
Core Java Quiz - 2
Authored by Gnaneshwar Reddy
Other
University
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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]
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
11 questions
The year 2021
Quiz
•
7th Grade - University
13 questions
General knowledge
Quiz
•
3rd Grade - Professio...
15 questions
HSSE Lecture 1, 2 & 3
Quiz
•
University
10 questions
renewable energy
Quiz
•
University
10 questions
CS QUIZ ON ELECTRICAL ANALOGIES OF MECH.SYS 10/08/2020
Quiz
•
University
10 questions
MIDTERM TEST SSD ETHICS CH7
Quiz
•
University
10 questions
O-Week Quiz
Quiz
•
University
12 questions
Intro C++
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
Discover more resources for Other
12 questions
IREAD Week 4 - Review
Quiz
•
3rd Grade - University
23 questions
Subject Verb Agreement
Quiz
•
9th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
7 questions
Renewable and Nonrenewable Resources
Interactive video
•
4th Grade - University
5 questions
Poetry Interpretation
Interactive video
•
4th Grade - University
19 questions
Black History Month Trivia
Quiz
•
6th Grade - Professio...
15 questions
Review1
Quiz
•
University
15 questions
Pre1
Quiz
•
University