How can we restrict inheritance for a class? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 7

How can we restrict inheritance for a class?

24th Oct 2017, 7:10 PM
Chandrakant More
Chandrakant More - avatar
2 Réponses
+ 7
We can prevent inheritance with keyword final. For example: public final class Person { }
24th Oct 2017, 7:35 PM
Alice
Alice - avatar
+ 4
Private data and methods can't be seen in subclasses.
24th Oct 2017, 9:57 PM
John Wells
John Wells - avatar