aspose file tools*
The moose likes Beginning Java and the fly likes inheritance functionality with out extends Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "inheritance functionality with out extends" Watch "inheritance functionality with out extends" New topic
Author

inheritance functionality with out extends

deepa sabbani
Greenhorn

Joined: Apr 11, 2008
Posts: 8
how to achieve inheritance functionality with out using extends or implements keyword?
Andre Brito
Ranch Hand

Joined: Dec 13, 2007
Posts: 95

Maybe importing a package?
Ok, it's not very usual and right, but it's a way, isn't it?
But why you can't use implements or extends?
deepa sabbani
Greenhorn

Joined: Apr 11, 2008
Posts: 8
can we achieve through composition
amitabh mehra
Ranch Hand

Joined: Dec 05, 2006
Posts: 98
Originally posted by deepa sabbani:
can we achieve through composition


Composition is different from inheritance. It is basically HAS-A relationship where as inheritance is IS-A relationship. If you are using composition, it would mean that you are using the other object's functionality. Its just a design issue as to which technique you want to choose. You can take a look at inheritance vs composition
[ June 05, 2008: Message edited by: amitabh mehra ]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18981
    
  40

Originally posted by deepa sabbani:
can we achieve through composition


Sure. You can simulate it. But why?

I guess if you have some sort of mechanism that references through composition, then have a relationship table (along with method jump table), you can simulate inheritence -- provided that everyone uses your mechanism for calling / casting, etc. But this would be a lot of work to simulate something that is already supported.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inheritance functionality with out extends