Solved

Insert the Missing Code in the Following Code Fragment

Question 1

Multiple Choice

Insert the missing code in the following code fragment. This fragment is intended to remove a node from the head of a linked list:
Public class LinkedList
{
) . .
Public Object removeFirst()
{
If (first == null) { ________________ }
Object element = first.data;
First = first.next; 1
Return element;
}
) . .
}


A) throw new NoSuchElementException() ;
B) throw new IllegalStateException() ;
C) throw new NullPointerException() ;
D) throw new IllegalArgumentException() ;

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