Question: Question 16 4 poin Write a JAVA code to implement a class named Vehicle, and its subclass called Car. The details of the classes are

 Question 16 4 poin Write a JAVA code to implement a

Question 16 4 poin Write a JAVA code to implement a class named Vehicle, and its subclass called Car. The details of the classes are described in the following UML diagram Vehicle -id : int +Vehicle +Vehicle(id : int) +getID : int +setId(id : int) : void +toString(): String Car -brand : String -color: String +Car(id : int, brand : String, color : String) +toString(): String For Vehicle class: - In the constructor Vehicle(id: int), use this keyword to initialize the attribute id. - The toString() should override the toString() of the object class. It should return the id of the vehicle. For example: Vehicle (id = 1001) For Car class: - Use super keyword to invoke the superclass constructor to pass the id. - Use this keyword to initialize the attributes brand and color. Override the Loslring() method to return the id, brand and color. Use super keyword to invoke the Lostring() of the super class for the id. For example: car : Vehicle (id = 1001), brand = Toyota, color = Red

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!