This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Composition Vs Inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Composition Vs Inheritance" Watch "Composition Vs Inheritance" New topic

Composition Vs Inheritance

Balakrishna Thati

Joined: Mar 12, 2008
Posts: 23

During Composition discussion, it is mentioned that

In composition, you can change the member objects @ runtime, to dynamically change the behaviour of the program.

Inheritance does not have this flexibility since compiler must place compile time restrictions on classes created with inheritance.

I doesn't understand this concept.

Can any one give an example code illustration this.

Balakrishna Thati
Ankit Garg

Joined: Aug 03, 2008
Posts: 9400

Hi Balakrishna! Welcome to javaranch.

I think by TIJ you mean Thinking in Java. Anyways I think this is not related to SCJP as it is more of a general Object Orientation concept which is not tested in SCJP...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Have you checked out Aspose?
subject: Composition Vs Inheritance
It's not a secret anymore!