-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_06_Example.java
More file actions
31 lines (27 loc) · 863 Bytes
/
_06_Example.java
File metadata and controls
31 lines (27 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package chap_07;
// 1) Object 클래스를 상속받는 경우
class Phone3 { // class Phone3 extends Object
String name;
String type;
int capacity;
int price;
}
class UpgradedPhone4 extends Phone3 {
void useStandBy() {}
void useNameDrop() {}
UpgradedPhone4() {}
UpgradedPhone4(String name, String type, int capacity, int price) {
this.name = name;
this.type = type;
this.capacity = capacity;
this.price = price;
}
}
public class _06_Example {
public static void main(String[] args) {
UpgradedPhone4 u = new UpgradedPhone4("jPhone", "Pro", 128, 1000000);
// 2) Object 클래스에 정의된 메서드 호출하는 경우
System.out.println(u.toString()); // chap_07.UpgradedPhone4@75b84c92
System.out.println(u); // chap_07.UpgradedPhone4@75b84c92
}
}