forked from bejeyon/KOSA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChap10_ExerciseQ10.java
More file actions
60 lines (51 loc) · 975 Bytes
/
Chap10_ExerciseQ10.java
File metadata and controls
60 lines (51 loc) · 975 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
HWJava16_08_Chap10_Exercise_배재연.zip
10장 연습문제
Q10. 클래스 A와 B의 구조는 다음과 같다.
class A {
A() {
System.out.println("A 생성자1");
}
A(int a) {
this();
System.out.println("A 생성자2");
}
}
class B extends A {
B() {
System.out.println("B 생성자1");
}
B(int a) {
super(a);
System.out.println("B 생성자2");
}
}
다음 코드의 실행 결과를 쓰시오.
public static void main(String[] args) {
B bb = new B(5); // "A 생성자1"\n"A 생성자2"\n"B 생성자2" 출력
}
*/
package classes;
class A {
A() {
System.out.println("A 생성자1");
}
A(int a) {
this();
System.out.println("A 생성자2");
}
}
class B extends A {
B() {
System.out.println("B 생성자1");
}
B(int a) {
super(a);
System.out.println("B 생성자2");
}
}
class Chap10_ExerciseQ10 {
public static void main(String[] args) {
B bb = new B(5); // "A 생성자1"\n"A 생성자2"\n"B 생성자2" 출력
}
}