Java 5

[정보처리기사 실기] 자바(JAVA) 기출 유형_5 (기타 주요 문법)

[22년 1회]11. 다음 Java 코드 중에서 밑줄에 들어갈 알맞는 코드를 작성하시오.class Car implements Runnable { int a; public void run() { System.out.println("message"); }}public class Main { public static void main(String args[]) { Thread t1 = new Thread(new ___1___()); t1.start(); }}답: Car Car 라는 클래스가 Runnable 의 자격을 얻었으므로, Thread 에 들어갈 수 있는 것도 Car 뿐이다. ..

[정보처리기사 실기] 자바(JAVA) 기출 유형_4 (정적 멤버 static, 싱글톤)

[21년 2회]17. 클래스 내에서 객체 생성 없이 사용할 수 있는 메소드로써 출력 결과를 작성하시오.public class Test { public static void main(String[] args) { system.out.print(Test.check( 1 )); } ( 1 ) String check(int num) { return (num >= 0) ? "positive" : "negative"; }}답: static 일반 메소드: Test t = new Test(); 처럼 new를 해서 물건을 만들어야만 부를 수 있음static 메소드: new 할 필요 없이 Test.check() 처럼..

[정보처리기사 실기] 자바(JAVA) 기출 유형_3 (상속, 오버라이딩, 생성자)

[20년 2회]5. 다음은 자바 코드이다. 다음 밑줄에 들어갈 키워드를 쓰시오.class parent { public void show() { system.out.println("Parent"); }}class Child extends Parent { public void show() { system.out.println("Child"); }}public class good { public static void main(String[] args) { Parent pa = ____ Child(); pa.show(); }}답: new 자바에서 객체(실체)를 생성할 때는 'n..

[정보처리기사 실기] 자바(JAVA) 기출 유형_2 (배열)

[20년 4회]6. 다음은 자바 소스 코드이다. 출력 결과를 보고 , 1,2에 알맞는 값을 적으시오.public class good { public static void main(String[] args) { int[][] a = new int[( 1 )][( 2 )]; for (int i = 0; i [출력 결과] 1 4 7 10 132 5 8 11 143 6 9 12 15 답: (1) 3 (2) 5 반복문이 어디까지 돌아가는지 확인한다. public static void main(String[] args) { int[][] a = new int[( 1 )][( 2 )];→ 배열 정의→..

[정보처리기사 실기] 자바(JAVA) 기출 유형_1 (반복문, 제어문, 연산)

[20년 1회]13. 다음은 자바 소스코드이다. 출력 결과를 쓰시오.public class good { public static void main(String[] args) { int i; int[] a = {0, 1, 2, 3}; for (i = 0; i 답: 0 1 2 3 public class good { public static void main(String[] args) { int i; int[] a = {0, 1, 2, 3};→ 변수 정의 for (i = 0; i System.out.print(a[i] + " ");i = 0 : i 의..