Monday 18 March 2013

SCJP - 34 -Given Example



Which will compile using Java 5, but will NOT compile using Java 1.4? (Choose all that apply.)
A. Line 4.
B. Line 5.
C. Line 6.
D. Line 7.
E. Line 8.
F. Line 9.

Answer:

A, D, and E are correct. Because of the methods’ return types, these method calls required
autoboxing to compile.

B, C, and F are incorrect based on the above. (Objective 3.1)
==
class Convert {
public static void main(String[] args) {
Long xL = new Long(456L);
long x1 = Long.valueOf("123");
Long x2 = Long.valueOf("123");
long x3 = xL.longValue();
Long x4 = xL.longValue();
Long x5 = Long.parseLong("456");
long x6 = Long.parseLong("123");
 }
 }

No comments:

Post a Comment