Archive for May 6th, 2013

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();
    }

}

Read more »

Java Program 5 – Interface

Program

interface Employee{

    public void applyLeave();
    public void getSalary();
    
}

interface EmployeeManager{

    public void approveLeave();
    
}

class Manager implements Employee{

    public void applyLeave(){
        
        System.out.println("Apply Leave…");
    }
    
    public void getSalary(){
        
        System.out.println("Get Salary…");
    }
}

class testInterface{

    public static void main(String args[]){
    
        Manager e=new Manager();
        e.applyLeave();
        e.getSalary();
    }
}

 

Read more »

Last updated by at .