Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

final concept

Former Member
0 Likes
657

Hi to all,

can any one explains me about final concept in oops?

Thanks

Priya

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
636

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

5 REPLIES 5
Read only

matt
Active Contributor
0 Likes
637

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

Read only

Former Member
0 Likes
636

Hi Matthew ,

can u tel me what is composition?and how it can overcome?

Thanks & Regards

Priya

Read only

matt
Active Contributor
0 Likes
636

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

Read only

Former Member
0 Likes
636

Thank you very very much

Read only

Former Member
0 Likes
636

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....