Search Header Logo

ArrayLists

Authored by Maddie Mihevc

Computers

University

Used 16+ times

ArrayLists
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If we have an ArrayList instruction with the element “Stop” at index 5, how do we change the string at 5 to “Go”?

list.add(5, "Go")

list.add(4, "Go")

list.set(5, "Go")

list.set(4, "Go")

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You can use the set method to place an element in a list at any index you want

true

false

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You can use the add method to place an element in a list at any index you want

true

false

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If aList is an object of the class ArrayList<String> that contains four strings “red”, “blue”, “green”, and “yellow”, what is the order of the strings on the list after aList.add(2, “orange”); ?

{“red”, “blue”, “orange”, “green”, “yellow”}

{“red”, “orange”, “blue”, “green”, “yellow”}

{“red”, “blue”, “green”, “orange”, “yellow”}

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If you create a list using

ArrayList<Double> doubleList = new ArrayList<Double>(20);

can the list contain more than 20 elements?

Yes because capacity isn't fixed

No because capacity is fixed

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you decrease the current capacity to the current size?

trimToSize()

clear()

trim()

decreaseCapacity()

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the difference between ArrayList size and capacity?

size is the number elements in the list while capacity is the maximum number of elements it can hold without resizing

capacity is the number elements in the list while size is the maximum number of elements it can hold without resizing

both represent the number of elements in the list

both represent the number of elements the list can hold before resizing

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers