Interface

//Interface

 

public interface InterfaceCar {

    public void carNeedTiers();
    public void carNeedsEngine();
    public void carNeedsSeats();
    public void carNeedsBody();
    public void carNeedsTrunk();

}

//Class Implementing Interface

 

public class HondaCar implements InterfaceCar {

    public void carNeedTiers(){
        System.out.println("Honda Car Needs Tiers");
    }
    public void carNeedsEngine(){
        System.out.println("Honda Car Needs Engine");
    }
    public void carNeedsSeats(){
        System.out.println("Honda Car Needs Seats");
    }
    public void carNeedsBody(){
        System.out.println("Honda Car Needs Body");
    }
    public void carNeedsTrunk(){
        System.out.println("Honda Car Needs Trunk");
    }
}

//Creating an Object

 

public class MainMethod {
    public static void main(String[] args) {
        //Creating an object using an inherited class
        InterfaceCar iCar = new HondaCar();
        iCar.carNeedsBody();
    }
}

Print Print | Sitemap
© 2016 Automation Learn. All rights reserved.