-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package extends1.super2; | ||
|
||
public class ClassA { | ||
|
||
public ClassA() { | ||
System.out.println("ClassA 생성자"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package extends1.super2; | ||
|
||
public class ClassB extends ClassA { | ||
public ClassB(int a) { | ||
this(a, 0); // 매개 변수가 없는 기본 생성자는 생략 가능 | ||
System.out.println("ClassB 생성자 a = " + a); | ||
} | ||
|
||
public ClassB(int a, int b) { | ||
super(); // 생략 가 | ||
System.out.println("ClassB 생성자 a = " + a + " b = " + b); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package extends1.super2; | ||
|
||
public class ClassC extends ClassB { | ||
public ClassC() { | ||
super(10, 20); // 부모에게 기본 생성자가 있으므로 생략 불가 | ||
System.out.println("ClassC 생성자"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package extends1.super2; | ||
|
||
public class Super2Main { | ||
public static void main(String[] args) { | ||
// ClassC classC = new ClassC(); | ||
|
||
ClassB classB = new ClassB(100); | ||
} | ||
} |