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)- A76% (19)
- C12% (3)
- D4% (1)
- E8% (2)
Community Discussion
No community discussion yet for this question.