Skip Top Navigation Bar

Evaluate Code Segments with Two-dimensional Array Creation and Access

Evaluating Expressions

Grab a Piece of Paper!

Evaluate each expression.

Verify your answer by running the code in the Java Playground.

Practice 1: Two-Dimensional Array with Initializer List

  • Trace the provide code segment and predict the output.
  • Verify your prediction is correct by running the code in the Java Playground.
  • Add output statements to print the value in the upper left corner and lower right corner of the 2D array. Use the length constant to compute the lower right corner.
  • Run the code to verify your statements are correct.

Practice 2: Jagged Two-Dimensional Array

  • Trace the provide code segment and predict the output.
  • Verify your prediction is correct by running the code in the Java Playground.

Practice 3: Initial Values

  • Trace the provide code segment and predict the output.
  • Verify your prediction is correct by running the code in the Java Playground.
  • Modify the code to make the 2D array be of type double. Predict the output and run the code to check.