nerdexam
Oracle

1Z0-803 · Question #14

Given: Which two are possible outputs?

The correct answer is A. Option A D. Option D. The first println statement, System.out.println("Before if clause");, will always run. If Math.Random() > 0.5 then there is an exception. The exception message is displayed and the program terminates. If Math.Random() > 0.5 is false, then the second println statement runs as well

Using Loop Constructs

Question

Given:

Which two are possible outputs?

Exhibits

1Z0-803 question #14 exhibit 1
1Z0-803 question #14 exhibit 2

Options

  • AOption A
  • BOption B
  • COption C
  • DOption D

How the community answered

(33 responses)
  • A
    58% (19)
  • B
    27% (9)
  • C
    15% (5)

Explanation

The first println statement, System.out.println("Before if clause");, will always run. If Math.Random() > 0.5 then there is an exception. The exception message is displayed and the program terminates. If Math.Random() > 0.5 is false, then the second println statement runs as well. Incorrect answers: B: The second println statement would not run. C: The first println statement will always run.

Topics

#control flow#conditional logic#loop execution#program output

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice