Author | Topic: Polymorphism |
raja pratap greenhorn |
posted April 07, 2000 12:55 AM
Which is an example of polymorphism. a. inner classes. b. anonymous classes. c. method overloading. d. method overriding.
|
rag unregistered |
posted April 07, 2000 08:34 AM
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 bartender |
posted April 07, 2000 10:37 AM
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 |
posted April 07, 2000 12:36 PM
quote: 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 bartender |
posted April 07, 2000 02:15 PM
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
|
Jane Rozen ranch hand |
posted April 07, 2000 06:07 PM
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 sheriff |
posted April 07, 2000 10:32 PM
Let me check this dusty old tome I have on my desk here... Remember the method overriding, and keep it holy. For that is the one true polymorphism, and thou shalt hold no other polymorphism before it. 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).]
|
sree ranch hand |
posted April 08, 2000 04:44 PM
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 sheriff |
posted April 08, 2000 07:44 PM
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.
|
| | |