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

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

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

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.