Interview Question on Abstraction

Interview question on abstraction


  •  Is it compulsory for a class which is declared as abstract to have at least one abstract method?

Not need. Abstract class may or may not have abstract methods.


  • Why final and abstract can not be used at a time?

Because, final and abstract are totally opposite in nature. A final class or method can not be modified further where as abstract class or method must be modified further.


  •  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 private? Justify your answer?

No. Abstract methods can not be private. If abstract methods are allowed to be private, then they will not be inherited to sub class and will not get enhanced.


  • We can’t instantiate an abstract class. Then why constructors are allowed in abstract class

It is because, we can’t create objects to abstract classes but we can create objects to their sub classes. From sub class constructor, there will be an implicit call to super class constructor. 







Comments

Popular posts from this blog

OBJECT ORIENTED CONCEPTS

Arrays programms