인사말

안녕하세요. 이 글을 읽고 계신다면 정보처리기사 또는 정보처리산업기사 수험생이실 것 같습니다.

여러 좋은 서적에서 이론을 잘 설명하고 있지만, 코딩 문제의 경우 같은 문제를 여러 번 풀다 보면 답이 머리에 기억되어 새로운 문제가 필요하게 되는 순간이 옵니다.

그럴 때 더 많은 문제를 풀어보고 도움이 되게 하고자 여러 C언어, JAVA, Python 문제를 변형 시키고 직접 컴파일하여 답을 확인하면서 문제를 만들었습니다.

정보처리 실기를 공부하시는 모든 수험생 여러분, 목표하는 모든 것이 이루어지는 그날까지 응원하겠습니다. 화이팅!

목표를 향해 열심히 노력하시고, 좋은 결과 있기를 기원합니다!

 

 

정보처리기사 실기 언어 코딩 기출변형 문제

 

1. 출력 값을 작성하시오.

public class ConfusingCalculation {

    private int initialValue;

    public ConfusingCalculation(int initialValue) {
        this.initialValue = initialValue;
    }

    public int calculateA() {
        return initialValue + 15;
    }

    public int calculateB() {
        return (70 + calculateA());
    }

    public int calculateC() {
        return (400 + calculateB());
    }

    public static void main(String[] args) {
        ConfusingCalculation obj = new ConfusingCalculation(7);
        int result = 0;
        result += obj.calculateC();
        System.out.println(result);
    }
}
정답

492

2. 출력 값을 작성하시오.

public class ConfusingProcess {
    private int base;

    public ConfusingProcess(int base) {
        this.base = base;
    }

    public int stepOne() {
        return base + 3;
    }

    public int stepTwo() {
        return (stepOne() * 2 - 7);
    }

    public int stepThree() {
        return (stepTwo() + 10);
    }

    public int stepFour() {
        return (stepThree() * 2 - stepOne());
    }

    public int stepFive() {
        return (stepFour() + 5 - stepTwo());
    }

    public static void main(String[] args) {
        ConfusingProcess proc = new ConfusingProcess(8);
        int finalResult = 0;
        finalResult += proc.stepFive();
        System.out.println("Confusing Computation Result: " + finalResult);
    }
}
정답

Confusing Computation Result: 29

3. 출력 값을 작성하시오.

public class ComplexOperations {
    public static void main(String[] args) {
        int initialValue = 27;
       
        System.out.println("Initial value: " + initialValue);
       
        int finalResult = 0;
        finalResult = stepOne(initialValue);
        finalResult = stepThree(finalResult);
        finalResult = stepTwo(finalResult);
        finalResult = stepFour(finalResult);
        finalResult = stepFive(finalResult);
       
        System.out.println("Final result after complex operations: " + finalResult);
    }

    public static int stepOne(int num) {
        return num * 3;
    }

    public static int stepTwo(int num) {
        return num - 8;
    }

    public static int stepThree(int num) {
        return num + 12;
    }

    public static int stepFour(int num) {
        return num / 2;
    }

    public static int stepFive(int num) {
        return num + 5;
    }
}
정답

Initial value: 27
Final result after complex operations: 47

4. 출력 값을 작성하시오.

public class Main {
    public static void main(String[] args) {
        String input = "Hello, World!";
        String result = "";

        result = appendString(input, " is confusing.");
        result = reverseString(result);
        result = convertToUpper(result);
        result = removeSpaces(result);

        System.out.println("Final result after confusing operations: " + result);
    }

    public static String appendString(String original, String appendage) {
        return original + appendage;
    }

    public static String reverseString(String text) {
        StringBuilder reversed = new StringBuilder(text);
        return reversed.reverse().toString();
    }

    public static String convertToUpper(String text) {
        return text.toUpperCase();
    }

    public static String removeSpaces(String text) {
        return text.replaceAll("\\s+", "");
    }
}
정답

Final result after confusing operations: .GNISUFNOCSI!DLROW,OLLEH

5. 출력 값을 작성하시오.

public class ConfusingSimpleProblem {
    public static void main(String[] args) {
        int a = 5;
        int b = 7;
        int c = a + b * 2;

        System.out.println("Result: " + c);
    }
}
정답

Result: 19

6. 출력 값을 작성하시오.

public class AdvancedConfusingProblem {
    public static void main(String[] args) {
        int x = 10;
        int y = 5;

        int result1 = calculate(x, y, true);
        int result2 = calculate(x, y, false);

        System.out.println("Result 1: " + result1);
        System.out.println("Result 2: " + result2);

        int difference = result1 - result2;
        System.out.println("Difference: " + difference);
    }

    public static int calculate(int a, int b, boolean add) {
        if (add) {
            return a + b;
        } else {
            return a * b;
        }
    }
}
정답

Result 1: 15
Result 2: 50
Difference: -35

7. 출력 값을 작성하시오.

public class ComplexCalculation {
    public static void main(String[] args) {
        int value1 = 0, value2 = 98, value3 = 22;
        boolean condition = value1 > value2 ? true : false;
       
        if (condition) {
            value2 = value2 << 3;
        } else {
            value3 = value3 << 1;
        }
       
        System.out.println("Result: " + (value2 + value3));
    }
}
정답

Result: 142

8. 출력 값을 작성하시오.

public class ArrayManipulation {
    public static void main(String[] args) {
        int[] array = {3, 7, 12, 5, 9};
        int sum = 0;
        int product = 1;
       
        for (int i = 0; i < array.length; i++) {
            sum += array[i];
            product *= array[i];
        }
       
        System.out.println("Sum of elements: " + sum);
        System.out.println("Product of elements: " + product);
    }
}
정답

Sum of elements: 36
Product of elements: 11340

9. 출력 값을 작성하시오.

public class RecursiveSum {
    public static void main(String[] args) {
        int number = 5;
        int sum = calculateSum(number);
        System.out.println("Sum of numbers from 1 to " + number + " is: " + sum);
    }

    public static int calculateSum(int n) {
        if (n == 1) {
            return 1;
        }
        else {
            return n + calculateSum(n - 1);
        }
    }
}
정답

Sum of numbers from 1 to 5 is: 15

10. 출력 값을 작성하시오.

class Parent {
    int value = 10;

    void display() {
        System.out.println("Parent class: " + value);
    }
}

class Child extends Parent {
    int value = 20;

    void display() {
        System.out.println("Child class: " + value);
    }

    void parentDisplay() {
        super.display();
    }
}

public class HidingExample {
    public static void main(String[] args) {
        Parent parent = new Parent();
        Child child = new Child();

        System.out.println("Parent value: " + parent.value);
        parent.display();

        System.out.println("\nChild value: " + child.value);
        child.display();

        System.out.println("\nCalling parent's display from child:");
        child.parentDisplay();
    }
}
정답

Parent value: 10
Parent class: 10

Child value: 20
Child class: 20

Calling parent’s display from child:
Parent class: 10