Question: The following code represents a Bicycle object with the gear, speed properties, and different constructors to create a Bicycle object public class Bicycle { protected

The following code represents a Bicycle object with the gear, speed properties, and different constructors to create a Bicycle object
public class Bicycle {
protected int gear;
protected int speed;
//Copy (Clone) Constructor
public Bicycle (Bicycle ob){
gear = ob.gear;
speed = ob. speed;
}
//Constructor used when all the attributes are specified
public Bicycle (int gear, int speed){
this.speed = speed;
this.gear = gear;
}
//Constructor used when no attributes are specified (Default)
public Bicycle (){
gear=0;
speed=0;
}
}
Create a class called MountainBike that inherits from Bicycle class and has a seatHeight of type double property. Create Constructors for this class similar to the ones for the Bicycle class taking into consideration the seatHieght property:
A Copy (clone) constructor
A Constructor when speed, gear, and the seatHeight are specified
A Default Constructor that sets the seatHeight to 10 and other attributes to their default values.
A Constructor for creating a MountainBike with a given seatHeight. Other attributes to their default values.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!