본문 바로가기

Programming/Java

자바 상속 개념 extends

반응형
package inheritance;

public class People {
	
	String name;
	int age;
	
	public People() {
		
	}
	
	public People(String name, int age) {
		this.name=name;
		this.age=age;
	}

}
package inheritance;

public class Student extends People {
	
	int stdNo;
	
	public Student() {
		super(); // 생략의 형태로 존재
	}

}
package inheritance;

public class Emp extends People{
	
	int empNo;
		

}
package inheritance;

public class Student extends People {
	
	int stdNo;
	
	public Student() {
		super.name=name;
		super.age=age;
		
		
	}

}
반응형