javascript
Brief description  about Online courses   join in Online courses
View Asif Minhas 's Profile

Inheritance

Dear Sir/Madam,

The code you have in the 'Inheritance section' doesn't seem to compile properly.

Car and RacingCar compile fine.But MyOwnCar gives this error

MyOwnCar.java:17: error: cannot find symbol
MyRacingCar.RacingCarPrintstate ( );
^
symbol: variable MyRacingCar
location: class MyOwnCar
1 error
Asked by Asif Minhas | Jun 1, 2014 |  Reply now
Replies (3)
View kumarathas nadarajah 's Profile
because in class MyOwnCar the variable declariation is missing.
therefore I will give you the code see below:
class MyOwnCar{
public static void main(String[]args){

Car mycar1=new Car();
Car mycar2=new Car();
RacingCar MyRacingCar=new RacingCar();//this is missing in the original //code

mycar1.changeSpeed(100);
mycar1.changeGear(3);
mycar1.FirstCarPrintState();


mycar2.changeSpeed(120);
mycar2.changeGear(6);
mycar2.SecondCarPrintState();

MyRacingCar.RacingCarPrintState();

}
}
Jun 15, 2015
View asif minhas 's Profile
class MyOwnCar {

public static void main(String[] args) {
Car mycar1 = new Car( ); //We are creating our first car from superset Car
Car mycar2 = new Car( ); //We are creating our second car from superset Car

//We will write method to define the speed and gear of our 1st car
mycar1.ChangeSpeed(100);
mycar1.ChangeGear(4);
mycar1. FirstCarPrintstate ( );

//We will write method to define the speed and gear of our 2nd car
mycar2.ChangeSpeed(120);
mycar2.ChangeGear(5);
mycar2.SecondCarPrintstate ( );

MyRacingCar.RacingCarPrintstate ( );
}
}.
Jun 5, 2014
View java teacher 's Profile
Send me the program which you executed so that i can check here.
Jun 2, 2014