Previous Next

Interview Questions on Java - Abstrct & Interface

1. What is Abstract class?

A class which is not fully implemented is called abstract class.

2. What is Concrete class?

A class which is fully implemented is called concrete class.

3. Can we create an Object for Abstract class?

No.

4. Can we keep abstract keyword for concrete class?

Yes, to avoid creation of Object we can use this.

5. can we keep abstract methods in concrete class?

No.

6. What is final?

final is a keyword which is used for classes, methods and variables. final classes can not inherit to canother classes. final methods can not override. final variables can not change.

7. Can we declare class with both abstract and final.

No. Because abstract needs to inherits to the child class, but final is used to avoid the inheritance.

8. Can we keep Constructor as abstract.

No, always Constructor should be concrete.

9. What is Interface?

Interface is a blue print of classes and contains all abstract methods. We can achieve 100% abstraction by using interface because there will be no constructors.

10. What are the modifiers applicable for methods in Interface?

public and abstract.

11. What are the Default modifiers for methods in Interface?

public and abstract.

12. What are the modifiers applicable for variables in Interface?

Public,static and final.

13. What are the Default modifiers for variables in Interface?

Public,static and final.

14. What is the main difference between Abstract and Interface?

In Abstract we can use any modifiers, but in Interface we should use public modifiers only.

Previous Next