Question: Java code : Answer the following questions with class definition (object) defined below: class Car { private String vehicle_id; // vehicle identification number private int
Java code : Answer the following questions with class definition (object) defined below:
class Car {
private String vehicle_id; // vehicle identification number
private int speed; // driving speed
Car( ) { };
Car(String id) { };
Car(String id, int spd) { };
public void setVehicleId (String id) { // set the vehicle identification number };
public void setSpeed (int spd) { // set speed};
public String getVehicleId( ) { // returns vehicle identification number };
public int getSpeed( ) { // returns speed };
}
- [2] What is the name of the class?
- [2] Name all methods except for the constructors.
- [2] How many data declarations (class instance variables) are there?
- [2] getSpeed ( ) method returns what data type?
- [2] Construct an object data type named honda with a vehicle identification number of {yourLastName_firstName}
- [2] Write statement(s) that will set the car speed to 55 for the honda.
- [2] Write statement(s) that will display the cars (honda) speed.
- [2] Write statement(s) that will display the cars (honda) vehicle identification number.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
