aspose file tools*
The moose likes Beginning Java and the fly likes about inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "about inheritance" Watch "about inheritance" New topic
Author

about inheritance

vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
hello guys,
what is the advantage of inheriting a parent class A compared to creating a new object of class A if we want to use class A's method? Is it because of method overriding?


I'm not available, my BF's name is WORK.
ak pillai
author
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
You can achieve code reuse in two ways:

1. implementation-inheritance (Gives you polymorphism as well)
2. composition (Can get polymorphism by using interface-inheritance)

Inheritance allows you to have a default behaviour in your parent class and subclasses can override this default behaviour. Implementation-Inheritance strongly couple classes together. So should favour interface inheritance with composition for reuse over implementation inheritance.

For more details refer Q8-Q10 on free sample PDF download at http://www.lulu.com/content/192463


java j2ee job interview questions with answers | Learn the core concepts and the key areas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about inheritance
 
Similar Threads
Object
deprecated methods
Events
How to call a stand alone class from WAS???
java.lang.OutOfMemoryError: PermGen space