Friday, December 7, 2001 01:21 PM
A final class is a fully defined class (ie all the methods are defined) which cannot be inherited by another class. When you can declare that your class as final, your class cannot be subclassed. Some extract from the Java Doc...
There are (at least) two reasons why you might want to do this:
1. To increase system security by preventing system subversion
One mechanism that hackers use to subvert systems is to create a subclass of a class
and then substitute their class for the original.
The subclass looks and feels like the original class but does vastly different things,
possibly causing damage or getting into private information.
2. For reasons of good object-oriented design
You may think that your class is "perfect" or that, conceptually, your class should have no subclasses
An abstract class is a skeletal class defined which is meant to be subclassed only. You cannot instantiate an abstract class. Sometimes, a class that you define represents an abstract concept and, as such, should not be instantiated.Click here
to read more on abstract classesClick here
to read more on final classes