Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The Bike and EBike classes are implemented as shown by the code below. public class Bike { private String make; private int numGears; private double
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();
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started