Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Guess The result

 
dilan alex
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,



Regards,
Dil.
 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what should we guess? Outputs?
 
John Jai
Rancher
Posts: 1776
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HowToAskQuestionsOnJavaRanch
 
dilan alex
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic