This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Guess The result Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Guess The result" Watch "Guess The result" New topic
Author

Guess The result

dilan alex
Greenhorn

Joined: Sep 17, 2011
Posts: 27
Hi All,



Regards,
Dil.
Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

So what should we guess? Outputs?
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
HowToAskQuestionsOnJavaRanch
dilan alex
Greenhorn

Joined: Sep 17, 2011
Posts: 27
Hi All,

Actually I just wanted to ask about this code snippet.



Here Prius Class extends Toyota class and as we know static methods are not overridden. But in main method I have created Prius object and calling breaking method -
Its called Toyota class breaking method. how does this happen ??
Static methods are not overridden ? is it?

this is the output i get

Vehecle Created....
Toyota Created....
Prius Created....
Toyota Breaking....

Any help??

Thanks,
Dil.

Peter Heide
Ranch Hand

Joined: Nov 04, 2006
Posts: 31
Add this to the main method:



The output ist:

Vehecle Breaking....


The reference is of type Vehicle and the object is of type Prius. It takes the Vehicle.breaking() and not the Toyota.breaking() because both methods are static methods and they are not overridden.


SCJA
 
wood burning stoves
 
subject: Guess The result