![]() |
Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
Here's the advantage of upcasting: now, to create a flute you would extend MusicalInstrument, and perhaps would give it some more attributes, but in order to tune this flute you wouldn't have to write a new method tuneFlute(), but would rather say: Flute f = MusicalInstrument.tune(new flute); this would create a new object flute and when tuning it it will upcast it to the object MusicalInstrument. Hope this helps.
> ABOUT ME IS THAT: > I am student of MCS(Masters in Computer Sciences) in AL-Khair University of Pakistan.I have completed half of MCS and now i am studing JAVA. > Only one concept of "UP CASTING" is teasing me too much and now i am fed up with that as all other concepts for example inheritance,interface is relating to "UP CASTING". > My main Problem is that I have understood how "up casting" is done but i could not understood what is the "ADVANTAGE" or purpose of "up casting". > I would be thankful to you to the crazy extent if You reply me as soon as possible.
Replies: |
Sponsored Links
|