Archive for May 5th, 2013

Java Program 4 – Inheritance

Program

class Car{

    public Car(){
        System.out.println("Inside car..Constructor");
    }

    public Car(String color){
        System.out.println("Inside car.." + color);
    }
    
    public void acceleration(){
        System.out.println("Car Acceleration");
    }

}

class Benz extends Car{

    public Benz(){
        super("Green");
        System.out.println("Inside Benz..Constructor");
    }
    public void breaking(){
        System.out.println("Inside Benz breaking..");
    }

}

Read more »

Last updated by at .