• Bhanu Prakash Paluru

Can we make an abstract class as final?

Introduction: An abstract class is a collection of both Concrete and Abstract methods


When to go for an Abstract class?

If your requirement is to create only the common reusable methods then go with Abstract class


As the abstract class is a combination of both complete and incomplete methods, each and every abstract class must contain at least one implementation class.


The base rule for Abstract class:

So, it justifies the base rule of an abstract class that is "Each and Every Abstract class must participate in Inheritance"


Can we create an object of Abstract class? No, java doest allow you to create an object of the abstract class directly, but as each and every abstract class participates in inheritance we can create the object of abstract class indirectly.

Ex: <Base class name> object reference= new <Derived class name> ( ) ;


What happens if we make an abstract class as final?

Java does not allow you to make the abstract class as final it gives you a compile-time error.

Conclusion:

No, we cannot make an abstract class as final. Reason behind:

Once we make any class as final, it cannot participate in inheritance. But the base rule for abstract class says "Each and Every Abstract class must participate in Inheritance". Please watch the video Can we make an abstract class as final?



130 views

©2020 by Real Time Selenium WebDriver Automation.