ArrayLists

ArrayLists

University

7 Qs

quiz-placeholder

Similar activities

PFP191 (Part 5)

PFP191 (Part 5)

University

10 Qs

Array

Array

University

12 Qs

Algorithm : Introduction

Algorithm : Introduction

University

5 Qs

Java Basics

Java Basics

University

10 Qs

Coding - Advanced Level

Coding - Advanced Level

8th Grade - Professional Development

11 Qs

System Design

System Design

University

10 Qs

List

List

University

10 Qs

Stack

Stack

University

10 Qs

ArrayLists

ArrayLists

Assessment

Quiz

Computers

University

Medium

Created by

Maddie Mihevc

Used 16+ times

FREE Resource

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