Discover the best answers at Westonci.ca, where experts share their insights and knowledge with you. Connect with a community of experts ready to provide precise solutions to your questions quickly and accurately. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.

The Bike and EBike classes are implemented as shown by the code below.public class Bike
{
private String make;
private int numGears;
private double tirePressure;
public Bike(String m, int g, double t)
{
make = m;
numGears = g;
tirePressure = t;
}
public void pumpTire()
{
tirePressure += 5.0;
}
}
public class EBike extends Bike
{
private int batteryLevel;
public EBike(String m, int g, double t, int b)
{
super(m, g, t);
batteryLevel = b;
}
public void chargeBattery()
{
batteryLevel++;
}
}
Suppose that the following declarations are made in a separate class.
Bike bike1 = new Bike("Clasic Cycle", 16, 65.0);
Bike bike2 = new EBike("Big EZ", 8, 72.0, 96);
EBike bike3 = new Bike("E-xtreme", 12, 80.0, 44);
Assuming the above three lines compile without error, which of the following statements will cause an error when compiled?
bike3.pumpTire();
bike2.pumpTire();
bike2.chargeBattery();
bike1.pumpTire();
bike3.chargeBattery();

Sagot :

Answer:

bike3.chargeBattery();

Explanation:

The Bite class is the super or parent class of the Java program while the Ebike class is the subclass or child class inheriting from the super-class. The Bike class defined methods can be used by the object instance of the Ebike class, but the method in the Ebike class cannot be used by the parent class "Bike".