aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt from Khalid Mughal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt from Khalid Mughal" Watch "Doubt from Khalid Mughal" New topic
Author

Doubt from Khalid Mughal

lalit upadheyay
Ranch Hand

Joined: Jun 20, 2005
Posts: 110
Hi,

In the following code :



How is the method call at line 1 in demonstarte() method of NeonLight class different than the method call at the next line ? Though both the methods are available in TubeLight and Light classes, but the first line in demonstrate() invokes method from TubeLight and next line invokes method from Light. Please help.


SCJP1.4, SCWCD1.4, SCBCD5.0(working on...)
Shivakanth Thyagarajan
Ranch Hand

Joined: Mar 28, 2005
Posts: 41
The method follows the principle of Overriding ( i,e the getBill method ), it is resolved at run time.

The second method is a static method( i,e printAll( ) ) which gets resolved at compile time therefore the output.

Important Note:
Static methods are resolved at compile time, therefore cannot be overridden .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt from Khalid Mughal
 
Similar Threads
Variable Shadowing
overriding/poly morphic question
variable shadowing
Access
Casting this