Friday 24 May 2013

JAVA INTERVIEW QUESTIONS - Abstract Class

Tags


1.What is an abstract class?
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation.
Note:
  • If even a single method is abstract, the whole class must be declared abstract.
  • Abstract classes may not be instantiated, and require sub-classes to provide implementations for the abstract methods.
  • You can’t mark a class as both abstract and final.


2.Can we instantiate an abstract class?
An abstract class can never be instantiated. Its sole purpose is to be extended (sub-classed).

3.When you declare a method as abstract, can other non abstract methods access it?
Yes, other non-abstract methods can access a method that you declare as abstract.

4.Can there be an abstract class with no abstract methods in it?
Yes, there can be an abstract class without abstract methods.

Differences between Interface and Abstract class


EmoticonEmoticon