Public classTestMain {     public static void main(String [ ] args)     {          Car myCar1, myCar2;          Electric Car myElec1, myElec2;          myCar1 = new Car( );          myCar2 = new Car("Ford", 1200, "Green");          myElec1 = new ElectricCar( );          myElec2 = new ElectricCar(15);          } }

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 13RQ
icon
Related questions
Question

Public classTestMain

{

    public static void main(String [ ] args)

    {

         Car myCar1, myCar2;

         Electric Car myElec1, myElec2;

         myCar1 = new Car( );

         myCar2 = new Car("Ford", 1200, "Green");

         myElec1 = new ElectricCar( );

         myElec2 = new ElectricCar(15);

         }

}

 

 

3. Consider the following class definitions:
public class Car
}
public String make;
protected int weight;
private String color;
private Car(String make, int weight, String color)
}
this.make
make;
weight3;
color;
this.weight
%3D
this.color
%3D
{
public Car( )
}
this("unknown", -1, "white");
public class ElectricCar extends Car
}
private int rechargeHour;
public ElectricCar()
}
this(10);B
private ElectricCar(int charge)
}
super();
rechargeHour = charge;
%3D
{
Transcribed Image Text:3. Consider the following class definitions: public class Car } public String make; protected int weight; private String color; private Car(String make, int weight, String color) } this.make make; weight3; color; this.weight %3D this.color %3D { public Car( ) } this("unknown", -1, "white"); public class ElectricCar extends Car } private int rechargeHour; public ElectricCar() } this(10);B private ElectricCar(int charge) } super(); rechargeHour = charge; %3D {
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning