본문 바로가기
정보처리산업기사

정보처리산업기사 실기 Java 기출 10문제

by Hwangminseo 2026. 4. 7.

1번

문제
다음 자바 프로그램의 실행 결과를 쓰시오.

public class Main {
    public static void main(String[] args) {
        int a = 0, sum = 0;
        while (true) {
            if (sum > 50) break;
            ++a;
            sum += a;
        }
        Systehttp://m.out.print(a + " " + sum);
    }
}

정답
10 55

핵심 개념

  • while 반복문
  • break
  • 누적합
  • 전위 증가 연산

2번

문제
다음 자바 프로그램의 실행 결과를 쓰시오.

public class Main {
    public static void main(String[] args) {
        int x = -7;
        int abs = (x >= 0) ? x : -x;
        Systehttp://m.out.print(abs);
    }
}

정답
7

핵심 개념

  • 삼항 연산자
  • 조건식

3번

문제
다음 자바 프로그램의 실행 결과를 쓰시오.

public class Main {
    public static void main(String[] args) {
        int i = 17;
        i += 1;
        i -= 2;
        i *= 3;
        i /= 4;
        i %= 5;
        Systehttp://m.out.print(i);
    }
}

정답
2

핵심 개념

  • 복합 대입 연산자
  • 정수 나눗셈
  • 나머지 연산

4번

문제
다음 자바 프로그램의 실행 결과를 쓰시오.

public class Main {
    public static void main(String[] args) {
        int a = 18;
        int b = 24;
        int g = 0;
        int c = a < b ? a : b;

        for (int i = 1; i <= c; i++) {
            if (a % i == 0 && b % i == 0) {
                g = i;
            }
        }

        Systehttp://m.out.print(g);
    }
}

정답
6

핵심 개념

  • 최대공약수
  • for 반복문
  • 논리 AND

5번

문제
다음 자바 프로그램의 실행 결과를 쓰시오.

public class Main {
    public static void main(String[] args) {
        int[] a = new int[8];
        int i = 0;
        int n = 13;

        while (n > 0) {
            a[i++] = n % 2;
            n /= 2;
        }

        for (i = 7; i >= 0; i--) {
            Systehttp://m.out.print(a[i]);
        }
    }
}

정답
00001101

핵심 개념

  • 배열
  • 10진수 → 2진수 변환
  • while / for

6번

문제
다음 자바 프로그램의 실행 결과를 쓰시오.

public class Main {
    static void init(int[][] a) {
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                a[i][j] = 0;
    }

    static void data(int[][] a) {
        int v = 1;
        for (int i = 0; i < 3; i++)
            for (int j = i; j < 3; j++)
                a[i][j] = v++;
    }

    static void prnt(int[][] a) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (a[i][j] == 0)
                    Systehttp://m.out.print(" ");
                else
                    Systehttp://m.out.print(a[i][j]);
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        int[][] a = new int[3][3];
        init(a);
        data(a);
        prnt(a);
    }
}

정답

123
 45
  6

핵심 개념

  • 2차원 배열
  • 메서드 호출 순서
  • 상삼각 형태 채우기

7번

문제
다음 자바 프로그램의 실행 결과를 쓰시오.

public class Main {
    public static void main(String[] args) {
        int x = 1;
        System.out.println(!(x > 0));
        System.out.println((x != 0) || (x > 0));
        System.out.println(x << 2);
        System.out.println(x & 2);
        System.out.println(x %= 3);
    }
}

정답

false
true
4
0
1

핵심 개념

  • 논리 NOT
  • 논리 OR
  • 비트 시프트
  • 비트 AND
  • 복합 대입

8번

문제
다음 자바 프로그램의 실행 결과를 쓰시오.

public class Main {
    public static void main(String[] args) {
        int[] a = {4, 7, 1, 2};

        for (int i = 0; i < 3; i++) {
            for (int j = i + 1; j < 4; j++) {
                if (a[i] > a[j]) {
                    int temp = a[j];
                    a[j] = a[i];
                    a[i] = temp;
                }
            }
        }

        for (int i = 0; i < 4; i++) {
            Systehttp://m.out.print(a[i] + "a");
        }
    }
}

정답
1a2a4a7a

핵심 개념

  • 배열 정렬
  • 중첩 반복문
  • swap

9번

문제
다음 자바 프로그램의 실행 결과를 쓰시오.

class Base {
    int x = 3;

    int getX() {
        return x * 2;
    }
}

class Derivate extends Base {
    int x = 7;

    int getX() {
        return x * 3;
    }
}

public class Main {
    public static void main(String[] args) {
        Base a = new Derivate();
        Derivate b = new Derivate();

        Systehttp://m.out.print(a.getX() + a.x + b.getX() + b.x);
    }
}

정답
52

핵심 개념

  • 다형성
  • 오버라이딩
  • 필드는 참조 변수 타입 기준
  • 메서드는 실제 객체 기준

풀이 요약

  • a.getX() → 실제 객체 Derivate 기준 → 21
  • a.x → 참조 타입 Base 기준 → 3
  • b.getX() → 21
  • b.x → 7
  • 합계 52

10번

문제
다음 자바 프로그램의 실행 결과를 쓰시오.

public class Main {
    static int a = 0;

    static int func(int t) {
        a = a + t;
        return a;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            func(i);
        }
        Systehttp://m.out.print(a);
    }
}

정답
10

핵심 개념

  • static 변수
  • 누적합
  • for 반복문

자주 나오는 문법 포인트

  • while / for / break
  • 삼항 연산자
  • 복합 대입 연산자
  • 정수 나눗셈 / 나머지
  • 1차원 배열 / 2차원 배열
  • 비트 연산자 <<, &
  • 상속 / 오버라이딩 / 다형성
  • 필드와 메서드의 바인딩 차이
  • static 변수 누적