Abstract Class Interview Questions

By | May 26, 2014

Interfaces are among the common topics discussed in java interview while most of the candidates know what an Abstract Class is and have used it several times but they fail to answer some surrounding Abstract classes which goes against them. The aim of this article is to list those questions .If you encountered some question oon Abstract classes which is not in this list feel free to submit it in comments or mail us

  • Difference between an abstract class and interface in java
  • Reffer this article.
  • Can abstract class be final in Java?
    NO
  • Can abstract class have static methods in Java?
    Yes abstract classes can have static methods like other classes.
  • Can you create instance of abstract class?
    No abstract classes are not meant to be instantiated.We can not create instances of them.
  • When is an abstract class favoured over interface?
    Since it’s almost impossible to add a new method on a published interface, it’s better to use abstract class, when evolution is concern. Abstract class in Java evolves better than interface. Similarly, if you have too many methods inside interface, you are creating pain for all it’s implementation, consider providing an abstract class for default implementation.
  • Can an abstract class contains main method ?
    YES
  • Can we have constructors in an abstract class?
    Yes but again since you cannot instantiate an abstract class these will be called in chained constructor call.

Have a look at at this article Difference between abstract class and interface Java to know the differences between an abstract class and interface .

One thought on “Abstract Class Interview Questions

  1. Pingback: Interface Common interview questions | CrackDInterview

Leave a Reply

Your email address will not be published. Required fields are marked *