A browser with JavaScript enabled is required for this page to operate properly.
Documentation

The Java™ Tutorials
Trail: Learning the Java Language
Lesson: Language Basics
Home Page > Learning the Java Language > Language Basics
« PreviousTOC

The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.
See Dev.java for updated tutorials taking advantage of the latest releases.
See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.

Answers to Questions and Exercises: Expressions, Statements, and Blocks

Questions

  1. Operators may be used in building expressions, which compute values.
  2. Expressions are the core components of statements.
  3. Statements may be grouped into blocks.
  4. The following code snippet is an example of a compound expression.
     1 * 2 * 3
    
  5. Statements are roughly equivalent to sentences in natural languages, but instead of ending with a period, a statement ends with a semicolon.
  6. A block is a group of zero or more statements between balanced braces and can be used anywhere a single statement is allowed.

Exercises

Identify the following kinds of expression statements:

  • aValue = 8933.234; // assignment statement
  • aValue++; // increment statement
  • System.out.println("Hello World!"); // method invocation statement
  • Bicycle myBike = new Bicycle(); // object creation statement
« PreviousTOC

Previous page: Questions and Exercises: Expressions, Statements, and Blocks

AltStyle によって変換されたページ (->オリジナル) /