A.5 Chapter 5: Flow control

Chapter 5 includes four Twist in the Tale exercises.

A.5.1 Twist in the Tale 5.1

Purpose: To emphasize multiple points:

  • A variable of any type can be (re)assigned a value in an expression used in an if condition.
  • if-else-if statements execute each if condition as control is passed to them, changing the value of any variable that’s manipulated in the evaluation of the expression.
  • An expression used in an if condition should evaluate to a boolean value.

Answer: f

Explanation: The flow of execution of code statements in this exercise is shown in figure A.4.

Figure A.4. Flow of execution of code in Twist in the Tale 5.1

The arrows on the left in figure A.4 show the flow of execution of statements for this code snippet. ...

Get OCA Java SE 8 Programmer I Certification Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.