본문 바로가기
6. 국가기술자격 모음/[정보기술]정보처리기사

[정보처리기사] 프로그래밍언어 - Java

by cogito21_cpp 2024. 10. 11.
반응형

1. 분석 및 키워드

학습목표

1) 응용 소프트웨어 개발에 사용되는 프로그래밍 언어의 기초 문법을 활용할 수 있고, 언어의 특성 및 라이브러리를 기반으로 하여 기본 응용 소프트웨어를 구현할 수 있어야 한다.

 

Keyword

- 진수, 변수, 데이터타입, 연산자, 조건문, 반복문, 함수, 사용자정의자료형(열거체, 구조체), 추상화와 상속, 알고리즘, 라이브러리, 예약어

 

빈출용어 및 개념

 

 

출제정답(2020년 이후)

년도 3회 2회 1회
2024년   1번
(배열 비교연산자)

14번
(홀수 더하기, 짝수 더하기)

17번
(문자열, 함수, charAt, 배열)

20번
(문자열 메서드)
1번()
10번()
16번()
2023년 1번()
12번()
14번()
14번() 1번()
18번()
20번()
2022년 4번()
19번()
20번()
7번()
17번()
1번()
5번()
2021년 1번()
11번()
17번()
19번()
7번()
17번()
2020년 2번
()

15번
()

17번
()

--- 4회 ---
7번
()

8번
()

19번
()
5번
()

19번
()
4번
()

 

 

 

2. 이론 

 

 

3. 최신기출

2024년 2회

[2024년 2회] 20번

class Main {
    public static void main(String[] args) {
        String str = "ITISTESTSTRING";
        String[] result = str.split("T");
        System.out.print(result[3]);
    }
}

 

 

[2024년 2회] 17번

class Main {
    public static void main(String[] args) {
        String str = "abacabcd";
        boolean[] seen = new boolean[256];
        System.out.print(calculFn(str, str.length()-1, seen));
    }
 
    public static String calculFn(String str, int index, boolean[] seen) {
        if(index < 0) return "";
        char c = str.charAt(index);
        String result = calculFn(str, index-1, seen);
        if(!seen[c]) {
            seen[c] = true;
            return c + result;
        }
        return result;
    }
}

 

 

[2024년 2회] 14번

class Main {
    public static void main(String[] args) {
        int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        ODDNumber OE = new ODDNumber();
        System.out.print(OE.sum(a, true) + ", " + OE.sum(a, false));
    }
}
 
interface Number {
    int sum(int[] a, boolean odd);
}
 
class ODDNumber implements Number {
    public int sum(int[] a, boolean odd) {
        int result = 0;
        for(int i=0; i < a.length; i++){
            if((odd && a[i] % 2 != 0) || (!odd && a[i] % 2 == 0))
                result += a[i];
        }        
        return result;
    }    
}

 

 

[2024년 2회] 1번

class Main {
    public static void main(String[] args) {
        int[] a = new int[]{1, 2, 3, 4};
        int[] b = new int[]{1, 2, 3, 4};
        int[] c = new int[]{1, 2, 3};
        
        check(a, b);
        check(a, c); 
        check(b, c); 
    }
 
    public static void check(int[] a, int[] b) {
        if (a==b) {
            System.out.print("O");
        }else{
            System.out.print("N");
        }
        
    }
}

 


2024년 1회

[2024년 1회] 번


2023년 3회

[2023년 3회] 번


2023년 2회

[2023년 2회] 번


2023년 1회

[2023년 1회] 번


2022년 3회

[2022년 3회] 번


2022년 2회

[2022년 2회] 번


2022년 1회

[2022년 1회] 번


2021년 3회

[2021년 3회] 번


2021년 2회

[2021년 2회] 17번

 

 

[2021년 2회] 19번

 

 


2021년 1회

[2021년 1회] 7번

 

 

[2021년 1회] 17번

 

 


2020년 4회

[2020년 4회] 7번

- 다음은 변수 n에 저장된 10진수를 2진수로 변환하여 출력하는 java 코드이다. 코드를 분석하여 빈칸 (가), (나)에 알맞은 답을 작성하시오.

class Main {
    public static void main (String[] args) {
    	int[]a = new int[8];
        int i=0; int n=10;
        while ( 가 ) {
        	a[i++] = ( 나 );
            n /= 2;
        }
        for(i=7; i>=0; i--){
         System.out.print(a[i]);
        }
     }
  }

 

답: (가) n>0 (나) n%2

 

[2020년 4회] 8번

- 빈칸 (가), (나)에 알맞은 답을 작성하시오.

public class Main {
    public static void main(String[] args) {
    	int ary[][] = new int[가][나];
   
        for(int i = 0; i <3; i++){
        for(int j=0; j < 5; j++){
        ary[i][j] = j*3+(i+1);
        	System.out.print(ary[i][j]+"");
         }
         System.out.println();
       }
     }
   }

 

답: (가) 3 (나) 5

 

[2020년 4회] 19번

- 출력 결과를 작성하시오.

class Parent{
    public int compute(int num){
    	if(num <=1) return num;
        return compute(num-1) + compute(num-2);
    }
 }
 
 class Child extends parent {
    public int compute(int num){
        if(num<=1) return num;
            return compute(num-1) + compute(num-3);
        }
   }
   
class Main{
    public static void main (String[] args){
        Parent obj = new Child();
        System.out.print(obj.compute(4));
   }
 }

 

답: 1


2020년 3회

[2020년 3회] 2번

- 출력 결과를 작성하시오.

public class Main{
    public static void main(String[] args){
    	int i=0, c=0;
        while (i<10){
         i++;
         c*=i;
        }
        System.out.println(c);
   }
  }

 

답: 0

 

[2020년 3회] 15번

- 출력 결과를 작성하시오.

abstract class Vehicle{
    String name;
    abstract public String getName(String val);
    public String getName(){
    	return "Vehicle name:" + name;
    }
}
 
class Car extends Vehicle{
    private String name;
    
    public Car(String val){
    	name=super.name=val;
    }
    
    public String getName(String val){
	    return "Car name : " + val;
    }
    
    public String getName(byte val[]){
	    return "Car name : " + val;
    }
}
 
public class Main {
    public static void main(String[] args){
        Vehicle obj = new Car("Spark");
        System.out.print(obj.getName());
    }
}

 

답: Vehicle name: Spark

 

[2020년 3회] 17번

- 출력 결과를 작성하시오.

public class Main {
    public static void main(String[] args){
    int i=0, sum=0;
    while (i<10){
    	i++;
        if(i%2 ==1)
        	continue;
        sum += i;
     }
     System.out.println(sum);
   }
}

 

답: 30

 


2020년 2회

[2020년 2회] 5번

- 빈 칸 (가)에 들어갈 알맞은 답을 작성하시오.

class Parent{
  void show(){System.out.println("parent");}  
}
class Child extends Parent{
  void show() {System.out.println("child");}
}
 
class Main {  
  public static void main(String args[]) { 
    Parent pa=(가) Child();
    pa.show();
  } 
}

 

답: (가) new

 

[2020년 2회] 19번

- 출력 결과를 작성하시오.

class A{
    private int a;
    public A(int a){
    	this.a = a;
    }
    public void display(){
    	System.out.println("a=" + a);
    }
}
 
class B extends A {
	public B(int a){
    	super(a);
        super.display();
    }
}
 
 
public class Main {
    public static void main(String[] args){
    	B obj = new B(10);
    }
}

 

답: a=10


2020년 1회

[2020년 1회] 4번

- 출력 결과를 작성하시오.

class Main {  
  static int[] arr() { 
    int a[]=new int[4];
    int b = a.length;
    for(int i =0; i<b;i++)
      a[i]=i;
    return a;
  } 
 
  public static void main(String args[]) { 
  int a[]=arr();
  for(int i =0; i< a.length; i++)
    System.out.print(a[i]+" ");
  } 
}

 

답: 0 1 2 3


 

 

반응형