Professional Documents
Culture Documents
F Div
F Div
finally
{ System.out.println(“finally msg”);}
3
abstract class Vehicle { public int speed() { 5. class Test
return 0; } {
class Car extends Vehicle { public int speed() static int x;
{ return 60; }
public:
class RaceCar extends Car { public int speed()
Test() { x++; }
{ return 150; } ...
static int getX() {return x;}
RaceCar racer = new RaceCar();
RaceCar racerCar = new Car();
};
Vehicle vehicle = new RaceCar(); int Test::x = 0;
System.out.println(racer.speed() + ", " + int main(){
raceCar.speed() + ", " + vehicle.speed()); cout << Test::getX() << " ";
What is the result? Test t[5];
A. 0, 0, 0 cout << Test::getX();
B. 150, 60, 0 }
C. Compilation fails.
a. Compiler error
D. 150, 150, 150
E. An exception is thrown at runtime. b. 0 0 0
c. 5 5
d. 0 5