WON.dev
chapter02 : inheritance 본문
package org.joonzis.ex;
class Person{
void sleep() {
System.out.println("잔다");
}
void eat(String food) {
System.out.println(food + "먹는다");
}
}
class Student extends Person{
void study() {
System.out.println("공부한다.");
}
}
class Worker extends Person{
void work() {
System.out.println("일한다.");
}
}
public class Ex02_Inheritance {
public static void main(String[] args) {
Student stu = new Student();
stu.eat("밥");
stu.study();
stu.sleep();
}
}
'JAVA > chapter13_inheritance_annotation' 카테고리의 다른 글
Test . inheritance (0) | 2023.05.26 |
---|---|
chapter05 : constructor (0) | 2023.05.26 |
chapter04 : constructor (0) | 2023.05.26 |
chapter03 : inheritance (0) | 2023.05.26 |
chapter01 : inheritance (0) | 2023.05.26 |