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();
}
}
Step-by-step explanation:
Variables are declared.
No-arg constructor is created with default values.
A constructor with parameters is created.
The required set methods and get methods are created.
toString method is created to return car's specifications.