Core Java Quiz - 2

Core Java Quiz - 2

University

10 Qs

quiz-placeholder

Similar activities

Java Programming Quiz

Java Programming Quiz

University

13 Qs

c set 3

c set 3

University

10 Qs

2R C-Skill Lab Test Autumn 2024-25

2R C-Skill Lab Test Autumn 2024-25

University

14 Qs

Struktur Data

Struktur Data

University

12 Qs

Python Basics

Python Basics

University

11 Qs

Coding Challenge Round 1

Coding Challenge Round 1

University

10 Qs

Stack Data Structure

Stack Data Structure

University

10 Qs

QUIZ3:-DATA STRUCTURE

QUIZ3:-DATA STRUCTURE

University

10 Qs

Core Java Quiz - 2

Core Java Quiz - 2

Assessment

Quiz

Other

University

Medium

Created by

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

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?