Self-Review Exercises

We encourage you to use JShell to do Exercises 25.125.43 after reading Sections 25.325.4. We’ve included the answers for all these exercises to help you get comfortable with JShell/REPL quickly.

  1. 25.1 Confirm that when you use System.out.println to display a String literal, such as "Happy Birthday!", the quotes ("") are not displayed. End your statement with a semicolon.

  2. 25.2 Repeat Exercise 25.1, but remove the semicolon at the end of your statement to demonstrate that semicolons in this position are optional in JShell.

  3. 25.3 Confirm that JShell does not execute a // end-of-line comment.

  4. 25.4 Show that an executable statement enclosed in a multiline comment—delimited by /* and */—does not execute.

  5. 25.5 Show what happens ...

Get Java How To Program, Late Objects, 11th 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.