0

Everyone knows that if a class is declared as final then it doesn't allow inheritance. Is there any other way to restrict inheritance .?

24th Aug 2016, 3:06 AM
Sarath chalapaka
Sarath chalapaka - avatar
4 Antworten
+ 1
- Make all member elements and methods private 
24th Aug 2016, 4:40 AM
kelvin kosgei
kelvin kosgei - avatar
+ 1
If you make the constructor private no other class can instantiate an object from it. As subclasses also call on the constructor of the extended class, it should not be possible to do so with a private one.
24th Aug 2016, 10:00 AM
Frostbyte
0
thanks
24th Aug 2016, 6:12 AM
Sarath chalapaka
Sarath chalapaka - avatar
0
put a class in a new package with no access modifier
24th Aug 2016, 10:30 AM
Tiger
Tiger - avatar