Solved

Insert the Missing Code in the Following Code Fragment

Question 3

Multiple Choice

Insert the missing code in the following code fragment. This fragment is intended to add a new node to the head of a linked list:
Public class LinkedList
{
) . .
Public void addFirst(Object element)
{
Node newNode = new Node() ; 1
NewNode.data = element;
_________ 2
_________ 3
}
) . .
}


A) first = newNode;
NewNode.next = first;
B) newNode.next = first;
First = newNode;
C) first = newNode.next;
NewNode.next = first;
D) first = newNode.next;
NewNode = first;

Correct Answer:

verifed

Verified

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents