Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


How does the 'Conversion' example output 'true' for variable 'z' when using the 'b' conversion?

  1. Because 'z' is non-null and not boolean type

  2. Because 'z' is a boolean with true value

  3. Because 'z' is a null reference

  4. Because 'z' has a numeric value of zero

The correct answer is: Because 'z' is a boolean with true value

The reason why the other choices are incorrect is because A: Since the 'b' conversion only looks at the existence of a value and not the data type, the boolean type of 'z' is irrelevant. C: Since 'z' is assigned a value of 'true' and not null, it cannot be a null reference. D: The numeric value of 'z' is not used in this conversion, only the boolean value. Therefore, 'z' can have any numeric value and still output 'true'.