When i run this, i get an error message saying TYpe expected and it points to the line having a.drive(100)... Any help please? Newbie...
class Car
{
public Car(){
int odometer=0;
System.out.println("Car constructed!");
}
public void drive(int miles)
{
System.out.println("Driving.....");
odometer+=miles;
}
public long odometer;
}
class Guzzler extends Car
{
public Guzzler(){
System.out.println("Guzzler Creeated!");
}
public void guzzle()
{
System.out.println("Guzzling....");
}
}
public class InheritanceExample
{
Car a=new Car();
Guzzler g=new Guzzler();
a.drive(100);
g.drive(200);
System.out.println("Car mileage : "+c.odometer);
System.out.println("Guzzler mileage : "+g.odometer);
g.guzzle();
if(g instanceof Car)
{
System.out.println("Guzzler is a car!!!");
}
}