What is the functionality of the following piece of code? [code] public int function() { Node temp = tail.getPrev(); tail.setPrev(temp.getPrev

Trần Vũ

New member
What is the functionality of the following piece of code?
Code:
public int function()
{
	Node temp = tail.getPrev();
	tail.setPrev(temp.getPrev());
	temp.getPrev().setNext(tail);
	size--;
	return temp.getItem();
}
A. Return the element at the tail of the list but do not remove it
B. Return the element at the tail of the list and remove it from the list
C. Return the last but one element from the list but do not remove it
D. Return the last but one element at the tail of the list and remove it from the list
 
Answer: B
Explanation: The previous and next pointers of the tail and the last but one element are manipulated, this suggests that the last node is being removed from the list.
 

Tìm kiếm

Back
Top