nerdexam
Oracle

1Z0-809 · Question #153

Given the code fragment: public static void main(String[] args) { Integer s1 = 1_000; Integer s2 = 2_000; Long s3 = (long)(s1 + s2); //line n1 String s4 = (String)(s3 + s2); //line n2…

The correct answer is B. Compilation fails at line n2. You've hit your session limit · resets 10:20pm (America/New_York)

Question

Given the code fragment: public static void main(String[] args) { Integer s1 = 1_000; Integer s2 = 2_000; Long s3 = (long)(s1 + s2); //line n1 String s4 = (String)(s3 + s2); //line n2 System.out.print("Sum is " + s4); } What is the result?

Options

  • ASum is 600
  • BCompilation fails at line n2.
  • CCompilation fails at line n1.
  • DA ClassCastException is thrown at line n2.
  • EA ClassCastException is thrown at line n1.

How the community answered

(21 responses)
  • A
    5% (1)
  • B
    76% (16)
  • C
    14% (3)
  • E
    5% (1)

Explanation

You've hit your session limit · resets 10:20pm (America/New_York)

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice