package com.study.javastudy.study;
public class Car4 {
public void run() {
System.out.println("Car4의 run 메소드");
}
}
package com.study.javastudy.study;
public class Bus3 extends Car4{
public void ppangppang() {
System.out.println("빵빵");
}
}
package com.study.javastudy.study;
public class BusExam3 {
public static void main(String[] args) {
Car4 c = new Bus3();
c.run();
Bus3 bus = (Bus3)c; // Bus3 타입으로 형변환을 시켜야 한다, 생성할 때 new Bus3()으로 생성해서 사용 가능
bus.run();
bus.ppangppang();
}
}
'자바 기초' 카테고리의 다른 글
인터페이스의 default method (0) | 2024.01.29 |
---|---|
인터페이스 (0) | 2024.01.27 |
오버라이딩 (0) | 2024.01.27 |
super, 부모 생성자 (0) | 2024.01.27 |
추상 클래스 (0) | 2024.01.27 |