Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Master your knowledge of Java programming with our immersive quiz based on 'Thinking in Java'. Test your skills with detailed questions and receive hints and explanations to enhance your learning. Get ready to ace your Java exam!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which method do you use to access elements in an ArrayList?

  1. get(int index)

  2. access(int index)

  3. elementAt(int index)

  4. indexOf(Object o)

The correct answer is: get(int index)

The method used to access elements in an ArrayList is get(int index). Option A is correct because it is the actual method that is used to retrieve the element at the specified index in an ArrayList. Option B is incorrect because there is no method called access in the ArrayList class. Option C is incorrect because elementAt() is a method used for accessing elements in a Vector, not in an ArrayList. Option D is incorrect because indexOf() is used to find the index of a specified element, not to access an element.