[OOP]

Untitled

[상속]

“상속”

기존(상위) 클래스의 자산(멤버)을 자식(하위) 클래스에서 재사용하기 위한 것

package com.ssafy.day3.a_inheritance;

public class Person {

	String name;
	
	void eat() {
		System.out.println("냠냠");
	}
	
	void jump() {
		System.out.println("폴짝");
	}
}

public class SpiderMan extends Person{

	boolean isSpider;
	
	void fireWeb() {
		System.out.println("어떻게??");
	}
}

“Object Class”

Untitled

“다양한 상속 관계 (is a)”