Evaluate Code Segments with ArrayList Objects
Need Help? Check out these resources!
- Learn: Constructing an ArrayList Object
- Learn: Adding Values to an ArrayList Object
- Learn: Accessing and Removing Values from an ArrayList Object
- Learn: Changing Values in an ArrayList Object
- Learn: Analyzing an ArrayList Object
- Learn: Iterating Over an ArrayList Object
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.
Practice 6: Searching for a value
- Trace the provide code segment and predict the output.
- Verify your prediction is correct by running the code in the Java Playground.
Practice 7: Searching for a value
- Trace the provide code segment and predict the output.
- Verify your prediction is correct by running the code in the Java Playground.
Practice 8: Searching for a value
- Trace the provide code segment and predict the output.
- Verify your prediction is correct by running the code in the Java Playground.
- Add a statement to see if
countriescontains"England". Predict the output and verify by running the code.