Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

When we will use an Interface and Abstract class?

Answer Posted / mohd shakir

I think if you have basics knowledge of any OO language then you should be aware of basic definition of Interface and Abstract class.

Here I am going to explain when to use Interface and when to use Abstract class.

Abstract class:-> If you have a common functionality that is used by its subclasses then put that method in super abstract class(now you need not to define that common method in every subclass again and again) This is what you can't do with Interface(because all the methods are by default abstract).

Interface:-> If you don't have the scenario as I discussed above(in abstract class)then choose Interface.And you can also achieve multiple inheritance using Interface that is not possible in case of Abstract class.

Is This Answer Correct ?    21 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you initialize an arraylist in java?

1097


How do you compare values in java?

1096


What are the topics in core java?

1127


Name some classes present in java.util.regex package.

1077


What are the actions that can occur when a thread enters blocked state?

1112


What does \ mean in regex?

1320


Explain thread life cycle in java?

1096


What is functional interface in java example?

1053


What exactly is a .class file?

1098


Is static a keyword in java?

1029


Mention the default values of all the elements of an array defined as an instance variable.

1037


What is this keyword used for?

1182


What is a class component?

1220


What is java and its types?

1168


What will happen if non-synchronized method calls a static synchronized method and what kind of lock it acquires?

1200