Pages

Abstraction Interview Questions in Java



Abstraction Interview Questions in Java

Without wasting of time today we start our topic Abstraction Interview Questions in Java.

Can abstract class be final in Java?

No, abstract class can not be final in Java

Can abstract class have static methods in Java?

Yes, abstract class can declare and define static methods,

Can you create instance of abstract class?

No, you can not create instance of abstract class in Java,

What is abstract method in Java?

An abstract method is a method without body.

Can abstract class contains main method in Java ?

Yes, abstract class can contain main method, it just another static method and you can execute Abstract class with main method, until you don’t create any instance.

Can abstract class have constructors in Java?

Yes, abstract class can declare and define constructor in Java.

Can we use abstract keyword with constructor, Instance Initialization Block and Static Initialization Block?

No. Constructor, Static Initialization Block, Instance Initialization Block and variables can not be abstract.

Can we instantiate a class which does not have even a single abstract methods but declared as abstract?

No, We can’t instantiate a class once it is declared as abstract even though it does not have abstract methods.

Can we declare abstract methods as static?

No, abstract methods can not be static.

Can a class contain an abstract class as a member?

Yes, a class can have abstract class as it's member.

Abstract classes can be nested. True or false?

True. Abstract classes can be nested i.e an abstract class can have another abstract class as it’s member.

Can we declare abstract methods as synchronized?

No, abstract methods can not be declared as synchronized. But methods which override abstract methods can be declared as synchronized.

Can we declare local inner class as abstract?

Yes. Local inner class can be abstract.

Can abstract method declaration include throws clause?

Yes. Abstract methods can be declared with throws clause.




No comments:

Post a Comment

 

Most Reading