aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes About overridden methods. 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 "About overridden methods." Watch "About overridden methods." New topic
Author

About overridden methods.

Narendra shah
Ranch Hand

Joined: Feb 28, 2007
Posts: 51
In chapter 2 of K & B book, 2 mins drill down following statement is written. Can any body explain with an example?

Object type (not the reference variable's type), determines which overridden
method is used at runtime.


Narendra Shah -- SCJP 5
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I think it refers to such a case:

Object type(here, Dog) (not the reference variable's type, here Animal), determines which overridden method is used at runtime. Dog's eat method will be called.


[My Blog]
All roads lead to JavaRanch
Anoobkumar Padmanabhan
Ranch Hand

Joined: Aug 08, 2007
Posts: 103
Hi Narendra shah,

Object type (not the reference variable's type), determines which overridden
method is used at runtime.

it is actually the definition for overriding. right? The method, which will be called is determined by the type of object at runtime, not by the refence used.


Thanks<br /> <br />Anoobkumar<br />SCJP 1.5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About overridden methods.