-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_02_Example2.java
More file actions
34 lines (30 loc) · 826 Bytes
/
_02_Example2.java
File metadata and controls
34 lines (30 loc) · 826 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
32
33
34
package chap_07;
// 1) 조상 클래스
class Phone2 {
String name;
String type;
int capacity;
int price;
}
// 2) 자손 클래스
class UpgradedPhone3 extends Phone2 {
void useStandBy() {}
void useNameDrop() {}
UpgradedPhone3() {}
UpgradedPhone3(String name, String type, int capacity, int price) {
this.name = name;
this.type = type;
this.capacity = capacity;
this.price = price;
}
}
public class _02_Example2 {
public static void main(String[] args) {
// 3) 자손 클래스의 객체 생성
UpgradedPhone3 u = new UpgradedPhone3("jPhone", "Pro", 128, 1000000);
System.out.println("u: " + u.name + " / " + u.type + " / " + u.capacity + " / " + u.price);
/*
p: jPhone / Pro / 128 / 1000000
*/
}
}