Question: JAVA - Type the program's output: public class CallCar { public static void main ( String [ ] args ) { Car car 1 =

JAVA
-
Type the program's output:
public class CallCar {
public static void main(String[] args){
Car car1= new Car();
Car car2= new Car();
car1.setBrand("Chevrolet");
car1.setModel("Cruze");
car2.setBrand("Ford");
car2.setModel("Explorer");
System.out.println(car2);
System.out.println(car1);
}
}
public class Car {
protected String brand;
protected String model;
void setBrand(String carBrand){
brand = carBrand;
}
void setModel(String carModel){
model = carModel;
}
@Override
public String toString(){
return brand +": "+ model;
}
}

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!