What is an ArrayList in Java?

Core Java Quiz - 2

Quiz
•
Other
•
University
•
Medium

Gnaneshwar Reddy
Used 3+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A fixed-size array
A resizable array
A linked list
A map data structure
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How is memory allocated for elements in an ArrayList?
Elements are stored in a continuous block of memory
Elements are stored in separate memory locations
Elements are stored in a binary tree structure
Memory allocation depends on the ArrayList's size
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How does the ArrayList differ from a regular array in Java?
ArrayLists can hold primitive data types, while arrays cannot
ArrayLists are dynamically resizable, while arrays have a fixed size
ArrayLists are faster for element access compared to arrays
ArrayLists cannot store objects, only arrays can
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What's the initial capacity of an ArrayList, and what happens if you exceed this capacity?
Initial capacity is 0, and exceeding it results in an exception
Initial capacity is 10, and exceeding it causes the ArrayList to automatically resize
Initial capacity is based on the size of the first element, and exceeding it causes a compile error
Initial capacity is unlimited, and exceeding it causes a memory overflow
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you add an element to an ArrayList?
Using the addElement() method
Using the add() method
Using the insert() method
Using the push() method
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the below ArrayList program?
import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(String[] args) {
ArrayList<String> al = new ArrayList<String>();
al.add("A");
al.add("B");
al.add("A");
al.add(null);
System.out.println(al);
}
}
Compile time error
[A, B, null]
[A, B]
[A, B, A, null]
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Find the output of the below ArrayList program?
import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(String[] args) {
List<String> al1 = new ArrayList<String>();
al1.add("A");
al1.add("B");
List<String> al2 = new ArrayList<String>();
al2.add("P");
al2.add("Q");
al1.addAll(al2);
System.out.println(al1);
}
}
[A, B]
[P, Q]
[A, B, P, Q]
[P, Q, A, B]
Create a free account and access millions of resources
Similar Resources on Quizizz
15 questions
C Quiz

Quiz
•
University
15 questions
Object Oriented Programming

Quiz
•
University
9 questions
Prova POO

Quiz
•
University
13 questions
Google Sheet Advanced

Quiz
•
University
14 questions
2R C-Skill Lab Test Autumn 2024-25

Quiz
•
University
10 questions
Stack Data Structure

Quiz
•
University
15 questions
AlgoWhiz Quiz

Quiz
•
University
10 questions
Test de JavaScript

Quiz
•
University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade