Welcome Guest | Sign in | Register
Abstract - Discussion Page For Q.2493 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Abstract > Questions and Answers

Q: abstract class Vehicle {
public int speed() { return 0; }
class Car extends Vehicle { public int speed() { return 60; }
class RaceCar extends Car { public int speed() { return 150; } ...
RaceCar racer = new RaceCar();
Car car = new RaceCar();
Vehicle vehicle = new RaceCar();
System.out.println(racer.speed() + ", " + car.speed() + ", " + vehicle.speed());
}

What is the result?
A. 0, 0, 0 B. 150, 60, 0
C. Compilation fails. D. 150, 150, 150
E. An exception is thrown at runtime.

Answer and Explanation

Answer:150, 150, 150

Explanation:
just normal flow of execution.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.