
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 + "사람");
}
}
[Java] 객체 지향 프로그래밍 (OOP)
객체 지향프로그래밍? OOP(Object-Oriented Programming). 개발 시 부품에 해당하는 객체를 만들고 객체를 조립하여 하나의 완성된 프로그램을 만드는 기법 객체 : 물리적으로 존재하거나 추상적으로 생
h-owo-ld.tistory.com
한번 더 읽어보기!
반응형
'개발 > 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 |