Skip Top Navigation Bar

Evaluate Code Segments with ArrayList Objects

Evaluating Expressions

Grab a Piece of Paper!

Evaluate each expression.

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

Practice 1: Managing a Guest List

  • Trace the provide code segment and predict the output.
  • Verify your prediction is correct by running the code in the Java Playground.
  • Add the following guests to the list: "Heather", "Chad", and "Ana" and print the ArrayList.
  • Predict the output of your code segment and then run it in the Java Playground to test your prediction.

Practice 2: Animal List

  • Trace the provide code segment and predict the output.
  • Verify your prediction is correct by running the code in the Java Playground.
  • Remove "cat" from the list and add "horse" to the beginning of the list.
  • Predict the output and verify your prediction by running the code in the Java Playground.

Practice 3: Add Numbers

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

Practice 4: Changing Numbers

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

Practice 5: Remove Numbers

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