nerdexam
Oracle

1Z0-803 · Question #46

Given the code fragment: What is the result?

The correct answer is C. Compilation fails. In segment 'if (valid)' valid must be of type boolean, but it is a string. This makes the compilation fail.

Java Basics

Question

Given the code fragment:

What is the result?

Options

  • AValid
  • Bnot valid
  • CCompilation fails
  • DAn IllegalArgumentException is thrown at run time

How the community answered

(59 responses)
  • A
    3% (2)
  • B
    2% (1)
  • C
    86% (51)
  • D
    8% (5)

Explanation

In segment 'if (valid)' valid must be of type boolean, but it is a string. This makes the compilation fail.

Topics

#compilation errors#syntax rules#type compatibility

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice