Define a final class in java. Explain the purpose of final class

Define a final class in java

A class declared as final cannot be extended further by any other class. The best example of such a class is the String class.

Declaring the class as final has further implications too:

The methods of a final class cannot be overridden. They can be ‘inlined' though. This way you may be able to overcome the performance issue caused due to the final class.
What is an interface? Explain with an example using java
What is an interface? - A class that implements an interface is compelled to implement all the methods that have been declared in the interface...
How can we implement multiple inheritances in java?
Multiple inheritances - Java does not support multiple inheritances. However, interfaces can be used in place of multiple inheritances...
Purpose of ‘instanceof’ keyword in java
Purpose of ‘instanceof’ keyword - The instanceof keyword is used to check the type of an instance of an object...
Post your comment