Notice
Recent Posts
Recent Comments
Link
«   2025/03   »
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
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter04 : constructor 본문

JAVA/chapter13_inheritance_annotation

chapter04 : constructor

GAWON 2023. 5. 26. 18:36
package org.joonzis.ex;
/*
 * 자식 클래스의 생성자는 부모 클래스의 생성자를 먼저 호출한다.
 * (자식을 만들려면 부모 먼저 만들어야 한다.)
 */
class Mother{
	public Mother() {
		System.out.println("Mother 객체 생성");
	}
}
class Son extends Mother{
	public Son() {
		System.out.println("Son 객체 생성");
	}
	void doSon() {
		System.out.println("doSon() 호출");
	}
}
public class Ex04_Constructor {
	public static void main(String[] args) {
		Son son = new Son();
		son.doSon();
	}
}

'JAVA > chapter13_inheritance_annotation' 카테고리의 다른 글

Test . inheritance  (0) 2023.05.26
chapter05 : constructor  (0) 2023.05.26
chapter03 : inheritance  (0) 2023.05.26
chapter02 : inheritance  (0) 2023.05.26
chapter01 : inheritance  (0) 2023.05.26