Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Which of the following correctly declares an ArrayList? (3 points) ArrayList aList = new ArrayList (10); ArrayList aList = new ArrayList (); ArrayList aList

1.

Which of the following correctly declares an ArrayList? (3 points)

  1. ArrayList aList = new ArrayList (10);
  2. ArrayList aList = new ArrayList ();
  3. ArrayList aList = new ArrayList (10);
I only
II only
III only
I and II only
II and III only

2.

Assume aList is a valid ArrayList containing the following string values: apple, orange, grape, kiwi, watermelon, peach, banana When the following statement executes, what does aList contain? (3 points) aList.set(1, "raspberry");

apple, orange, grape, kiwi, watermelon, peach, banana
apple, raspberry, grape, kiwi, watermelon, peach, banana
apple, raspberry, orange, grape, watermelon, peach, banana
raspberry, orange, grape, kiwi, watermelon, peach, banana
raspberry, apple, orange, grape, kiwi, watermelon, peach, banana

3.

Assume aList is a valid ArrayList containing the following values: 3, 95, 86, 11, 18, 42, 73 Which of the following places 55 immediately before 42 in aList? (3 points)

aList.add(55);
aList.add(5, 55);
aList.add(6, 55);
aList.add(42, 55);
aList.add(55, 6);

4.

Assume aList is a valid ArrayList containing the following: purple, red, blue, yellow, green, pink, black, gold Which of the following removes blue from aList? (3 points)

  1. aList.remove(2, "blue");
  2. aList.remove("blue");
  3. aList.remove("blue", 2);
I only
II only
III only
I and II only
II and III only

5.

What is the size of theArrayList aList after the following code segment is executed? (3 points) ArrayList aList = new ArrayList (3); aList.add(3.5); aList.add(4.3); aList.add(1, 12.3); aList.set(2, 18.9); aList.add(42.6); aList.set(0, 20.3); aList.remove(3); aList.add(24.8);

3
4
7
9
An IndexOutOfBoundsException error occurs

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

The location of the neuro centre activity of the heart is.......?

Answered: 1 week ago