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
posted
0
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.