Java ArrayList Add Method: Code & Examples


Choose an answer and hit 'next'. You will receive your score and answers at the end.

question 1 of 3

Which of the following correctly inserts the integer value 247 into the third element of the ArrayList pCode?

Create Your Account To Take This Quiz

As a member, you'll also get unlimited access to over 79,000 lessons in math, English, science, history, and more. Plus, get practice tests, quizzes, and personalized coaching to help you succeed.

Try it risk-free
Try it risk-free for 30 days. Cancel anytime
Already registered? Log in here for access

1. Examine the following code. What is the add function doing?

2. What happens when you add an item to an existing ArrayList, without specifying an index?

Create your account to access this entire worksheet
A Premium account gives you access to all lesson, practice exams, quizzes & worksheets
Access to all video lessons
Quizzes, practice exams & worksheets
Certificate of Completion
Access to instructors
Create an account to get started Create Account

About This Quiz and Worksheet

For this quiz and worksheet combo, you are working with ArrayList in Java and its add method. Questions test you on the correct insertion of an integer into a specific element, as well as what is missing from a sample piece of code.

Quiz and Worksheet Goals

You can expect to find the topics mentioned below in the questions for this quiz:

  • The use of the add function in a given line of code
  • Adding an item to an ArrayList without specifying an index
  • The function of a given piece of code
  • What is missing from a given piece of code

Skills Practiced

  • Information recall - remember what you have learned about the function of ArrayList
  • Making connections - use what you've learned about ArrayList to explain what happens when you add an item to an ArrayList without specifying an index
  • Knowledge application - use what you know to answer questions about sample pieces of code

Additional Learning

For more practice, open the lesson titled Java ArrayList Add Method: Code & Examples. Inside, you can locate the additional material highlighted below:

  • Initializing an ArrayList
  • The process of adding elements to an array
  • Examples of arrays and their uses