QuestionQ197

Handling Exceptions

Consider the following:

Question Image

What is the result?

  • A True false
  • B True null
  • C Compilation fails
  • D A NullPointerException is thrown at runtime
Explanation

Boolean.parseBoolean("true") produces true. The Boolean(String) constructor creates a Boolean representing false when the supplied string is null, so no NullPointerException occurs. Boolean string representations are lowercase; the output is true false. Choice A is the intended matching option despite its capitalization. Oracle Boolean API

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!