Easy learning with example program codes

java interview questions and answers abstract class

Abstract class in real world:

Let us take an example of graphic objects. Different graphic objects are there such as circle, rectangle, triangle etc. They all have state defined by their positions, colour etc. and behaviour defined by draw, resize, calculate size etc. As all these object types has common things but with different implementations. We can take advantage of common things with different implementations and put these common things in an abstract class (say GraphicObjects) then extends this class in subclasses to provide specific implementations.

Abstract class in java:

Abstract class is a way of implementing 0 to 100% abstraction. A class declared with abstract keyword is known as an abstract class. An abstract class may or may not contain abstract method. Abstract classes cannot be instantiated.

Java interview questions on abstract class

  • What is abstract class in java?
  • Why abstract class is used in java?
  • Can abstract class have constructors in java?
  • Can abstract class be final in java?
  • Can we declare local inner class as abstract?
  • What is difference between abstract class and interface in java?

  • Copyright © 2018 CodesJava Protection Status SiteMap