• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Doubt from Khalid Mughal

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
reply
    Bookmark Topic Watch Topic
  • New Topic