반응형
조상 type 참조 변수로 자손 type 객체를 다루는 것
또는 여러 가지 형태를 가질 수 있는 능력
class TvBotton {
boolean power;
int channel;
void power() { power = !power; }
void channelUp() { ++channel; }
void channelDow() { --channel; }
}
class SmartTv extends TvBotton {
String text; // caption
void caption() { }
}
이러한 코드가 있을 때
조상 type으로 자손 instance(new)를 생성가능

자손 type으로 조상 instance 생성 불가

반응형
'☕ JAVA > ☕ Class & Method' 카테고리의 다른 글
| [JAVA]instanceof 연산자:형변환 전 확인용도 (0) | 2024.04.06 |
|---|---|
| [JAVA]참조변수의 형변환 (0) | 2024.04.04 |
| [JAVA]접근 제어자/제한자 access modifier (1) | 2024.04.02 |
| [JAVA]예약어 static, final, abstract (0) | 2024.03.31 |
| [JAVA]import와 import static (0) | 2024.03.31 |