class TV {
private int size;
public TV(int size) {this.size = size;}
protected int getSize() {return size;}
}
public class ColorTV extends TV {
private int color;
public ColorTV(int size,int color) {
super(size);
this.color = color;
}
void printProperty() {
System.out.println(getSize()+"인치 "+color+"컬러");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
ColorTV myTV = new ColorTV(32,1024);
myTV.printProperty();
}
}
결과
32인치 1024컬러
'명품JAVA프로그래밍 > 5장 상속' 카테고리의 다른 글
[명품JAVA프로그래밍] 5장 실습문제 5번 (0) | 2022.01.12 |
---|---|
[명품JAVA프로그래밍] 5장 실습문제 4번 (0) | 2022.01.12 |
[명품JAVA프로그래밍] 5장 실습문제 3번 (0) | 2022.01.12 |
[명품JAVA프로그래밍] 5장 실습문제 2번 (0) | 2022.01.12 |
[명품JAVA프로그래밍] 5장 Open Challenge (0) | 2022.01.12 |