Quiz

Review today's material by taking this three-question quiz.

Questions

1: Which of the following is a valid value for a boolean variable?
  1. "false"

  2. false

  3. 10

2: Which of these conventions is not used when naming variables in Java?
  1. Each successive word after the first in the variable name begins with a capital letter.

  2. The first letter of the variable name is lowercase.

  3. All letters are capitalized.

3: Which of these data types holds numbers from -32,768 to 32,767?
  1. long

  2. byte

  3. int

Answers

1: Which of the following is a valid value for a boolean variable?
  1. "false"

  2. false

  3. 10

A1: b. In Java, a boolean can only be true or false . If you put quotation marks around the value, it will be treated like a String rather than one of the two ...

Get Sams Teach Yourself Java 2 in 21 Days, Second Edition 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.