Consider the following class definitions.
public class Vehicle
{
private int numOfWheels;
public Vehicle(int nNumOfWheels)
{
numOfWheels = nNumOfWheels;
}
public String toString()
{
return "Number of Wheels: " + numOfWheels;
}
}
public class Motorized extends Vehicle
{
private int maxSpeed;
public Motorized(int nNumOfWheels, nMaxSpeed)
{
super(nNumOfWheels);
maxSpeed = nMaxSpeed;
}
public String toString()
{
String s = super.toString() + " Max Speed: ";
if (maxSpeed <= 10)
{
s += "Slow";
}
else if (maxSpeed > 10 && maxSpeed <= 100)
{
s += "Fast";
}
else
{
s += "Super Speedy";
}
return s;
}
}
Which of the following code segments, when executed in a class other than Vehicle or Motorized, will display Number of Wheels: 4 Max Speed: Fast ?
A. Vehicle obj = new Vehicle(55);
System.out.println(obj);
B. Vehicle obj = new Vehicle(55);
System.out.println(toString(obj));
C. Motorized obj = new Motorized(55);
System.out.println(obj);
D. Vehicle obj = new Motorized(4, 55);
System.out.println(obj);
E. Motorized obj = new Motorized(4, 55);
System.out.println(toString(obj));