‎2007 Dec 20 8:13 AM
Hi to all,
can any one explains me about final concept in oops?
Thanks
Priya
‎2007 Dec 20 8:16 AM
If a class is defined as final, it cannot be subclassed. You can't create a class that will inherit from it.
This can be overcome, to an extent, by using composition, rather than inheritance.
matt
‎2007 Dec 20 8:16 AM
If a class is defined as final, it cannot be subclassed. You can't create a class that will inherit from it.
This can be overcome, to an extent, by using composition, rather than inheritance.
matt
‎2007 Dec 20 8:18 AM
Hi Matthew ,
can u tel me what is composition?and how it can overcome?
Thanks & Regards
Priya
‎2007 Dec 20 8:23 AM
Instead of subclassing a class (CLASSA), you create a new class(CLASSB) which has, as an attribute, an object reference to CLASSA. You can then create methods in CLASSB with the same signature as those in CLASSB, and pass those parameters to a call to the same method in CLASSA - with or without adding your own functionality.
[This article|http://www.artima.com/designtechniques/compoinh.html] explains the concepts in more detail.
matt
‎2007 Dec 20 9:19 AM
‎2007 Dec 20 8:23 AM
Hi,
Abstract and Final Methods and Classes
The additions ABSTRACT and FINAL for the statements METHODS and CLASS can be used to define abstract and final methods or classes.
Abstract methods are declared in abstract classes and cannot be implemented in the same class but only in a subclass of the inheritance tree. It is therefore not possible to instantiate abstract classes.
Final methods cannot be redefined in subclasses. Final classes cannot have other subclasses and close an inheritance tree finally.
I think you got clear picture if a method is defined in super class and declared as final means you cant redefine in subclass that method.
Regds
Sivaparvathi
Please reward points if helpful....