Problem

Consider the following class definitions. Identify invalid statements. class Car {...

Consider the following class definitions. Identify invalid statements.

class Car {

public String make;

protected int weight;

private String color;

...

}

class ElectricCar extends Car {

private int rechargeHour;

public ElectricCar() {

...

}

//copy constructor

public ElectricCar (ElectricCar car) {

this.make = car.make;

this.weight = car.weight;

this.color = new String(car.color);

this.rechargeHour= car.rechargeHour;

}

...

}

class TestMain {

public static void main (String[] args) {

Car myCar;

ElectricCar myElecCar;

myCar = new Car();

myCar.make = "Chevy";

myCar.weight = 1000;

myCar.color = "Red";

myElecCar = new ElectricCar();

myCar.make = "Chevy";

myCar.weight = 500;

myCar.color = "Silver";

}

}

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 13