GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Polymorphism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Polymorphism" Watch "Polymorphism" New topic
Author

Polymorphism

raja pratap
Greenhorn

Joined: Mar 21, 2000
Posts: 21
Which is an example of polymorphism.
a. inner classes.
b. anonymous classes.
c. method overloading.
d. method overriding.

I think the answer is both C and D.
Because method overloading is compile time polymorphism and method overriding is runtime polymorphism.
Its this right?? If not correct me....Maha help me ....
rag mul
Greenhorn

Joined: Oct 31, 2003
Posts: 12
I did read from tutorial (might be Baldwin's) and I remember that only run time polyporphism (overriding) is polymorphism.
But I donot agree with that since the polymorphism (having many forms) is implemented using both overloading and overriding.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Raja,
In Object Oriented Concepts, polymorphism and overriding always go together. So only ans d) is correct.
regds
maha anna

[This message has been edited by maha anna (edited April 07, 2000).]
Jane Rozen
Ranch Hand

Joined: Feb 12, 2000
Posts: 53
polymorphism and overriding always go together.

Maha, I'm playing devil's advocate again :
Both overloading and overriding are considered to be examples of polymorphism:
1. Overloading sometimes is called shallow kind,resolved by the compiler
2. Overriding is a deep (or true) polymorphism , resolved at runtime...
Sorry..
I wish I had more time now to visit this site more often, it's a joy and a challenge!
[This message has been edited by Jane Rozen (edited April 07, 2000).]
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Jane,
I used to refer to Thinking in Java for any such issues. In this, in chapter 7. Ploymorphism , 3rd paragaraph, Bruce Eckel, says This ability is critical because it allows many types (derived from the same base type) to be treated as if they were one type, and a single piece of code to work on all those diff types equally. And also throughout this chapter he talks about the late-binding of methods depending upon the type of the object, gives the classic base class 'shape' , derived classes 'Circle', 'Rectangle' etc. He also mentions at page 221 3rd paragraph, that This doesn't appear as polymorphic call at all where the example given was overloaded instead of overriden and he says that this is not what we wanted.
regds
maha anna
Jane Rozen
Ranch Hand

Joined: Feb 12, 2000
Posts: 53
Maha,sure neither of us makes up this stuff! I referred to "Just Java" and "Core Java" - in both there are references to "true" as opposed to "limited" polymorphism. As long as we all know what we are talking about...
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Let me check this dusty old tome I have on my desk here...
<blockquote>Remember the method overriding, and keep it holy. For that is the one true polymorphism, and thou shalt hold no other polymorphism before it.</blockquote>
I can't make out the author - it appears to have been assembled from postings by a number of different authors, and often appears to give conflicting info. But a lot of people seem to take it seriously for some reason.

Seriously, I personally would have answered D only, but I guess a case can be made for C, depending on how exactly one defines "polymorphism". Perhaps this question would work better as "choose the 1 best answer" - we all agree that's D right?

[This message has been edited by Jim Yingst (edited April 08, 2000).]


"I'm not back." - Bill Harding, Twister
sreelakshmi sarma
Ranch Hand

Joined: Mar 02, 2000
Posts: 130
Jim you vote for c or d? You said if you had to choose one best answer you will pick c(overloading).So, you think overloading is the best example for polymorphism.
Thanks.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Sorry Sree- that was a typo when I said C, which now is fixed. So now people will look at your post and wonder what you're talking about. But for the record - there was originally a good reason why he posted that question.
 
GeeCON Prague 2014
 
subject: Polymorphism