Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

chapter 2 Object orienation polymorphism

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic