nerdexam
Oracle

1Z0-851 · Question #270

Given: public void testIfA() { if (testIfB("True")) { System.out.println("True"); } else { System.out.println("Not true"); } } public Boolean testIfB(String str) { return Boolean.valueOf(str); }…

The correct answer is A. True. See the full explanation below for the reasoning.

Question

Given: public void testIfA() { if (testIfB("True")) { System.out.println("True"); } else { System.out.println("Not true"); } } public Boolean testIfB(String str) { return Boolean.valueOf(str); } What is the result when method testIfA is invoked?

Options

  • ATrue
  • BNot true
  • CAn exception is thrown at runtime.
  • DCompilation fails because of an error at line 12.
  • ECompilation fails because of an error at line 19.

How the community answered

(25 responses)
  • A
    76% (19)
  • C
    12% (3)
  • D
    4% (1)
  • E
    8% (2)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice