Introduction
This is now an important question asked by an interviewer in the interview. I have found many solutions on the Internet regarding "When to use interface and abstract method?". Lately, I thought about writing an article on simplifying my experience and what I learned. If you check both the things, they seem to be very similar, which makes a confusion in the mind while answering these questions.
Here, in this article, I will try to explain these things.
Abstract Class
Before giving the introduction about abstract class, I will try to explain the abstract method, first.
Abstract Method
A method without any particular body is known as an abstract method. These methods contain only declaration of the method.To declare an abstract method, we have to use abstract modifier on the method.The class, under which these abstract methods are defined, is referred to as an abstract class, and this also has to be declared using abstract modifier.The implementation of abstract method is done by a derived class. When the abstract class inherits the derived class, the derived class must implement the abstract methods using override keyword in it.
Abstract Class An abstract class is a special class that contains both abstract and non-abstract members in it.
Example
public abstract class Cars
{
//Abstract Methods
public abstract double price();
public abstract int getTotalSeat();
}
Here are some points regarding abstract class.
- Abstract class can contain abstract members as well as non-abstract members in it.
- A class can only inherit from one abstract Class.
- We cannot create object of an abstract class.
Interface
It is also user defined type like a class which only contains abstract members in it. These abstract members should be given the implementation under a child class of an interface. A class can be inherited from a class or from an interface.
Points to remember
- Interface contains only abstract methods.
- We cannot create object of an interface.
- The default scope for a member in Interface is Public. So, no need to use the Public access specifier in the program.
NOTE - In case of multiple inheritance, use Interface.
From both the definitions, it gets concluded that,
Figure 1

Figure 2

Now, I have class like Hyundai and Toyota which are derived from a parent class called Car. Here, I have the car methods as follow:
public class Cars
{
public string Wheel()
{
return "4 wheeler";
}
public string CheckAC()
{
return "AC is available";
}
public string CallFacility()
{
return "Call Facility supported";
}
}
Here, I have 2 types of cars which are inherited from Cars.
using oops1;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace oops1
{
public class Hyundai : Cars
{
static void Main(string[] args)
{
Hyundai dust = new Hyundai();
Console.WriteLine(dust.CallFacility());
Console.WriteLine(dust.Wheel());
Console.WriteLine(dust.CheckAC());
Console.ReadLine();
}
}
}
Now, it runs as expected and gives the following output .

Similarly, as Toyota is a car and it also inherits from Cars class.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace oops1
{
public class Toyota : Cars
{
public string DiscountPrice()
{
return "20% discount on buying Toyoya Cars";
}
static void Main(string[] args)
{
Toyota Toy = new Toyota();
Console.WriteLine(Toy.CallFacility());
Console.WriteLine(Toy.Wheel());
Console.WriteLine(Toy.CheckAC());
Console.WriteLine(Toy.DiscountPrice());
Console.ReadLine();
}
}
}

We need some methods which are common to both the classes but their implementation is different.
- PRICE()- Both have price but different price.
- TotalSeat()- Both have total seats but different no. of seats.
- colors()- Both cars are of different colour.
So, here are the options for implementing these methods in both classes.
- Can I go for a normal class?
- Should I use interface here?
- Can I use an abstract class?

- If we are taking class, then we can only write normal methods having common implementation there. But, this will not satisfy our requirement because we need separate implementations in both the classes. Thus, we will not go forward with Class.

If we go for interface, we can achieve our goal but it will be like this. First, I will declare n interface, as follows.
interface IExtra
{
double price();
int getTotalSeat();
string colors();
}
Now, let me first inherit the Toyota class from Cars class and IExtra interface class to achieve our goal.
The code is given below.
namespace oops1
{
public class Toyota : Cars,IExtra
{
public string DiscountPrice()
{
return "20% discount on buying Toyoya Cars";
}
public double price()
{
return 1000000.00;
}
public int getTotalSeat()
{
return 5;
}
public string colors()
{
return "Red";
}
static void Main(string[] args)
{
Toyota Toy = new Toyota();
Console.WriteLine(Toy.CallFacility());
Console.WriteLine(Toy.Wheel());
Console.WriteLine(Toy.CheckAC());
Console.WriteLine(Toy.DiscountPrice());
Console.WriteLine("Total ONRoad Price:"+ Toy.price());
Console.WriteLine(Toy.getTotalSeat());
Console.WriteLine(Toy.colors());
Console.ReadLine();
}
}
}

So, the sketch diagram of this implementation will be like this.

Abstract Class
Now, we will see here how we can solve our problem using Abstract Class.
1. Define an abstract class as Car.
2. Put all the common functionality in simple methods and all the methods whose implementation is different but name is same. Make them Abstract method.
Here is my Car abstract class.

using System;
using System.Collections;
using System.Collections.Generic;
namespace oops1
{
public abstract class Cars
{
//put all the common functions but diffrent implementation in abstract method.
public abstract double price();
public abstract int getTotalSeat();
public abstract string colors();
//put all the common property in normal class
public string Wheel()
{
return "4 wheeler";
}
public string CheckAC()
{
return "AC is available";
}
public string CallFacility()
{
return "Call Facility supported";
}
}
}
Now, here is my Toyota class which is derived from Cars abstract class.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace oops1
{
public class Toyota : Cars
{
public string DiscountPrice()
{
return "20% discount on buying Toyoya Cars";
}
public override double price()
{
return 1000000.00;
}
public override int getTotalSeat()
{
return 5;
}
public override string colors()
{
return "Red";
}
static void Main(string[] args)
{
Toyota Toy = new Toyota();
Console.WriteLine("-------Common property defined commonly in Cars Class----------");
Console.WriteLine(Toy.CallFacility());
Console.WriteLine(Toy.Wheel());
Console.WriteLine(Toy.CheckAC());
Console.WriteLine("-------Own property defined in Toyota class------------");
Console.WriteLine(Toy.DiscountPrice());
Console.WriteLine("-------Common method but implementation is diffrent defined in IExtra Interface------------");
Console.WriteLine("Total ONRoad Price:"+ Toy.price());
Console.WriteLine(Toy.getTotalSeat());
Console.WriteLine(Toy.colors());
Console.ReadLine();
}
}
}
And thus, the result will be the same.

Conclusion
When we have the requirement of a class that contains some common properties or methods with some common properties whose implementation is different for different classes, in that situation, it's better to use Abstract Class then Interface.
Abstract classes provide you the flexibility to have certain concrete methods and some other methods that the derived classes should implement. On the other hand, if you use interfaces, you would need to implement all the methods in the class that extends the interface. An abstract class is a good choice if you have plans for future expansion.
Now, I will explain the second use of Abstract Class here.
Imagine, we have taken a normal parent class as Cars where we have only defined the common methods. And, my Toyota class is derived from the Cars class. This will look like the below code.
public class Cars
{
public string Wheel()
{
return "4 wheeler";
}
public string CheckAC()
{
return "AC is available";
}
public string CallFacility()
{
return "Call Facility supported";
}
}
And, here is the Toyota class after inheriting from Cars.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace oops1
{
public class Toyota : Cars
{
public string DiscountPrice()
{
return "20% discount on buying Toyoya Cars";
}
static void Main(string[] args)
{
Console.ReadLine();
}
}
}
Here, users know only the Toyota class, its methods, and properties. The user can access the Cars class property and method by creating the object of Toyota class because it is a child class.
Now, the main demerit of this kind of Implementation is that it allows the user to create the object of the Parent class (which the user should not be aware of and this is not his strategy). Let's see what happens when the user creates the object.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace oops1
{
public class Toyota : Cars
{
public string DiscountPrice()
{
return "20% discount on buying Toyoya Cars";
}
static void Main(string[] args)
{
//Toyota Toy = new Toyota();
Cars ca = new Cars();
Console.WriteLine("-------Common property defined commonly in Cars Class----------");
Console.WriteLine(ca.CallFacility());
Console.WriteLine(ca.Wheel());
Console.WriteLine(ca.CheckAC());
Console.WriteLine("-------Own property defined in Toyota class------------");
Console.WriteLine(ca.DiscountPrice());
Console.ReadLine();
}
}
}
As we know, we won't be able to access the child class methods using parent class object, this Cars object will not access the DiscountPrice() Method because it is a child class method. This implementation will not satisfy our requirement. So, even if the user will create an object of Parent class, we need to check them because using that object, he can't able to access the child class method.

So, the main problem we face here is,
As the user is unaware of parent class, he is able to create the object of parent class and unable to access the child class method using parent class. So, to restrict this, we have to do the following things-
- We should not give the permission to create the object of parent class in child class
- We can only allow the user to create the child class object to access both parent class methods and child class methods.
Simple to do this Create the base class as an Abstract class and that will solve our problems as follow.
Even if you want to create the object of parent class, it shows the following error.using System; using System.Collections; using System.Collections.Generic; namespace oops1 { public abstract class Cars public string Wheel() { return "4 wheeler"; } public string CheckAC() { return "AC is available"; } public string CallFacility() { return "Call Facility supported"; } } }

So, this will solve our problem.
Conclusion
So, in those cases, we will use abstract class where we want to restrict the user from creating the object of parent class because by creating object of parent class, you can't call child class methods. So, the developer has to restrict accidental creation of parent class object by defining it as abstract class.
So, I think, in these ways, we can use abstract class in our real time project.
When To Use Interface In Real Time Project?
INTERFACE
It is also user-defined type like a class which only contains abstract members in it and these abstract members should be given implementation under a child class of an interface. A class can inherit from a class or from an interface.
interface I1
{
void MethodToImplement();
}
In your daily programming, you are using a lot of interfaces knowingly or unknowingly. If you are using a List, Dictionary, or Hash Table etc in your project, then you are indirectly using interface in your project because all collections are derived from an Interface, IEnumerable.
Here, I will not discuss about the uses of Interface. I will discuss when can we use our interface in C#.
Before explaining in details, I will ask you to focus on the following points.
- In C++, we have a concept of Multiple Inheritance where we find a serious problem called Diamond Problem.
- Thus, in C#, multiple inheritance is not supported. When there is a situation like multiple inheritance, use Interface.


The solution of the multiple inheritance can be provided by Interface. So, we can do this example using Interface as follows. In this way, the diamond problem of Inheritance is solved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OOPs2
{
interface Demo1
{
void print();
}
interface Demo2
{
void print();
}
class Program:Demo1,Demo2
{
void Demo1.print()
{
Console.WriteLine("Debendra");
}
void Demo2.print()
{
Console.WriteLine("Debendra");
}
static void Main(string[] args)
{
Program p = new Program();
((Demo2)p).print();
Console.ReadLine();
}
}
}
Now, I will narrate a real time scenario where we can use interface. I will go for the same example that I have done earlier.
using System;
using System.Collections;
using System.Collections.Generic;
namespace oops1
{
public class Cars
{
public string Wheel()
{
return "4 wheeler";
}
public string CheckAC()
{
return "AC is available";
}
public string CallFacility()
{
return "Call Facility supported";
}
}
}
Now, here is my Toyota class which is derived from Cars.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace oops1
{
public class Toyota : Cars
{
static void Main(string[] args)
{
Toyota Toy = new Toyota();
Console.WriteLine(Toy.CallFacility());
Console.WriteLine(Toy.Wheel());
Console.WriteLine(Toy.CheckAC());
Console.ReadLine();
}
}
}
Here is my Hyundai class which is derived from Cars.
using oops1;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace oops1
{
public class Hyundai:Cars
{
static void Main(string[] args)
{
Hyundai dust = new Hyundai();
Console.WriteLine(dust.CallFacility());
Console.WriteLine(dust.Wheel());
Console.WriteLine(dust.CheckAC());
Console.ReadLine();
}
}
}
A new feature for the Hyundai car is Introduced called GPS which is not supported in Toyota cars. Then, how can we implement and which way we can implement these?
Here, we have certain options like
- Go for a new class defining the GPS method and inherit it to the Hyundai Class.
- Go for an abstract class and define GPS method and inherit it on Hyundai class and implement the GPS method there.
- Directly create a method in Hyundai class and consume it.
- Go for Interface
.
CASE 1 - By Using simple class
Let's find what will happen if we use a class there, and declare a method as GPS and try to inherit in Hyundai class.
Created a new class as "NewFeatures, as shown below. -
Now, inherit the Hyundai class from NewFeatures. So, if we check this class, it was previously inherited from Cars class and for now, again inherits from NefFeatures class. So, it gives the following error when you try to run the program.class NewFeatures { public void GPS() { Console.WriteLine("GPS supported"); } }
Now, run the program and find out the error.using oops1; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace oops1 { public class Hyundai:Cars,NewFeatures { static void Main(string[] args) { Hyundai hun = new Hyundai(); Console.WriteLine(hun.CallFacility()); Console.WriteLine(hun.Wheel()); Console.WriteLine(hun.CheckAC()); Console.ReadLine(); } } }

This is simple because C# does not support multiple inheritance.
- CASE 2 - By using Abstract class
Now, go for abstract class and see what happens.
Now, let's try to inherit from abstract class.public abstract class NewFeatures { abstract public void GPS(); }
So, here is the error I got.using oops1; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace oops1 { public class Hyundai:Cars,NewFeatures { public override void GPS() { Console.WriteLine("GPS supported."); } static void Main(string[] args) { Hyundai hun = new Hyundai(); Console.WriteLine(hun.CallFacility()); Console.WriteLine(hun.Wheel()); Console.WriteLine(hun.CheckAC()); Console.ReadLine(); } } }

- CASE 3 - Direct creating a method called GPS() inside Hyundai class
This is very relevant way to use a unique method but it has a small problem. If for any reason we forget to create such common method, then it will not ask to write methods.Today, we are using one unique method so that is OK we can remember and write the method. Suppose, we have hundreds of such common methods and we forget to write 2 of them then it will run but not give the expected output,so we have to skip the way and go for the fourth one by defining interface.
- CASE 4 - By defining Interface
This is the most important case and we will see how it will solve our problem.Lets define the method in an Interface
Now inherit the Interface from Cars and see without implementing the GPS() method.interface INewFeatures { void GPS(); }
As we have not implemented the method it will show the following error as follow.using oops1; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace oops1 { public class Hyundai:Cars, INewFeatures { static void Main(string[] args) { Hyundai hun = new Hyundai(); Console.WriteLine(hun.CallFacility()); Console.WriteLine(hun.Wheel()); Console.WriteLine(hun.CheckAC()); Console.ReadLine(); } } }

So, the problems which happen in case 3 can be easily solved by using Interface. Now, let's implement the method and see will it solve the problem which arises in Case1 and case2 as follows.using oops1; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace oops1 { public class Hyundai:Cars,INewFeatures { public void GPS() { Console.WriteLine("GPS supported."); } static void Main(string[] args) { Hyundai hun = new Hyundai(); Console.WriteLine(hun.CallFacility()); Console.WriteLine(hun.Wheel()); Console.WriteLine(hun.CheckAC()); hun.GPS(); Console.ReadLine(); } } }

Thus, it resolves the demerits of all the above 3 cases. So, in this situation, we have to use Interface. Here, I have shown you the sketch diagram.

In this way, we can use abstract class and interface in our project depending on the condition.
Hope this article gives you an idea about when to use these 2 important things.If you have any suggestions, please feel free to comment so that I can include that in this article.

Radha ReddyPosted Jul 23, 2023, 4:40 AM
Thanks, easy to understand
Silambarasan PeriyasamyPosted Mar 15, 2023, 7:23 PM
Super and clearly explained
Manish KhandelwalPosted Oct 27, 2022, 12:09 AM
Excellent article, very very helpful.
Bogdan HrncicPosted Sep 2, 2022, 12:22 PM
Out of all sources, this one is by far the best. Great job!
Srinivas PabballaPosted Jul 14, 2022, 4:50 PM
Simply superb....
chinchu tharayilPosted Feb 24, 2022, 9:54 AM
Excellent write-up. The concept is lucidly explained with real-time scenarios. However, since the emergence of c# 8, the new features - default methods, access modifiers, and static variables, now, can be used with intereface. Default methods facilitate declaring and defining methods similar to the non-abstract methods in the abstract classes. So my question is this...Doesn't this facilitate us to use Interface more or less likely the way we use abstarct classes?
Musab ALIPosted Feb 20, 2022, 12:38 AM
Thanks, Easy to understand.
Bikash KatwalPosted Jan 23, 2022, 12:28 AM
Very well explained. Thanks man
Sharan B SPosted Jan 13, 2022, 3:40 PM
Thanks for this....
Aman ChaudharyPosted Dec 23, 2021, 1:30 PM
Awesome article. Created account just to write this. Great work man!!
Shikha VarshneyPosted Sep 27, 2021, 1:55 PM
Best Artical
Ankit MoriPosted Sep 27, 2021, 10:48 AM
Best Article I have found till date. Easy to understand.
Loqmaan MohammadPosted Jul 20, 2021, 10:56 AM
I have created account just to appreciate your work.
Loqmaan MohammadPosted Jul 20, 2021, 10:56 AM
Awesome.. you cleared all my doubts in a single article. Thank you
Chokder AcademyPosted Apr 18, 2021, 5:05 PM
I thought about interface and abstract class same as you but wasn't confident. After reading your article I am confident to use them. This is the best explanation. Thank you very much.
Rahul SharmaPosted Apr 15, 2021, 5:35 AM
Supper Man, now you have clear my all confusion. i dont want to lose you. Can we connect through Whatsapp so that we will keep in touch please ping me whenever see my comment 8210897189.
sachin inglePosted Mar 31, 2021, 5:36 AM
Very well explained. that's what I was looking for.
Pavan RamamurthyPosted Mar 30, 2021, 5:19 PM
Thank you for detailed information
Subrahmanyam ReddyPosted Feb 28, 2021, 6:44 AM
Thank you so much for sharing about when to use abstract and interface. I had a lot of confusion when to both and when to use single one of them. Now I got clarity on both of the functionality. Could you please explain about encapsulation like the way you have explained above
Weng Kin ChanPosted Nov 14, 2020, 10:30 AM
Is it recommended to use abstract and interface at the same time? I'm facing a situation in my APIs where Toyota and Hyundai implementing some common features differently while having some INewFeatures of themselves. Using interface will do the job, but, I would like to enforce more rules by using abstract so that people will always follow the standard naming of those common features. However, this is creating a problem where the abstract function and interface are having redundant signature and new common features will likely to be added to the interface but not the abstract
Puja TundalwarPosted Sep 28, 2020, 1:55 PM
Thank u so much Sir.
Manikanta NaniPosted Aug 15, 2020, 9:53 AM
It was a nice Explanation given by you. It helps a lot to understand when to use abstract and interface
Thirumalarao ThotapalliPosted May 30, 2020, 12:38 PM
Excellent explanation for abstract but interface good(its ok) expected more explanation for advantages of interface
Vijay KalePosted May 20, 2020, 1:04 AM
Awesome Explanation of both Abstract class and Interface. Thanks a lot for this.
mari arunPosted Feb 25, 2020, 6:57 AM
It is very useful to me. Thanks for you excellent explanation.
Dinesh GabhanePosted Nov 12, 2019, 5:53 AM
Nice Article. Thanks
alibasha syedPosted Oct 16, 2019, 9:06 PM
Excellent explanation
vishal yadavPosted Sep 6, 2019, 1:10 AM
We can create an object of abstract class and interface but we can not create instance of both. Please confirm what is the difference between object and instance of a class?
Sathiya MoorthyPosted Aug 20, 2019, 9:27 PM
Awesome beautifully explained.
Metta ChittibabuPosted Aug 7, 2019, 2:23 AM
Thank you.
Moulidharan SelvamPosted Jul 24, 2019, 3:45 AM
Very Nice explanation, Keep doing the god work..!!
NIshant GiriPosted Jul 16, 2019, 2:34 AM
Awesome, eye opener article on basic fundamentals.. Appreciate for writing suck insightful article.
Pankaj SaxenaPosted Jun 25, 2019, 4:15 AM
Thanks for sharing this concept with us.
Jiten GopePosted Jun 23, 2019, 7:46 AM
Wow, this is one of the best explanation I found in c-sharpcorner. Thanks Debendra..Keep it up.
Sonal SaxenaPosted Jun 7, 2019, 12:19 AM
Simple, logical and beautifully explained. This is one of the most common interview question. Now i realized where I was going wrong. Thanks a ton. Looking forward for more articles from you.
darpan mistryPosted Jun 4, 2019, 4:53 AM
I have little doubt in interface that, if interface contains unique method then we can put that method directly in to Particular Class so why we used Interface?
Pravin GupthaPosted May 10, 2019, 8:14 AM
The explanation are clear and in more elaborate manner!!! Keep up the good work :)
Om PrakashPosted May 2, 2019, 9:06 AM
I was confused that when to use Interface and Abstract class but now, after reading this article, there is no confusion about Interface and Abstract class. Thanks a lot to writing such a informative article.
Balamurugan RPosted Apr 12, 2019, 7:19 AM
Nicely explained & Very clear :)
Ameer SNPosted Feb 12, 2019, 1:11 AM
Thank You.. Get more idea about Abstract and Interface
Nikhil AlexPosted Jan 19, 2019, 2:25 AM
As for now this is the best and simplest way of explanation i found. thank you so much.
AMOL WAKCHAWAREPosted Dec 14, 2018, 12:45 PM
Superb Debendra. Good job done. And thanks for giving solid explanation with examples. Really very helpful.
Surya JeyPosted Dec 11, 2018, 12:14 AM
Very very helpful. Thanks bro for your clear explanations.
Rahul KadamPosted Dec 7, 2018, 9:39 AM
It's really nice
pooja mPosted Dec 5, 2018, 3:12 AM
Just Amazing. You clarified many doubts I have on these two topics from many days. Thanks. Keep posting like this and educate us more.
Sarika PPosted Nov 23, 2018, 4:53 AM
Article cleared my all doubts. nice explaination with examples. thank you
YashiPosted Nov 22, 2018, 7:10 AM
Hi bro can you give example on concrete methods ? And Explain What is concrete methods ?
YashiPosted Nov 22, 2018, 5:50 AM
Hi bro can you explain "If we are taking class, then we can only write normal methods having common implementation there".
YashiPosted Nov 22, 2018, 5:42 AM
Hi bro can you explain about "Call Facility supported".
YashiPosted Nov 22, 2018, 5:38 AM
Hi bro can you explain figure1
Aryabhatta ramanujanPosted Nov 17, 2018, 10:57 AM
Interviewer asked me why we use interface instead of abstract class if a class required only abstract methods. Let us assume in your example there is only one base class required that is either abstract or interface but both contains only abstract methods. so which should you prefer i know obviously interface but why ? . Because of interface supports multiple inheritance is not the correct answer i think. Could you explain it clearly in this or any new article.
Usama ShahidPosted Oct 28, 2018, 2:35 PM
It was fantastic bro, you've removed many confusions of the developers even they have some professional experience. Awesome sharing :)
kalu singh raoPosted Aug 5, 2018, 5:26 AM
Very very helpful and nice article. Keep it !!!
Viknaraj ManogararajahPosted Jul 15, 2018, 7:16 PM
Nice explanation, thank you for sharing.
Former memberPosted Jul 3, 2018, 5:22 AM
sir please give the example of dependency injection in mvc, Thanks sir
Former memberPosted Jul 3, 2018, 5:21 AM
Hi Sir, Really it is awesome and much understandable about interface and abstract class.
Arpit ShrivastavaPosted Jun 12, 2018, 10:24 AM
I would say, this is the best article I found on the internet explaining Abstract Class and Interface. Thanks, buddy. It was really helpful. Keep it up..
Sharmila babuPosted Jun 9, 2018, 4:18 AM
Very Good Explanation !!
Raj SharmaPosted May 24, 2018, 9:05 PM
Why u dont use virtual keyword to base class method.
Raj SharmaPosted May 24, 2018, 9:03 PM
Nice Explanation..but i have doubt why u don't use virtual keyword to declare parent class
Neha JaiswalPosted May 14, 2018, 3:34 AM
Bcz in 2nd case u explain that one by using interface only
Neha JaiswalPosted May 14, 2018, 3:32 AM
U wrote their if u have plan for future expansion then go for abstract class... didn't understand this point..I think for this we should go for interfaces.
ritavrat DwivediPosted May 12, 2018, 1:51 PM
CASE 3 - Direct creating a method called GPS() inside Hyundai class didn't understand what problem it can face?
yeshwanth reddyPosted Apr 22, 2018, 12:52 AM
I understood the concept. i have a doubt in multiple inheritance example which u have explained .why to add a GPS in a new class instead if we add in car class or on abstract class we can use it in derived class right
Akshay PorwalPosted Apr 16, 2018, 7:05 AM
Thanks a lot Debendra.. too good explanation .. Kudos
Shubhangi ShrivastavaPosted Apr 11, 2018, 3:42 AM
Thanks alot.. great and effective explanation :)
Faisal M.Posted Apr 9, 2018, 6:49 AM
This was well explained use case of both Interface and Abstruct Class. Thanks alot.
bambo GrowthPosted Mar 11, 2018, 6:26 PM
Thanks a lot Sir the most very useful explanation I ever found !
Shyamsunder KashyapPosted Jan 12, 2018, 2:52 PM
So nice thanks dude ...
susantha pereraPosted Jan 1, 2018, 11:11 AM
Thank you very much, nice explanation...
Hamid KhanPosted Dec 24, 2017, 1:51 AM
Very nice explanation thanks.........................
Anil SahPosted Dec 3, 2017, 5:04 AM
Nice articles..................................................
Esakki MuthuPosted Nov 24, 2017, 8:11 AM
Good explanation bro
Subhash KokarePosted Nov 18, 2017, 5:36 AM
Very simply explained...
Bhagavan BhagiPosted Oct 23, 2017, 9:26 AM
Thank u , explained very well
suresh shanmugamPosted Oct 12, 2017, 7:22 AM
Very good explanation.
Navjot KaurPosted Sep 22, 2017, 4:05 AM
Too good....cleared all my doubts. Thanks!
vikas vermaPosted Aug 26, 2017, 4:04 PM
Very nice explanation.
MEENAKSHI KEDWALPosted Aug 21, 2017, 5:44 PM
Thanks Debendra sir... you've cleared all my doubts related to the abstract class and interface with full explanation of examples.
Vineet ShankhdharPosted Jul 11, 2017, 2:27 PM
Nice Article brother.Very much Clear by this example
Vishal PrajapatiPosted Jun 28, 2017, 6:12 AM
Awesome explanation...
Prashant MorePosted Jun 25, 2017, 8:46 AM
To the point with good example
nithya veluPosted Jun 13, 2017, 2:08 AM
Thanks alot Bud ,Its very Simple to understand....
jaya jhaPosted Apr 5, 2017, 3:42 AM
Excellent explanation keep blogging ....
Sivaiah DevaraPosted Mar 19, 2017, 3:28 PM
Thnks Debendra, very clean explanation with best examples.
manohar rayallaPosted Mar 8, 2017, 10:47 PM
Excellent article......
Pradeep singhPosted Feb 22, 2017, 7:06 AM
Now only understand the concept......Thanks sir.......
Mahesh PullaguraPosted Jan 21, 2017, 1:38 PM
Nice articel with step by step explanation Thanks..
Muhammad AhmedPosted Jan 21, 2017, 6:54 AM
When we have to implement same functionality but with different implementation as above in GPS case then interface is a clean choice rathar than writing method directly in class. If we look IComparer interface it has default methods i.e Compare each custom types have its own functionality of Comparing it's objects but method signature is same.
Arjunan SelvamPosted Jan 1, 2017, 8:44 AM
When the abstract class inherits the derived class ???
Pankaj GuptaPosted Dec 13, 2016, 12:52 PM
Nice article with good explanation...
Kanniyappan KrishPosted Nov 16, 2016, 2:49 AM
Clear Explanation. Thanks
SubashPosted Sep 30, 2016, 8:42 AM
Nice article sir
Humayun Kabir MamunPosted Sep 27, 2016, 3:46 AM
Nice...
Mert OzogulPosted Sep 22, 2016, 3:16 PM
I read carefully and i understand. Thanks.
Debendra DashPosted Sep 22, 2016, 10:24 AM
If we declare an abstract class and implements all the methods of cars and some abstract method then we need to implement all the abstract methods to the derived class like(Hyundai,Toyota) as we need the GPS() method to be implementing only in Hyundai class thats why we cant go for a single abstract class.
Mert OzogulPosted Sep 22, 2016, 9:16 AM
In case2, at the same time you can define non-abstract methods (Cars class methods) in one abstract class. Thus case1 and case3 errors are solved. Namely i prefer one abstract class to class and interface. Why do i use interface instead of abstract class ?
srinivasulu PPosted Sep 16, 2016, 10:00 AM
Good
Umamaheswara Rao DasariPosted Sep 12, 2016, 3:50 AM
Very Clear Explenation...most of the people expect's any topic like this way of explenation....Thanks
Benjamin SukPosted Sep 12, 2016, 2:31 AM
Very good tutorial
Bhuvan PandeyPosted Sep 8, 2016, 12:45 AM
Good one.
Imran BashirPosted Sep 7, 2016, 11:27 AM
nice share
Debendra DashPosted Sep 6, 2016, 3:14 PM
Thanks a lot to all of you..
Pradeep SahooPosted Sep 6, 2016, 10:17 AM
Nice share ..
Apurba RanjanPosted Sep 6, 2016, 3:30 AM
Really Helpful
Anu VPosted Sep 6, 2016, 12:03 AM
Nice..
Sinraj VPosted Sep 5, 2016, 9:25 AM
Nice one
Rumbidzai MuserepwaPosted Sep 5, 2016, 8:07 AM
Thnks for such a clear tutorial
RakeshPosted Sep 4, 2016, 11:29 PM
Good one
Shamim UddinPosted Sep 4, 2016, 9:46 PM
Nice one
Vignesh ManiPosted Sep 4, 2016, 5:00 PM
Nice one
Savadamuthu SaravananPosted Sep 4, 2016, 2:09 PM
Very clear explanation thank you
sreenivasa kPosted Sep 4, 2016, 11:38 AM
Nice one sir
Surya KantPosted Sep 4, 2016, 7:41 AM
Valuable information. Good one
Prasanna MuraliPosted Sep 4, 2016, 7:25 AM
Nice Post..