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

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

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

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.