캬캬백곰
2012. 5. 8. 15:32
728x90
public class Child extends Parent {
public Child(){
System.out.println("Child의 생성자를 호출");
}
@Override //컴파일러에게 알려주는 역할
public void work() {
//super.work(); //부모의 work메소드를 호출
System.out.println("쉬면서 일해요");
}
public void buy(){
this.account--;
System.out.println("구매완료..잔액은? "+this.account);
}
실행
public static void main(String[] args) {
Child c = new Child();
c.work();
c.buy();
c.buy();
}
결과
728x90
반응형