I got the following code on 4test web site. Which print out is right?
**************
Given the following classes defined in separate files:
class Vehicle {
public void drive() {
System.out.println("Vehicle: drive");
}
}
class Car extends Vehicle {
public void drive() {
System.out.println("Car: drive");
}
}
public class
Test {
public static void main (
String args []) {
Vehicle v;
Car c;
v = new Vehicle();
c = new Car();
v.drive();
c.drive();
v = c;
v.drive();
}
}
Prints out:
Vehicle : drive
Car : drive
Car : drive
or
Prints out:
Vehicle : drive
Car : drive
Vehicle : drive
*******************************
Thanks!
