SCJP Module-7 Question-7


 

SCJP Module-7 Question-7

The program given below will test your understanding about the Integer class and int class in java.

The program given below will test your understanding about the Integer class and int class in java.

Given a sample code:

1    class Test {
2    public static void main(String[] args) {
3    Integer i = new Integer(2) + new Integer(3);
4    int j = i + 3;
5    System.out.print(i);
6    System.out.print(" "+j);
}}

What will be the result of above code ?

(A) 5 8
(B) An exception is thrown at runtime.
(C) Compilation fails because of an error on line 3.
(D) Compilation fails because of an error on line 4.

Answer:

(A)

Ads