728x90 자바 객체 상속2 [JAVA] ch07-05. 객체 지향 5 public class Ex05 { public static void main(String[] args){ Descendant descendant = new Descendant(); descendant.method(); } } class Descendant extends Parent{ int x = 20; void method(){ System.out.println("x= "+x); System.out.println("this.x= "+this.x); System.out.println("super.x= "+super.x); } } JAVA/예제 2017. 8. 22. [JAVA] ch07-04. 객체 지향 4 public class Ex04 { public static void main(String[] args){ Child child = new Child(); child.method(); } } class Parent{ int x =10; } class Child extends Parent{ void method(){ System.out.println("x= "+x); System.out.println("this.x= "+this.x); System.out.println("super.x= "+super.x); } } JAVA/예제 2017. 8. 22. 이전 1 다음 728x90