Home Tutorial Java Scjp Part7 SCJP Module-7 Question-10

 
 

SCJP Module-7 Question-10
Posted on: July 14, 2010 at 12:00 AM
The example given below will test your understanding about parsing integer object into primitive int, and will also test your logic about the program.

Given a sample code:

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

What will be the result of above code ?

(A) 5 10
(B) Compilation fails because of an error on line 4.
(C) Compilation fails because of an error on line 5.
(D) Compilation fails because of an error on line 6.

Answer:

(A)

Related Tags for SCJP Module-7 Question-10: