Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Composition Vs Inheritance

 
Balakrishna Thati
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In TIJ,

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.

Regards
Balakrishna Thati
 
Ankit Garg
Sheriff
Posts: 9527
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic