The second use of 'final' keyword in Inheritance is to prevent inheritance by specifying 'final' for class.
If we specify 'final' for any superclass, then we cant create sub classes for the superclass.
Lets implement this on Eclipse IDE:
1. Create a superclass 'Superclass' by specifying it as 'final' as shown below:
Download this project:
Click here to download the project containing the 'Superclass' and 'Subclass' class files used in this post (You can download this project and import into Eclipse IDE on your machine)
Please comment below to feedback or ask questions.
'Packages' concept will be explained in the next post.
No comments:
Post a Comment