재구성 출제 고지: 이 문제집은 국가평생교육진흥원 독학학위제 4단계 통합프로그래밍 출제기준의 평가영역(C 언어, 객체지향 프로그래밍/Java) 범위와 문항 유형을 분석해 새로 구성한 재구성 문항입니다. 실제 기출 문항을 그대로 옮긴 것이 아니며, 회차별 정확한 문항 수·배점·시험 시간은 시행처 공고를 확인해야 합니다. 여기서는 학습 편의를 위해 22문항을 표준 분량으로 구성했습니다.
출제 범위와 문항 배분
이 편은 06~12편(C 언어 핵심, Java 기초·객체지향·예외·컬렉션)에서 다룬 개념을 코드 실행 결과 추적·오류 찾기·설계 문제 형태로 재확인합니다. 22편(통합 실습 ①)에서 다룬 C·자료구조 연계 감각도 함께 점검합니다.
| 영역 | 문항 수 | 문항 번호 | 관련 편 |
|---|---|---|---|
| C 배열과 문자열 | 3 | 1–3 | 06 |
| C 포인터와 함수 인자 전달 | 4 | 4–7 | 06, 07 |
| C 구조체 | 3 | 8–10 | 08 |
| C 파일 입출력 | 2 | 11–12 | 08 |
| Java 클래스·생성자·기본 문법 | 2 | 13–14 | 09 |
| Java 상속·오버라이딩·다형성 | 4 | 15–18 | 10 |
| Java 추상 클래스·인터페이스 | 2 | 19–20 | 11 |
| Java 예외 처리·컬렉션 | 2 | 21–22 | 12 |
각 문제는 코드를 먼저 한 줄씩 손으로 따라가며 변수 값을 표에 적어본 뒤 보기를 확인하는 방식으로 푸는 것을 권장합니다. 특히 포인터가 가리키는 주소·값의 변화, 객체지향에서 어떤 메서드가 실제로 호출되는지(동적 바인딩)는 독학사 4단계에서 반복 출제되는 함정 지점입니다. 정답은 각 문제 해설에서 위치까지 다시 확인했습니다.
C 배열과 문자열 (1–3)
문제 1
#include <stdio.h>
int main(void) {
int arr[5] = {10, 20, 30};
printf("%d %d\n", arr[3], arr[4]);
return 0;
}문제 14지선다
크기 5로 선언했지만 원소 3개만 초기화한 배열 arr를 위와 같이 출력했을 때 arr[3]과 arr[4]의 값으로 가장 적절한 것은?
문제 2
#include <string.h>
#include <stdio.h>
int main(void) {
char s1[20] = "hello";
char s2[20] = "world";
strcat(s1, s2);
printf("%s\n", s1);
return 0;
}문제 24지선다
strcat(s1, s2) 함수의 동작과 위 코드의 출력 결과로 가장 적절한 것은?
문제 3
#include <stdio.h>
int main(void) {
char str[] = "ABC";
printf("%c\n", str[3]);
return 0;
}문제 34지선다
문자 배열 str이 문자 A, B, C, 그리고 문자열의 끝을 표시하는 널 문자로 구성될 때, str[3]을 출력한 결과로 가장 적절한 것은?
C 포인터와 함수 인자 전달 (4–7)
문제 4
#include <stdio.h>
void addOne(int x) {
x = x + 1;
}
int main(void) {
int a = 5;
addOne(a);
printf("%d\n", a);
return 0;
}문제 44지선다
addOne 함수가 값에 의한 호출(call by value)로 동작할 때 위 코드의 출력 결과는?
문제 5
#include <stdio.h>
void addOnePtr(int *x) {
*x = *x + 1;
}
int main(void) {
int a = 5;
addOnePtr(&a);
printf("%d\n", a);
return 0;
}문제 54지선다
문제 4의 함수를 포인터를 이용한 호출로 바꾼 위 코드의 출력 결과는?
문제 6
#include <stdio.h>
int main(void) {
int arr[4] = {10, 20, 30, 40};
int *p = arr;
printf("%d\n", *(p + 2));
return 0;
}문제 64지선다
배열 이름이 첫 원소의 주소로 변환되는 성질을 이용한 위 코드에서 *(p plus 2)를 출력한 결과는?
문제 7
다음 코드에는 오류가 있다.
#include <stdio.h>
int* getLocalAddress(void) {
int local = 100;
return &local;
}
int main(void) {
int *p = getLocalAddress();
printf("%d\n", *p);
return 0;
}문제 74지선다
위 코드가 실행 시점에 안고 있는 문제로 가장 적절한 것은?
C 구조체 (8–10)
문제 8
#include <stdio.h>
struct Point {
int x;
int y;
};
int main(void) {
struct Point p1 = {3, 4};
struct Point p2 = p1;
p2.x = 10;
printf("%d %d\n", p1.x, p2.x);
return 0;
}문제 84지선다
구조체 변수를 다른 구조체 변수에 대입(p2 = p1)한 뒤 p2.x만 바꾼 위 코드의 출력 결과는?
문제 9
#include <stdio.h>
struct Point {
int x;
int y;
};
void movePoint(struct Point *p, int dx, int dy) {
p->x += dx;
p->y += dy;
}
int main(void) {
struct Point p1 = {1, 1};
movePoint(&p1, 5, 5);
printf("%d %d\n", p1.x, p1.y);
return 0;
}문제 94지선다
구조체 포인터를 매개변수로 받는 movePoint 함수에서 p arrow x 형태(화살표 연산자)를 사용한 위 코드의 출력 결과는?
문제 10
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node *next;
};
int main(void) {
struct Node *head = (struct Node *)malloc(sizeof(struct Node));
head->data = 1;
head->next = NULL;
printf("%d\n", head->data);
free(head);
return 0;
}문제 104지선다
자기 자신을 가리키는 포인터(struct Node *next)를 멤버로 갖는 구조체를 사용하는 위 코드에 대한 설명으로 가장 적절한 것은?
C 파일 입출력 (11–12)
문제 11
#include <stdio.h>
int main(void) {
FILE *fp = fopen("data.txt", "r");
if (fp == NULL) {
printf("open fail\n");
return 1;
}
fclose(fp);
return 0;
}문제 114지선다
fopen 함수 호출 뒤 반환값을 NULL과 비교해 검사하는 위 코드의 목적으로 가장 적절한 것은?
문제 12
#include <stdio.h>
int main(void) {
FILE *fp = fopen("out.txt", "w");
fprintf(fp, "%d,%d\n", 10, 20);
fclose(fp);
int a, b;
FILE *fp2 = fopen("out.txt", "r");
fscanf(fp2, "%d,%d", &a, &b);
fclose(fp2);
printf("%d %d\n", a, b);
return 0;
}문제 124지선다
위 코드가 out.txt 파일에 쓰기와 읽기를 순서대로 수행할 때 마지막 printf의 출력으로 가장 적절한 것은?
Java 클래스·생성자·기본 문법 (13–14)
문제 13
class Counter {
int count;
Counter() {
count = 0;
}
Counter(int start) {
count = start;
}
}
public class Main {
public static void main(String[] args) {
Counter c1 = new Counter();
Counter c2 = new Counter(10);
System.out.println(c1.count + " " + c2.count);
}
}문제 134지선다
매개변수 개수가 다른 두 생성자를 정의한 위 코드에 대한 설명으로 가장 적절한 것은?
문제 14
class Box {
static int totalCount = 0;
int id;
Box() {
totalCount++;
id = totalCount;
}
}
public class Main {
public static void main(String[] args) {
Box b1 = new Box();
Box b2 = new Box();
Box b3 = new Box();
System.out.println(b1.id + " " + b2.id + " " + b3.id + " " + Box.totalCount);
}
}문제 144지선다
static으로 선언된 totalCount 필드의 성질을 이용한 위 코드의 출력 결과로 가장 적절한 것은?
Java 상속·오버라이딩·다형성 (15–18)
문제 15
class Animal {
String sound() {
return "...";
}
}
class Dog extends Animal {
String sound() {
return "Woof";
}
}
public class Main {
public static void main(String[] args) {
Animal a = new Dog();
System.out.println(a.sound());
}
}문제 154지선다
부모 타입 참조 변수 a가 자식 클래스 Dog 객체를 가리키는 위 코드에서 a.sound()를 호출한 결과로 가장 적절한 것은?
문제 16
class Animal {
void move() {
System.out.println("Animal moves");
}
}
class Bird extends Animal {
void move() {
System.out.println("Bird flies");
}
void chirp() {
System.out.println("Bird chirps");
}
}
public class Main {
public static void main(String[] args) {
Animal a = new Bird();
a.chirp();
}
}문제 164지선다
위 코드를 컴파일했을 때 나타나는 결과로 가장 적절한 것은?
문제 17
class Shape {
double area() {
return 0.0;
}
}
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[] shapes = new Shape[2];
shapes[0] = new Circle(2);
shapes[1] = new Shape();
double total = 0;
for (Shape s : shapes) {
total += s.area();
}
System.out.println(total);
}
}문제 174지선다
Shape 배열에 서로 다른 실제 타입의 객체를 담아 다형성으로 처리하는 위 코드에서 total의 출력 값으로 가장 적절한 것은?
문제 18
class A {
A() {
System.out.println("A constructor");
}
}
class B extends A {
B() {
System.out.println("B constructor");
}
}
public class Main {
public static void main(String[] args) {
B b = new B();
}
}문제 184지선다
자식 클래스 B의 생성자만 명시적으로 호출한 위 코드에서 new B()를 실행했을 때 출력 순서로 가장 적절한 것은?
Java 추상 클래스·인터페이스 (19–20)
문제 19
abstract class Shape {
abstract double area();
void printArea() {
System.out.println("area = " + area());
}
}
public class Main {
public static void main(String[] args) {
Shape s = new Shape();
}
}문제 194지선다
추상 클래스 Shape를 직접 new로 인스턴스화하려는 위 코드에 대한 설명으로 가장 적절한 것은?
문제 20
interface Flyable {
void fly();
}
interface Swimmable {
void swim();
}
class Duck implements Flyable, Swimmable {
public void fly() {
System.out.println("Duck flies");
}
public void swim() {
System.out.println("Duck swims");
}
}
public class Main {
public static void main(String[] args) {
Duck d = new Duck();
d.fly();
d.swim();
}
}문제 204지선다
한 클래스가 서로 다른 두 인터페이스를 동시에 구현(implements)하는 위 코드에 대한 설명으로 가장 적절한 것은?
Java 예외 처리·컬렉션 (21–22)
문제 21
public class Main {
public static void main(String[] args) {
int[] arr = {1, 2, 3};
try {
System.out.println(arr[5]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("index error");
} finally {
System.out.println("done");
}
}
}문제 214지선다
배열의 범위를 벗어난 인덱스에 접근하는 예외 상황을 try-catch-finally로 처리한 위 코드의 출력 순서로 가장 적절한 것은?
문제 22
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<String> names = new ArrayList<String>();
names.add("Kim");
names.add("Lee");
names.add("Park");
names.remove("Lee");
System.out.println(names.size());
System.out.println(names.get(1));
}
}문제 224지선다
ArrayList 컬렉션에서 특정 값을 제거한 뒤 크기와 인덱스로 원소를 조회하는 위 코드의 출력 결과로 가장 적절한 것은?
참고 자료
Last updated on