기록.

자바 관련 문제 본문

Programming/Java

자바 관련 문제

Youngheon 2017. 12. 22. 23:36

JAVA에 대한 설명으로 틀린 것은? (2개)

1) 객체지향형언어이다.

2) WINDOWS플랫폼에서 컴파일된 클래스는 UNIX플랫폼에서 재컴파일 없이 실행 가능하다.

3) WINDOWS플랫폼에 설치될 JDK는 UNIX플랫폼에도 설치 가능하다.

4) 컴파일된 클래스는 BinaryCode 체계로 구성된다.


다음 중 Primitive Type(기본 데이타 타입)이 아닌 것은?

1) int

2) float

3) String

4) char


다음 프로그램의 출력 결과는?

public class Foo{

    public static void main(String args []){

        String s;

        System.out.println("s = "+ s);

    }

1) "s = " 이라고 출력된다.

2) "s = null" 이라고 출력된다.

3) s가 초기화되지 않았기 때문에 컴파일 에러

4) 컴파일은 되나 실행시 NullPointException 예외가 발생된다.


다음 A 클래스의 상속을 받은 B클래스에서 method()를 바르게 Overriding한 것은?

class A{

    void method(Object o) {}

class B extends A{

    //이곳에서 Overriding

}

1) void method(int o){}

2) public void method(Object obj){}

3) int method(Object obj){}

4) private void method(Object obj)


다음 클래스의 (a)에서 test() 메소드를 Overloading 하려고 한다. 잘못된 것은(2개)

class Test{

    public void test(){}

    // (a)


1) public void test(int a){}

2) void test(){}

3) public int test(){}

4) public int test(int i){}


다음은 배열을 선언하거나 초기화 한 것이다. 잘못된 것을 고르시오

1) int [] arr;

2) int [] arr = {1,2,3};

3) int [] arr = new int[5];

4) int[5] arr;


다음 중 접근 제어자(access modifier)의 접근 범위가 넓은 것에서 좁은 것의 순서로 바른 것은?

1) public > protected > (default) > private

2) public > (default) > protected > private

3) private > (default) > protected > public

4) private > protected > (default) > public


다음 중 import 하지 않아도 사용 가능한 package는?

1) java.lang.*;

2) java.util.*;

3) java.net.*;

4) java.sql.*;


아래코드의 실행 결과로 가장 알맞은 것을 고르시오.

void m(int i){

    try{

        if(i==1){

        throw new NullPointerException();

        }

        System.out.print("try,");

    } finally{

        System.out.print("finally,");

    }

    System.out.print("end");


1) i가 0일 경우 출력되는 결과는 try, finally, end 이다.

2) i가 1일 경우 출력되는 결과는 try, finally, end 이다.

3) i가 0일 경우 출력되는 결과는 try, end 이다.

4) i가 1일 경우 출력되는 결과는 try, end 이다.


다음 code의 실행결과는?

public class CallMethod{

    public void increase(int[] a){

        a[0]++;

    }

    public static void main(String [] args){

        CallMethod cm = new CallMethod();

        int[] a = new int[3];

        cm.increase(a);

        System.out.println("a[0] = "+a[0]);

    }



(a) 부분에 적절한 표현과 (b) 부분에 적절치 않은 것 두개 고르시오

package com.my;

public class A{

    private int data;

    public void setData(int d){

        data = d;

    }

 // (a)


class AUser{

    public static void main(String[] args){

    A a;

    // (b)

}


(a)

1) import  com.A;

2) import  my.A;

3) import com.my;

4) import com.my.A;


(b)

1) a = null;

2) a = new A();

3) a.data = 10;

4) a.setData(10);


다음 code의 실행 결과는?

String str1 = new String("test");

String str2 = new String("test");

System.out.print(str1.equals(str2);

System.out.print(str1 == str2);


다음 중 자바에서 사용되는 키워드가 아닌 것은?

1) protected

2) Integer

3) this

4) super


다음 프로그램에 대한 설명으로 올바른 것은?

public class Test{

    public static void main(String [] args){

        int [] numbers = {1,2,3,4,5};

        for(int i=1; i<numbers.length;i++){

            System.out.println(numbers[i]);

        }

        System.out.println("end");

    }

1) i의 초기값이 반드시 0 이어야 한다.

2) 컴파일 오류

3) 실행시 Exception이 발생

4) 마지막에 end가 출력


다음 프로그램에서 (a)에 들어가지 못하는 것은?

interface SuperInterface{}

interface SuperA extends SuperInterface{}

interface SuperB extends SuperInterface{}

class impleClass implements SuperB{}


public class Test{

    public static void main(String [] args){

        (a) a = new ImpleClass();

    }

}

1) SuperInterface

2) SuperA

3) SuperB

4) ImpleClass


다음 중 자료 구조형 API 설명으로 올바른 것은?

1) Set은 중복된 데이터를 저장할 수 있다.

2) List는  key, value로 저장된다.

3) Map은 순서가 있다.

4) Map은 key, value 구조로 저장된다.


다음 코드에서 출력되는 값은?

class Test{

    public static void main(String args [])}

        ObjectOne one = new ObjectOne();

        one.number = 99;

        one.method(100);

        System.out.println(one.number);

    }


class ObjectOne{

        public int number;

        public void method (int n){

            number = n;

        }

}

1) 0

2) 1

3) 99

4) 100


다음과 같은 class가 정의되어 있다. Sub class의 Main method가 실행될 때의 결과는?

class Super{

    public void method (int i){

        System.out.println("Value is "+i);

    }



class Sub extends Super{

    public void method (int j){

       System.out.println("This value is "+ j);

    }

    public static void main(String args [] ){

        Super s1 = new Super();

        Super s2 = new Sub();

        s1.method(5);

        s2.method(6);

    }

}

1) Value is 5

   Value is 6

2) This value is 5

   This value is 6

3) Value is 5

   This value is 6

4) This value is 5

   Value is 5



다음 프로그램에 대한 설명으로 올바른 것은?

public class Test{

    public static void main(String [] args){

        int num = Integer.parseInt("A");

        System.out.println(num);

    }

1) 컴파일 에러

2) 컴파일은 되나 실행시 NumberFormatException 예외가 발생

3) 65가 출력

4) 컴파일은 되나 실행시 NullPointException 예외가 발생




답지는 없습니다..

'Programming > Java' 카테고리의 다른 글

자바8 소개  (0) 2016.04.27