Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

JAVA
-
Type the program's output:
public class CallCar {
public static void main(String[] args){
Car myCar = new Car();
ElectricCar electricCar = new ElectricCar();
myCar.setBrand("Chevrolet");
myCar.setModel("Malibu");
electricCar.setBrand("Renault");
electricCar.setModel("Zoe");
electricCar.setRange("185 miles");
System.out.println(electricCar);
System.out.println(myCar);
}
}
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;
}
}
public class ElectricCar extends Car {
protected String range;
void setRange(String newRange){
range = newRange;
}
@Override
public String toString(){
return super.toString()+"("+ range +")";
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago

Question

Customers have to repeat information they have already provided.

Answered: 1 week ago