This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Customer Requirements for Developers and have Marcho Behler on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Benefit of providing a super-class reference to a subclass object ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Benefit of providing a super-class reference to a subclass object ?" Watch "Benefit of providing a super-class reference to a subclass object ?" New topic
Author

Benefit of providing a super-class reference to a subclass object ?

Prince Chauda
Greenhorn

Joined: Feb 13, 2008
Posts: 8
While providing a reference of a super-class to the object of the sub-class we are simply
decreasing the usability of that object because it can not call the methods declared only in its own class.
So what are the benefits (other than tight encapsulation and loose coupling ) of this feature of java ?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43423
    
  32
You can use polymorphism. You will have to look in the books or tutorials for more details.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Prince Chauda wrote:...other than tight encapsulation and loose coupling...

Would that not be "enough"?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Benefit of providing a super-class reference to a subclass object ?
 
It's not a secret anymore!