Skip to Content
독학사독학사 3단계객체지향프로그래밍20. 중간 수준 모의문제: 클래스·상속·예외

재구성 출제 고지: 이 문제집은 국가평생교육진흥원 독학학위제 3단계 객체지향프로그래밍 출제기준(클래스·객체, 상속, 예외 처리 등 평가영역)의 범위와 문항 유형을 분석해 새로 구성한 재구성 문항입니다. 실제 기출 문항을 그대로 옮긴 것이 아닙니다. 회차별 정확한 문항 수·시험 시간은 시행처 공고를 확인해야 하며, 여기서는 24문항을 표준 분량으로 구성했습니다.

출제 범위와 문항 배분

영역문항 수문항 번호관련 편
클래스·객체·생성자·this·super51–504, 05
캡슐화와 접근 제어46–906
상속과 오버로딩410–1308
오버라이딩·다형성·동적 바인딩514–1809
예외 처리619–2413, 14

각 문제의 코드를 눈으로만 읽지 말고, 한 줄씩 실행되는 순서와 그 시점의 필드 값·호출되는 메서드를 직접 표로 적어 본 뒤 정답을 확인하세요. 특히 정적 바인딩과 동적 바인딩의 차이, 생성자 호출 순서, checked·unchecked 예외의 구분은 독학사 3단계에서 반복 출제되는 대표 함정입니다.

클래스·객체·생성자·this·super (1–5)

문제 1

public class Counter { int count; String label; public static void main(String[] args) { Counter c = new Counter(); System.out.println(c.count); System.out.println(c.label); } }
문제 14지선다
위 코드를 실행했을 때 출력되는 결과로 옳은 것은?

문제 2

public class Point { int x, y; public Point(int x, int y) { this.x = x; this.y = y; } public static void main(String[] args) { Point p = new Point(); System.out.println(p.x); } }
문제 24지선다
위 코드를 컴파일했을 때 결과로 옳은 것은?

문제 3

public class Box { int width; int height; public Box() { this(10, 20); } public Box(int width, int height) { this.width = width; this.height = height; } public static void main(String[] args) { Box b = new Box(); System.out.println(b.width + " " + b.height); } }
문제 34지선다
위 코드를 실행했을 때 출력되는 값으로 옳은 것은?

문제 4

class Animal { Animal() { System.out.println("Animal 생성자"); } } class Dog extends Animal { Dog() { System.out.println("Dog 생성자"); } public static void main(String[] args) { Dog d = new Dog(); } }
문제 44지선다
위 코드를 실행했을 때 출력 순서로 옳은 것은?

문제 5

class Base { int value = 10; } class Derived extends Base { int value = 20; void printValues() { System.out.println(this.value); System.out.println(super.value); } public static void main(String[] args) { new Derived().printValues(); } }
문제 54지선다
위 코드를 실행했을 때 출력되는 값으로 옳은 것은?

캡슐화와 접근 제어 (6–9)

문제 6

public class Circle { private double radius; public Circle(double radius) { this.radius = radius; } public double getRadius() { return radius; } } class Main { public static void main(String[] args) { Circle c = new Circle(5.0); System.out.println(c.radius); } }
문제 64지선다
위 코드에서 Main 클래스가 c.radius로 직접 접근하려고 할 때 발생하는 일로 옳은 것은?

문제 7

문제 74지선다
protected 접근 제어자에 대한 설명으로 가장 정확한 것은?

문제 8

public class Account { private int balance; public void setBalance(int balance) { if (balance >= 0) { this.balance = balance; } } public int getBalance() { return balance; } public static void main(String[] args) { Account acc = new Account(); acc.setBalance(-500); System.out.println(acc.getBalance()); } }
문제 84지선다
위 코드를 실행했을 때 출력되는 값으로 옳은 것은?

문제 9

문제 94지선다
접근 제어자에 대한 설명으로 옳지 않은 것은?

상속과 오버로딩 (10–13)

문제 10

public class Calc { static void show(int x) { System.out.println("int: " + x); } static void show(double x) { System.out.println("double: " + x); } public static void main(String[] args) { show(5); show(5.0); show('A'); } }
문제 104지선다
위 코드를 실행했을 때 출력되는 세 줄의 결과로 옳은 것은?

문제 11

문제 114지선다
메서드 오버로딩에 대한 설명으로 옳지 않은 것은?

문제 12

class Vehicle {} class Car extends Vehicle {} class Bicycle extends Vehicle {} public class Main { public static void main(String[] args) { Vehicle v = new Car(); Bicycle b = (Bicycle) v; } }
문제 124지선다
위 코드를 컴파일하고 실행했을 때 결과로 옳은 것은?

문제 13

class Parent { int value; Parent(int value) { this.value = value; } } class Child extends Parent { Child() { System.out.println("Child 생성자"); } public static void main(String[] args) { Child c = new Child(); } }
문제 134지선다
위 코드를 컴파일했을 때 결과로 옳은 것은?

오버라이딩·다형성·동적 바인딩 (14–18)

문제 14

class Parent { protected void greet() { System.out.println("Parent"); } } class Child extends Parent { private void greet() { System.out.println("Child"); } }
문제 144지선다
위 코드를 컴파일했을 때 결과로 옳은 것은?

문제 15

class Shape { double area() { return 0; } void printArea() { System.out.println("면적: " + area()); } } class Circle extends Shape { double radius; Circle(double radius) { this.radius = radius; } @Override double area() { return 3.14 * radius * radius; } } public class Main { public static void main(String[] args) { Shape s = new Circle(2); s.printArea(); } }
문제 154지선다
위 코드를 실행했을 때 출력되는 결과로 옳은 것은?

문제 16

class Animal { void sound() { System.out.println("동물 소리"); } } class Cat extends Animal { @Override void sound() { System.out.println("야옹"); } void scratch() { System.out.println("할퀴기"); } } public class Main { public static void main(String[] args) { Animal a = new Cat(); a.sound(); a.scratch(); } }
문제 164지선다
위 코드를 컴파일했을 때 결과로 옳은 것은?

문제 17

import java.io.IOException; class Parent { void process() throws IOException { System.out.println("Parent 처리"); } } class Child extends Parent { @Override void process() throws RuntimeException { System.out.println("Child 처리"); } public static void main(String[] args) { Parent p = new Child(); try { p.process(); } catch (IOException e) { System.out.println("예외 처리"); } } }
문제 174지선다
위 코드를 컴파일하고 실행했을 때 결과로 옳은 것은?

문제 18

class Shape { String name() { return "도형"; } } class Triangle extends Shape { @Override String name() { return "삼각형"; } } class Square extends Shape { @Override String name() { return "사각형"; } } public class Main { public static void main(String[] args) { Shape[] shapes = { new Triangle(), new Square(), new Shape() }; for (Shape s : shapes) { System.out.print(s.name() + " "); } } }
문제 184지선다
위 코드를 실행했을 때 출력되는 순서로 옳은 것은?

예외 처리 (19–24)

문제 19

public class Main { static int test() { try { return 1; } finally { System.out.println("finally 실행"); } } public static void main(String[] args) { System.out.println(test()); } }
문제 194지선다
위 코드를 실행했을 때 출력 순서로 옳은 것은?

문제 20

import java.io.IOException; public class Main { static void readFile() throws IOException { throw new IOException("파일 없음"); } public static void main(String[] args) { readFile(); } }
문제 204지선다
위 코드를 컴파일했을 때 결과로 옳은 것은?

문제 21

public class Main { public static void main(String[] args) { try { int[] arr = new int[3]; System.out.println(arr[5]); } catch (Exception e) { System.out.println("Exception 처리"); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("배열 인덱스 예외 처리"); } } }
문제 214지선다
위 코드를 컴파일했을 때 결과로 옳은 것은?

문제 22

class InsufficientBalanceException extends Exception { InsufficientBalanceException(String message) { super(message); } } class Account { int balance = 1000; void withdraw(int amount) throws InsufficientBalanceException { if (amount > balance) { throw new InsufficientBalanceException("잔액 부족"); } balance -= amount; } } public class Main { public static void main(String[] args) { Account acc = new Account(); try { acc.withdraw(2000); } catch (InsufficientBalanceException e) { System.out.println("오류: " + e.getMessage()); } } }
문제 224지선다
위 코드를 실행했을 때 출력되는 결과로 옳은 것은?

문제 23

public class Main { static void methodA() { try { methodB(); } finally { System.out.println("A의 finally"); } } static void methodB() { throw new RuntimeException("문제 발생"); } public static void main(String[] args) { try { methodA(); } catch (RuntimeException e) { System.out.println("main에서 처리: " + e.getMessage()); } } }
문제 234지선다
위 코드를 실행했을 때 출력 순서로 옳은 것은?

문제 24

문제 244지선다
checked 예외와 unchecked 예외에 대한 설명으로 옳은 것은?

참고 자료

Last updated on