정보처리기사 실기 · 2023년 1회 · 17번

Q.172023년1회10과목 · Java배점 5점
다음 Java 프로그램의 출력 결과를 쓰시오.
class Parent {
  int x = 100;
  Parent() {
    this(500);
  }
  Parent(int x) {
    this.x = x;
  }
  int getX() {
    return x;
  }
}

class Child extends Parent {
  int x = 4000;
  Child() {
    this(5000);
  }
  Child(int x) {
    this.x = x;
  }
}

public class Main {
  public static void main(String[] args) {
    Child obj = new Child();
    System.out.println(obj.getX());
  }
}

이 문제는 풀이 화면에서 직접 실행해 풀 수 있어요.

이 회차 문제 풀어보기 →정보처리기사 실기 더 풀기