File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes one question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "one question" Watch "one question" New topic
Author

one question

Jack Nicholson
Ranch Hand

Joined: Sep 07, 2002
Posts: 41
I need one clarification in OOPS,
I am illustrating Polymorphism with following example
There is one class - 4SIDE
& sub Classes - Square, rectangle , parallelogram
extends 4SIDE class to inherite properties such as all are having 4 sides.
but I am illustarting polymorphism example with inheritance in picture
although behavoiur is like polymorphic, internally we are using inheritance for the same.
Is there any example where inheritance is not in picture ??
& where it is mostly used in practical scenario..?
can some body explain me pls?
I need thought on this.
Thanx


Jack Nicholson
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8964
    
    9

There is a mechanism in Java which allows polymorphism without inheritance, but since I get the feeling that this is a homework assignment, I will refrain from blurting it out. Take a look at the various collections in java.util.
I'm not sure what you mean by a "practical scenerio". Polymorphism is all over the place in the Java API. Poke around in the API documentation. The tree-looking thing under the class name is the inheritance tree. Under that is "Direct Known Subclasses". Use these two features to navigate a particular tree, say java.util, and you may be able to piece together an example.
[ October 08, 2003: Message edited by: Joe Ess ]

[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: one question