JAVA/예제

[JAVA] ch07-11. 객체 지향 11

밍글링글링 2017. 8. 22.
728x90
 
public class Ex11 {
    public static void main(String[] args){
        FireCar firecar = new FireCar();
        firecar.drive();
        firecar.stop();
        firecar.water();
        
        Car car = firecar;
        car.drive();
        car.stop();
        //car.water();
    }
}

class Car{
    String color;
    int door;
    
    void drive(){
        System.out.println("dreive.");
    }
    void stop(){
        System.out.println("stop.");
    }
}

class FireCar extends Car{
    void water(){
        System.out.println("water.");
    }
}

728x90

'JAVA > 예제' 카테고리의 다른 글

[JAVA] ch07-14. 객체 지향 14  (0) 2017.08.22
[JAVA] ch07-13. 객체 지향 13  (0) 2017.08.22
[JAVA] ch07-10. 싱글톤 기법 (singleton)  (0) 2017.08.22
[JAVA] ch07-09. 객체 지향 9  (0) 2017.08.22
[JAVA] ch07-08. 객체 지향 8  (0) 2017.08.22

댓글