Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The World Wide Web And Databases International Workshop Webdb 98 Valencia Spain March 27 28 1998 Selected Papers Lncs 1590

Authors: Paolo Atzeni ,Alberto Mendelzon ,Giansalvatore Mecca

1st Edition

3540658904, 978-3540658900

More Books

Students also viewed these Databases questions

Question

6. Describe why communication is vital to everyone

Answered: 1 week ago