package com.over2;//메소드 오버라이딩 super참조 변수

class A{
	public void make(){
		System.out.println("부모 클래스");
	}
}

class B extends A{
	public B(){
		//super : 슈퍼클래스 (부모 클래스)를 가리키는
		//레퍼런스 변수
		super.make();
	}
	public void make(){//메소드 오버라이딩
		System.out.println("자식 클래스");
	}
}

public class Exten02 {
	public static void main (String[] args){
		B bp = new B();
		bp.make();
		//부모 값과 자식값 둘다 가져오게 된다 
	}
}

부모 클래스

자식 클래스


'Java > Overriding' 카테고리의 다른 글

예비  (0) 2012.04.11
super 연습문제 (에러 찾기)  (0) 2012.04.11
super로 은닉된 슈퍼클래스의 멤버변수 접근하기  (0) 2012.04.11
Super 기본 정수  (0) 2012.04.11
메소드 오버라이딩  (0) 2012.04.11

+ Recent posts