p.330 문제 5번 실행 결과
public class Parent {
public String nation;
public Parent() {
this("대한민국");
System.out.println("Parent() call");
}
public Parent(String nation) {
this.nation = nation;
System.out.println("Parent(String nation) call");
}
}
public class Child extends Parent{
private String name;
public Child() {
this("홍길동");
System.out.println("Child() call");
}
public Child(String name) {
this.name = name;
System.out.println("Child(String name) call");
}
}
public class ChildEx {
public static void main(String[] args) {
Child child = new Child();
System.out.println(child.nation + "사람");
child.nation = "미국";
System.out.println(child.nation + "사람");
}
}
한번 더 읽어보기!
반응형
'개발 > Inafolio' 카테고리의 다른 글
[React] 프로젝트 기초공사하기 - 공통 컴포넌트, 폰트, 레이아웃 css 셋팅 (0) | 2022.08.02 |
---|---|
[혼공단 8기] 4주차 미션 (0) | 2022.07.31 |
[혼공단 8기] 3주차 미션 (0) | 2022.07.24 |
[혼공단 8기] 1주차 미션 (0) | 2022.07.08 |
백준알고리즘 2557번: Hello World (0) | 2022.07.04 |