[JAVA] 객체지향 프로그래밍
오버로딩 / 오버라이딩 오버로딩은 기존에 없는 새로운 메서드를 추가 오버라이딩은 조상으로부터 상속받은 메서드의 내용을 변경 super 자손 클래스에서 조상 클래스로부터 상속받은 멤버를 참조할때 사용 public class SuperTest { public static void main(String[] args) { Child c = new Child(); c.method(); } } class Parent{ int x = 10; } class Child extends Parent{ int x = 20; void method(){ System.out.println("x=" + x); // 20 System.out.println("this.x=" + this.x); // 20 System.out.printl..
2023.02.07