aspose file tools*
The moose likes Beginning Java and the fly likes real world example of polymorphism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "real world example of polymorphism" Watch "real world example of polymorphism" New topic
Author

real world example of polymorphism

Federico Minarelli
Greenhorn

Joined: Jan 16, 2010
Posts: 29
Hello!

I would like to ask you a question.. Should you be asked "why are oo concepts such as polymorphis, abstraction etc so important? Could you please motivate your answer with a real world example (avoid classical examples like Shapes and Animals, please)?", how would you answer? Can you please point me to some online resources about this please?

Thanks a lot!
Bye!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

How are shapes not a real-world example? Drawing programs exist.

(I actually worked on a system where we had animals, too, actually, but that was in Lisp/CLOS.)

Can you really not think of any examples where there are types and subtypes?
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
Federico Carbonetti wrote:Hello!

I would like to ask you a question.. Should you be asked "why are oo concepts such as polymorphis, abstraction etc so important? Could you please motivate your answer with a real world example (avoid classical examples like Shapes and Animals, please)?", how would you answer? Can you please point me to some online resources about this please?

Thanks a lot!
Bye!


How about any program dealing with cars? I'm willing to bet there are going to be times when all you care about is that the object is a car, even if the object being passed is a 1966 Shelby Cobra.


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

A real-world example is javax.swing.JComponent. Note that subclasses of that include things like buttons, labels, combo boxes, and so on. All of them have common behaviour which is encapsulated in JComponent and individual behaviour which they control themselves.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: real world example of polymorphism