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 };

}

  1. [2] What is the name of the class?

  1. [2] Name all methods except for the constructors.

  1. [2] How many data declarations (class instance variables) are there?

  1. [2] getSpeed ( ) method returns what data type?

  1. [2] Construct an object data type named honda with a vehicle identification number of {yourLastName_firstName}

  1. [2] Write statement(s) that will set the car speed to 55 for the honda.

  1. [2] Write statement(s) that will display the cars (honda) speed.

  1. [2] Write statement(s) that will display the cars (honda) vehicle identification number.

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!