What will be printed when SportsCar is run? Answer :8 Acelerate : SportsCar I feel it should print :- 9 Acelerate : SportsCar, since in the main you are saying "new SportsCar()" Please explain? Sonir
What will be printed when SportsCar is run? Answer :8 Acelerate : SportsCar I feel it should print :- 9 Acelerate : SportsCar, since in the main you are saying "new SportsCar()" Please explain? Sonir
The varibles are called by reference type and not by object type. Here the refrence is of type Car so Car.gearRatio will be printed
When accessing fields, the compile-time type counts (here c.gearRatio will be the gearRatio of class Car), while when accessing methods the run-time type is taken into account (you got that one ) HIH
My Linked In
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad: