This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes chapter 2 Object orienation  polymorphism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "chapter 2 Object orienation  polymorphism" Watch "chapter 2 Object orienation  polymorphism" New topic

chapter 2 Object orienation polymorphism

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

by Katherine Sierra (Author), Bert Bates (Author)

chapter 2bject orienation

even though the compiler
only knows about the declared reference type, the Java Virtual Machine (JVM)
at runtime knows what the object really is. And that means that even if the
PlayerPiece object's displayShape() method is called using a GameShape
reference variable, if the PlayerPiece overrides the displayShape() method, the
JVM will invoke the PlayerPiece version! The JVM looks at the real object at the
other end of the reference, "sees" that it has overridden the method of the declared
reference variable type, and invokes the method of the object's actual class

can anyone illustrate with an example

OCPJP 6.0 93%
OCPJWCD 5.0 98%
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446

well you will get all this in the next part of the book in the Overriding and overloading section
this is the example I have tried in the book hope this helps

Happy preparation

SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
It is sorta covered in the JavaRanch Style Guide.
subject: chapter 2 Object orienation polymorphism
jQuery in Action, 3rd edition