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...)
posted 11 years ago
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 .