문서의 이전 판입니다!
Phone.java
package chapter08;
public class Phone {
String name;
String color;
String company;
void call() {
System.out.println("전화를 건다");
}
void receive() {
System.out.println("전화를 받다");
}
}
package chapter08;
public class SmartPhone extends Phone {
public void installApp() {
System.out.println("앱 설치");
}
}
package chapter08;
public class SmartPhoneMain {
public static void main(String[] args) {
Phone p = new Phone();
p.name = "전화기";
p.company = "현대";
p.color = "화이트";
System.out.println("Phone 출력");
System.out.println(p.name);
System.out.println(p.company);
System.out.println(p.color);
p.call();
p.receive();
SmartPhone sp = new SmartPhone();
sp.name = "갤럭시";
sp.company = "삼성";
sp.color = "블랙";
System.out.println("SmartPhone 출력");
System.out.println(sp.name);
System.out.println(sp.company);
System.out.println(sp.color);
sp.call();
sp.receive();
sp.installApp();
}
}
별도로 명시하지 않을 경우, 이 위키의 내용은 다음 라이선스에 따라 사용할 수 있습니다: CC Attribution-Share Alike 4.0 International