wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

LinkedList Java

Total questions: 33

Worksheet time: 23mins

Name
Class
Date
1.

Linked list is generally considered as an example of _________ type of memory allocation.

a)

static

b)

compile time

c)

dynamic

d)

none of these

2.

In Linked list implementation, a node carries information regarding _______.

a)

Data

b)

Link

c)

Data and Link

d)

Node

3.

Linked list data structure usage offers considerable saving in

a)

Computational time

b)

Space utilization

c)

Space utilization and Computational time

d)

None of the above

4.

What is the time complexity to count the number of elements in the linked list?

a)

O(n)

b)

O(1)

c)

O(log n)

d)

None of the above

5.

Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only. Given the representation, which of the following operation can be implemented in O(1) time?


a. Insertion at the front of the linked list

b.Insertion at the end of the linked list

c.Deletion of the front node of the linked list

d. Deletion of the last node of the linked list

a)

a and c

b)

a and b

c)

b and d

d)

d and a

6.

The doubly linked list would have how many fields in a node?

a)

1

b)

2

c)

3

d)

4

7.

How many null pointers exists in a circular linked list?

a)

0

b)

1

c)

2

d)

3

8.

What is the condition to check whether linked

list is empty

a)

Head->next==Null

b)

Head->next->next==Null

c)

temp->next==Null

d)

Head==Null

9.

Which of these is a self-referential structure?

a)

Linked-List

b)

Array

c)

Node

d)

None of the above

10.

What would the next of the last node of a circular linked list return?

a)

head

b)

tail

c)

null

d)

none of the above

11.

What is the best and worst-case time complexity for searching for a value in a Linked List?

a)

O(1) and O(log n)

b)

O(1) and O(1)

c)

O(1) and O(n^2)

d)

O(1) and O(n)

12.

How do you insert an element at the beginning of the list?

a)

public void insertBegin(Node node)

{

node->next=head;

head = node;

}

b)

public void insertBegin(Node node)

{

head = node;

node->next=head;

}

c)

public void insertBegin(Node node)

{

head = node;

}

d)

None

13.

What type of linkedlist is represented in the image

a)

singly linkedlist

b)

doubly linkedlist

c)

circular singly linkedlist

d)

circular doubly linkedlist

14.

class Test {

public static void main(String args[]) {

int arr[2];

System.out.println(arr[0]);

System.out.println(arr[1]);

}

}

a)

0

0

b)

garbage value

garbage value

c)

Compiler Error

d)

Exception

15.

public class Main {

public static void main(String args[]) {

int arr[][] = new int[4][];

arr[0] = new int[1];

arr[1] = new int[2];

arr[2] = new int[3];

arr[3] = new int[4];

int i, j, k = 0;

for (i = 0; i < 4; i++) {

for (j = 0; j < i + 1; j++) {

arr[i][j] = k;

k++;

}

}

for (i = 0; i < 4; i++) {

for (j = 0; j < i + 1; j++) {

System.out.print(" " + arr[i][j]);

k++;

}

System.out.println();

}

}

}

a)

Compiler Error

b)

0

1 2

3 4 5

6 7 8 9

c)

0

0 0

0 0 0

0 0 0 0

d)

9

7 8

4 5 6

0 1 2 3

16.
Is LinkedList in Java LIFO or FIFO?
a)
a) Neither
b)
b) LIFO
c)
c) FIFO
d)
d) Both
17.
How does LinkedList work internally in Java?
a)
a) Single linked list, LIFO
b)
b) Doubly linked list, FIFO
c)
c) Circular linked list, FIFO
d)
d) Unidirectional list, LIFO
18.
Is LinkedList a Queue or list?
a)
a) Neither
b)
b) Only Queue
c)
c) Only list
d)
d) Both Queue and list
19.
Is LinkedList thread safe in Java?
a)
a) Yes
b)
b) No
c)
c) Depends on implementation
d)
d) Sometimes
20.
Where is linked list used in real life?
a)
a) Only in computer science
b)
b) Only in advanced data structures
c)
c) Various applications like browsers, music players
d)
d) Only in academic research
21.
Why is insertion faster in LinkedList?
a)
a) Less memory usage
b)
b) No resizing of array
c)
c) Direct memory access
d)
d) Better caching mechanisms
22.

What would be the time complexity of adding an element to the middle of a linked list?

a)

O(n)

b)

O(1)

c)

O(n^2)

d)

None of the above

23.

Which node’s data will be printed when


“temp =temp->next” is executed 3 times and the initial value of temp is temp=head

a)

Null

b)

9

c)

27

d)

46

24.

In the above image what will be printed when Head->next->data?

a)

83

b)

9

c)

27

d)

Error

25.

In the above image what will be printed when Head->next->next->data is displayed?

a)

83

b)

9

c)

27

d)

Error

26.

Which operation is not typically supported by a LinkedList in Java?

a)

Sorting the list in place

b)

Removing an element from the beginning

c)

Adding an element at the end

d)

Accessing an element by index

27.

When an ArrayList in Java reaches its capacity and you add one more element, which of the following best describes what happens internally?

a)

Java simply allocates one extra slot in the same array.

b)

The old array is extended in place without reallocation.

c)

A new array is created (1.5× old size), elements are copied, and reference is updated.

d)

A linked list node is appended to the current structure.

28.

Element Removal — Hidden Cost

Consider:

List<Integer> list = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5));

list.remove(2);

What happens internally when remove(2) is called?

a)

Element at index 2 is nullified; array size remains same.

b)

Element at index 2 is removed; subsequent elements are shifted left.

c)

The entire array is reallocated.

d)

The operation is O(1) as it just changes a pointer.

29.

Random Access & Iterator Behavior

You have:

List<String> list = new LinkedList<>(List.of("A", "B", "C", "D")); list.get(3);

Which statement is true?

a)

Operation executes in O(1) as LinkedList supports direct indexing.

b)

It traverses nodes from head to index 3 sequentially — O(n).

c)

It converts to an array internally for faster access.

d)

The call fails at runtime because LinkedList doesn’t implement List.

30.

You’re designing a playlist manager where songs are often added and removed from the middle of the list. Occasional random access is needed but not frequent.
Which data structure gives the best balance?

a)

Array

b)

ArrayList

c)

LinkedList

d)

Vector

31.

Which of the following correctly reverses a singly linked list iteratively and returns the new head?

a)

b)

c)

d)

32.

Which of the following recursive functions correctly reverses a singly linked list and returns the new head?

a)

ListNode reverse(ListNode head) {

if (head == null || head.next == null)

return head;

ListNode rest = reverse(head.next);

head.next.next = head;

head.next = null;

return rest;

}

b)

ListNode reverse(ListNode head) {

if (head == null)

return null;

head.next = reverse(head.next);

return head;

}

c)

ListNode reverse(ListNode head) {

if (head.next == null)

return null;

ListNode temp = head.next;

temp.next = head;

return temp;

}

d)

ListNode reverse(ListNode head) {

while (head != null) {

ListNode next = head.next;

head.next = null;

head = next;

}

return head;

}

33.

Output?

a)

1 2 3 4

b)

4 3 2 1

c)

1 3 2 4

d)

Compilation error