A.2 Chapter 2: Working with Java data types

Chapter 2 includes four Twist in the Tale exercises. Twist in the Tale 2.1 has two parts.

A.2.1 Twist in the Tale 2.1 (part 1)

Purpose: By default, System.out.println() will print out a number in its decimal base. It does so regardless of the base number system that you use to initialize a number.

Answer: The code prints the following output:

534
534

Explanation: Often programmers are tricked by similar questions. If a variable is assigned a value using 0b100001011 (a number in the binary number system), a programmer might believe that System.out.println() will print out numbers in the binary number system, which is incorrect. By default, System.out.println() will print out a number in its decimal base. ...

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.