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

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

Want to excel in Java? Test your knowledge with our ultimate quiz based on 'Thinking in Java'. Engage with multiple-choice questions and in-depth explanations. Boost your understanding and prepare for your exam with confidence.

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.


What is returned by the 'compete()' method in the 'RoShamBo' example?

  1. An integer indicating the result

  2. An enum instance NEW, LOSE, or DRAW

  3. An enum instance WIN, LOSE, or DRAW

  4. A boolean value

The correct answer is: An enum instance WIN, LOSE, or DRAW

The 'compete()' method in the 'RoShamBo' example returns an enum instance indicating whether the player won, lost, or tied the game. Option A is incorrect because it suggests that an integer value is returned, which would not make sense for a game that has more than two possible outcomes. Option B is also incorrect because the 'ROCK, PAPER, SCISSORS' enum is used to represent the choices, not the result. Option D is incorrect because a boolean value would not be able to accurately represent all the possible outcomes in the game. Therefore, option C is the correct and most logical answer.