Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

one question

 
Jack Nicholson
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Joe Ess
Bartender
Posts: 9280
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic