package com.study.javastudy.study;

public class Car1 {
    public void run() {
        System.out.println("달리다.");
    }
}

package com.study.javastudy.study;

public class Bus extends Car1{
    public void ppangppang() {
        System.out.println("빵빵");
    }
}

package com.study.javastudy.study;

public class BusExam{
    public static void main(String[] args) {
        Bus bus = new Bus();
        bus.run(); // 달리다
        bus.ppangppang(); // 빵빵

        Car1 car = new Car1();
        car.run();

//        car.ppangppang(); // 부모클래스는 자식이 가지고 있는 것을 사용 할 수 없다
    }
}

'자바 기초' 카테고리의 다른 글

추상 클래스  (0) 2024.01.27
접근제한자  (0) 2024.01.27
생성자 오버로딩과 this  (0) 2024.01.27
메소드 오버로딩  (0) 2024.01.27
생성자  (0) 2024.01.27

+ Recent posts