The rest of the quiz questions are related to the following partially finished c
ID: 3591824 • Letter: T
Question
The rest of the quiz questions are related to the following partially finished code:
How many attributes does this class have?
0
1
2
3
QUESTION 2
Which of the following is a correct declaration of the two-argument constructor? Note: only the declaration part, not including the implementation.
public Car(String model,
public Constructor(String model,
void
public Car Car(String model, int year)
QUESTION 3
Which of the following is a correct implementation of the two-argument contructor?
QUESTION 4
Which of the following is a correct declaration and implementation of the getter method for year attribute?
QUESTION 5
Which of the following is a correct declaration and implementation for the setter method of model attribute?
QUESTION 6
Which of the following correctly creates a Car instance and assigns it to a variable declared with an appropriate data type?
String car= new Car();
Car car= new Car("A6", 2012);
Car car= new Car();
Car car= new Car("A6", "2012");
QUESTION 7
Assuming the car variable has been declared and properly initialized by the correct statement in the previous question. Which of the following correctly retrieves and outputs information of the car?
a. System.out.println(car.getModel());
b. System.out.println(Car.getModel());
c. System.out.println(car.getModel);
d. System.out.println(car.model);
QUESTION 8
Which of the following correct declares and creates an array to store Car instances?
a. Car[] cars = new Car[10];
b. String[] cars = new Car[10];
c. Car[] cars = new String[10];
d. Car[] cars = new Car("A6", 2010);
QUESTION 9
Which of the following correctly describes the model attribute in a UML class diagram?
a. String model
b. -String: model
c. +String:model
d. -model:String
QUESTION 10
Which of the following correctly describes the setter method for model attribute in a UML class diagram?
a. +setModel(model:String):void
b. +setModel():void
c. setModel
d. +String:setModel(String:model
a.0
b.1
c.2
d.3
Explanation / Answer
Question 1) c.2
Explanation:- It has two attributes 'model' and 'year'
Question 2) a.public Car(String model,int year)
Question 3) c. this.model = model;
this.year = year;
Question 4) c. public int getYear() {
return year;
}
Question 5) b. public void setModel(String model) {
this.model=model;
}
Question 6) b. Car car= new Car("A6", 2012);
Question 7) a. System.out.println(car.getModel());
Question 8) a. Car[] cars = new Car[10];
Question 9) b. -String:model
Question 10) a. +setModel(model:String):void
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.