This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt from Khalid Mughal" Watch "Doubt from Khalid Mughal" New topic

Doubt from Khalid Mughal

lalit upadheyay
Ranch Hand

Joined: Jun 20, 2005
Posts: 110

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:
subject: Doubt from Khalid Mughal
It's not a secret anymore!