abstract class vs final class

abstract class vs final class


Abstract class and Final class are very different basically in their nature and usage in Java language. Both are very contrary in their functionality.

Following table gives the differences: abstract class vs final class.
Property Abstract class Final class
Subclassing Should be subclassed to override the functionality of abstract methods Can never be subclassed as final does not permit
Method alterations Abstract class methods functionality can be altered in subclass Final class methods should be used as it is by other classes
Instantiation Cannot be instantiated Can be instantiated
Overriding concept For later use, all the abstract methods should be overridden Overriding concept does not arise as final class cannot be inherited
Inheritance Can be inherited Cannot be inherited
Abstract methods Can contain abstract methods Cannot contain abstract methods
Partial implementation A few methods can be implemented and a few cannot All methods should have implementation
Immutable objects Cannot create immutable objects (infact, no objects can be created) Immutable objects can be created (eg. String class)
Nature It is an incomplete class (for this reason only, designers do not allow to create objects) It is a complete class (in the sense, all methods have complete functionality or meaning)
Adding extra functionality Extra functionality to the methods can be added in subclass No extra functionality can be added and should be used as it is

I am sure now you are clear of abstract class vs final class.

Pass your comments and suggestions on this tutorial "abstract class vs final class".

View All for Java Differences on 90 Topics

Leave a Reply

Your email address will not be published. Required fields are marked *