dhiru kumar wrote:Hi Nitesh ,
yes it is a correct Polymorphism , but I don't think its serving the purpose of it.
Because anyways at runtime it will call the methods of GameShape only.
TestPiece and GamePiece doesn't override the method " displayingShape() ", they inherit it from the super class.
I can be wrong .
Lets wait for others to post.
--Dhiru
ket bhav wrote:Hi there,
just try
and try again to run.
And continue thread with your opinion.
Thanks.
Dennis Deems wrote:Polymorphism means that a subclass can override a method defined in the superclass and specify its own behavior.
Dennis Deems wrote:...
OCPJP6-05-11
"Your life is in your hands, to make of it what you choose."
Tommy Delson wrote:
Eli Wood wrote:Tommy, if no overriding function is provided for a parent class's public instance methods then the subclass will simply inherit them, so the following two comments are incorrect. You can see the output I have appended to my earlier post to see those methods will execute.
Tommy Delson wrote:
OCPJP6-05-11
"Your life is in your hands, to make of it what you choose."
Tommy Delson wrote:
Eli Wood wrote:Tommy, if no overriding function is provided for a parent class's public instance methods then the subclass will simply inherit them, so the following two comments are incorrect. You can see the output I have appended to my earlier post to see those methods will execute.
Tommy Delson wrote:
When testing with the package name it won't works, but without package name it works. I didn't make it clearly or changed on the comments based on two tests.
Eli Wood wrote:,,,,,,,,,,,,,,,
Nitesh Nandwana wrote:
and i am looking for more alternative ways of these declarations so i can easily understand this.
Nitesh Nandwana wrote:
Dennis Deems wrote:...
Dennis don't worry after learning it i will post here in detail so everyone can learn it because noone have dare to explain it.
Nitesh Nandwana wrote:
Nitesh Nandwana wrote:
Dennis Deems wrote:...
Dennis don't worry after learning it i will post here in detail so everyone can learn it because noone have dare to explain it.
As i promised to Dennis and all ranches, i am gonna demo everone real polymorphism affect.
OCPJP6-05-11
"Your life is in your hands, to make of it what you choose."
Tommy Delson wrote:
1. Declare displayingShape() method in GameShape class as static, see what effect will happen, and find out why?
Tommy Delson wrote:
2. Declare an Exception on the original displayingShape() in GameShape class after you have tried 1, see what effect will happen and find out why?
Dennis Deems wrote: You were repeatedly told that only overriding a method would achieve polymorphism. I guess you had to work it out for yourself.
Switch to decaf, ok champ?![]()
Nitesh Nandwana wrote:
Tommy Delson wrote:
1. Declare displayingShape() method in GameShape class as static, see what effect will happen, and find out why?
You must have know that static method cant be overridden so your this point is useless.
Tommy Delson wrote:
2. Declare an Exception on the original displayingShape() in GameShape class after you have tried 1, see what effect will happen and find out why?
If exception is declared on original method then it wont affect on overriding method but if you try to declare exception for overriding although if that is not declare for original then it'll be your mistake.
![]()
OCPJP6-05-11
"Your life is in your hands, to make of it what you choose."
Dennis Deems wrote:
Nitesh Nandwana wrote:
Nitesh Nandwana wrote:
Dennis Deems wrote:...
Dennis don't worry after learning it i will post here in detail so everyone can learn it because noone have dare to explain it.
As i promised to Dennis and all ranches, i am gonna demo everone real polymorphism affect.
Uh ... thanks? You were repeatedly told that only overriding a method would achieve polymorphism. I guess you had to work it out for yourself.
Switch to decaf, ok champ?![]()
OCPJP6-05-11
"Your life is in your hands, to make of it what you choose."
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |