When will we go for abstract class and when will we go for interface?

Showing Answers 1 - 21 of 21 Answers

When you have some methods to be implemented as common and some methods you want to keep abstract, that time we will go for abstract class. You want to provide contract between class and object. And you don't want to implement any method as common that time we will go for interface.

  Was this answer useful?  Yes

Shivang Modi

  • Oct 5th, 2011
 

Whenever there is need of having same common features among all subclasses of super class, we have to go for an abstract class.
Whenever there is no common features for subclasses of super class, we have to go for an interface.

  Was this answer useful?  Yes

AFROZ AZAM

  • Oct 23rd, 2011
 

When we want to implement a class in future we go for abstract class.

we go for interface in order to achieve 100% abstractness.

  Was this answer useful?  Yes

Fathima

  • Dec 16th, 2011
 

When the sub-types behaviour is totally different then you use an interface, when the sub-types behaviour is partially common and different with respect to the supertype an abstract class is used.

  Was this answer useful?  Yes

When you want to extend more than one then go for interface because java does not support multiple inheritance. So you can not extends more one class but using interface we can do it.

  Was this answer useful?  Yes

sampra

  • Mar 6th, 2012
 

Correct ans would be:Whenever there is need of having same common features among all subclasses of super class, we have to go for an abstract class.
Whenever there is no common features for subclasses of super class, we have to go for an interface.

  Was this answer useful?  Yes

Praveen Kumar Singh

  • Mar 13th, 2012
 

When you have some methods to be implemented as common and some methods you want to keep abstract, that time we will go for abstract class. You want to provide contract between class and object. And you don't want to implement any method as common that time we will go for interface.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions