Question: class Car private String model; private double price; i ii - - //default constructor //constructor with 2 parameters iii- //set method for model iv

class Car private String model; private double price; i ii - - //default constructor //constructor with 2 parameters iii- //set method for model iv- //set method for price v //method print() public class CarTest public

class Car private String model; private double price; i ii - - //default constructor //constructor with 2 parameters iii- //set method for model iv - //set method for price v //method print() public class CarTest public static void main (String[] args) { String model; double price; Car cari new Car(); Car car2 = new Car ("Mercedes", 124000.50); carl.setModel("Mitsubishi"); car2.setPrice (100000.50); carl.print(); //output //Car model: Mitsubishi //Car price: RM100000.50 a. Given the Java program in the previous page, answer the following questions to complete the Car class definition. i) default constructor [2 marks] ii) constructor with 2 parameter AND SHADOWING [4 marks] iii) set method for model [2 marks] iv) set method for price [2 marks] v) method print() [3 marks] b. Draw the class diagram for class Car. [5 marks]

Step by Step Solution

3.47 Rating (147 Votes )

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 Programming Questions!