Java Program 6 – Abstract Class

Program

abstract class Vehicle{
    
    int modifier;
    
    public void accelaration(){
        System.out.println("In vehicle accelaration…");
    }

}

class Car extends Vehicle{

    public void breaking(){
    
        System.out.println("In car breaking…");
    
    }

}

class TestAbstract{

    public static void main(String args[]){
    
        //Vehicle v=new Vehicle();
        Vehicle v=new Car();
        v.accelaration();
        
        Car c=new Car();
        c.breaking();
    }

}


Output

D:\a5518\day2>javac abstract.java

D:\a5518\day2>java TestAbstract
In vehicle accelaration…
In car breaking…

D:\a5518\day2>


 

You can leave a response, or trackback from your own site.

Leave a Reply