Meaningless Drivel is fun!*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "chapter 2 Object orienation  polymorphism" Watch "chapter 2 Object orienation  polymorphism" New topic
Author

chapter 2 Object orienation polymorphism

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634



SCJP1.6 JAVA 6 CERTIFICATION Guide-310-065
by Katherine Sierra (Author), Bert Bates (Author)


chapter 2bject orienation
pg-102



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
    
    1

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
 
Don't get me started about those stupid light bulbs.
 
subject: chapter 2 Object orienation polymorphism