Exploring ArrayList Techniques and Strategies

Exploring ArrayList Techniques and Strategies

12th Grade

14 Qs

quiz-placeholder

Similar activities

Python Fundamentals and Programming

Python Fundamentals and Programming

11th - 12th Grade

13 Qs

Web Design- HTML Review

Web Design- HTML Review

KG - University

17 Qs

Pre Test Kelas Pemograman WEB

Pre Test Kelas Pemograman WEB

1st - 12th Grade

10 Qs

Ish

Ish

KG - Professional Development

10 Qs

Quiz 1. Data Structures (OSTIM 2022)

Quiz 1. Data Structures (OSTIM 2022)

1st - 12th Grade

12 Qs

Java Lesson 4

Java Lesson 4

5th Grade - University

10 Qs

Pythton

Pythton

5th - 12th Grade

10 Qs

Exploring ArrayList Techniques and Strategies

Exploring ArrayList Techniques and Strategies

Assessment

Quiz

Other

12th Grade

Medium

Created by

Mouna Boutemine

Used 2+ times

FREE Resource

14 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following methods is used to add an element at a specific index in an `ArrayList` in Java?

`addElement(int index, E element)`

`insert(int index, E element)`

`add(int index, E element)`

`put(int index, E element)`

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider an `ArrayList list` with elements `["apple", "banana", "cherry"]`. What will be the output after executing the following code? ```java list.set(1, "blueberry"); ```

`["apple", "blueberry", "cherry"]`

`["apple", "banana", "blueberry"]`

`["blueberry", "banana", "cherry"]`

`["apple", "cherry", "blueberry"]`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method would you use to remove all elements from an `ArrayList` in Java?

`clear()`

`removeAll()`

`deleteAll()`

`empty()`

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given an `ArrayList numbers` initialized with `[1, 2, 3, 4, 5]`, which of the following code snippets correctly iterates through the list and prints each element?

for (int i = 0; i < numbers.size(); i++) { System.out.println(numbers.get(i)); } ```

for (Integer num : numbers) { System.out.println(num); } ```

while (i<= numbers.size() -1 ) { System.out.println(number.get(i)); } ```

All of the above

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If you want to check whether an `ArrayList` contains a specific element, which method would you use?

`containsElement(Object o)`

`has(Object o)`

`contains(Object o)`

`exists(Object o)`

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the result of the following code snippet? ```java ArrayList fruits = new ArrayList<>(Arrays.asList("apple", "banana", "cherry")); fruits.remove("banana"); System.out.println(fruits); ```

`["apple", "banana", "cherry"]`

`["apple", "cherry"]`

`["banana", "cherry"]`

`["apple", "banana"]`

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements about `ArrayList` is true?

`ArrayList` is synchronized.

`ArrayList` can store primitive data types directly.

`ArrayList` allows duplicate elements.

`ArrayList` has a fixed size.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?