File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Guess The result" Watch "Guess The result" New topic

Guess The result

dilan alex

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

Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

So what should we guess? Outputs?
John Jai

Joined: May 31, 2011
Posts: 1776
dilan alex

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??


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.

I agree. Here's the link:
subject: Guess The result
It's not a secret anymore!