Answer:
public class Car {
private int yearModel;
private String make;
private int speed;
public Car(){
yearModel = 2000;
make = "Nissan";
speed = 4;
}
public Car(int yearModel, String make, int speed) {
this.yearModel = yearModel;
this.make = make;
this.speed =speed;
}
public void setYearModel(int yearModel){
this.yearModel = yearModel;
}
public void setMake(String make){
this.make = make;
}
public void setSpeed(int speed){
this.speed = speed;
}
public int getYearModel(){ return yearModel; }
public String getMake(){ return make; }
public int getSpeed(){ return speed; }
public String toString(){
return "Car's year model: " + getYearModel() + ", make: " + getMake() + ", speed: " + getSpeed();
}
}
Explanation:
<em>Variables</em> are declared.
<em>No-arg constructor</em> is created with default values.
<em>A constructor with parameters</em> is created.
The required <em>set methods</em> and <em>get methods</em> are created.
<em>toString</em> method is created to return car's specifications.