File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question on object reusability

 
Vallabhaneni Suresh Kumar
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between object reuse using inheritance versus object reuse using composition. Which of these techniques breaks the encapsulation of the extended object.


Thank you
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is either an interview question, or a school essay question. We won't answer it for you, but we could help you put an answer together. First tell us what "inheritance" and "composition" are.
 
Vallabhaneni Suresh Kumar
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Holding the reference of the other class within some other class is known as composition.
Acquiring the properties of a base class into the child class is known as inheritance

Thank you
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic