
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
What is an ArrayList in Java?
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 Wayground
13 questions
Google Sheet Advanced

Quiz
•
University
10 questions
Exploring Abstract Data Types

Quiz
•
University
10 questions
Recordando JavaScript

Quiz
•
University
10 questions
Introduction to R for Data Science

Quiz
•
University
12 questions
أسئلة عن هياكل البيانات

Quiz
•
University
15 questions
Day -4 Workshop Quiz

Quiz
•
University
6 questions
Python

Quiz
•
University
15 questions
Boboiboy Galaxy season 1

Quiz
•
KG - Professional Dev...
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Other
10 questions
Would you rather...

Quiz
•
KG - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
10 questions
The Constitution, the Articles, and Federalism Crash Course US History

Interactive video
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
16 questions
Water Modeling Activity

Lesson
•
11th Grade - University
10 questions
ACT English prep

Quiz
•
9th Grade - University