Core Java Interview Questions-Abstract classes

This Core Java Interview Questions-Abstract Classes page provides all the core java interview questions about abstraction and abstract classes including concrete methods, abstract methods, instantiation of the abstract class, main method in the abstract class, accessing non-static members of the abstract class, final and abstract modifiers combination and much more.


What is an abstract class?
The partial definition of Object is called abstract class.
An abstract class can be defined using the abstract modifier.


What type of method allowed in Abstract class?
abstract class allows Concrete & Abstract methods.


What are Concrete & Abstract methods?
Concrete methods having the definition(body).
Abstract methods don’t have definitions. These are called specifications of Object.


Can we Instantiate abstract class?
No, the abstract class is partially defined hence we can instantiate only classes directly.


Can we define main() inside an abstract class?
Yes allowed. JVM invokes the main method directly using its class name.


Can we define the abstract class with no abstract methods?
Yes, but it is not recommended because the meaning of abstract class is the partial definition of Object.


How can we instantiate the abstract class?
By instantiating its extended(child) class.


Can we place instance variables inside an abstract class?
Yes, and we can provide initialization in the process of Child object creation using super() method.


How can we initialize abstract class object?
using the super() method.


Can an abstract class be final?
No, the abstract class must be extended whereas final class cannot be extended.


Can an abstract method be final?
No, the abstract method must be overridden in the extended class.


Why can abstract method not be static?
an abstract method is specific functionality
static method is common functionality
Hence we cannot combine both abstract & static.


Can a final class extend abstract class?
Yes, but it has to implement all the specifications(abstract methods) of an abstract class.


>Core Java Interview Questions-interfaces<

Share this