Solved

Assuming That Names Is a Queue of String Objects, Select

Question 5

Multiple Choice

Assuming that names is a Queue of String objects, select a statement to complete the code segment below. The code is designed to remove the last element from the queue, which is guaranteed to have at least one element. Queue<String> aQueue = new LinkedList<String>() ;
While (names.size() > 1)
{
AQueue.add(names.remove() ) ;
}
Names.remove() ;
While (aQueue.size() > 0)
{
____________________________
}


A) names.add(aQueue.remove() ) ;
B) names.add(aQueue.peek() ) ;
C) aQueue.add(names.remove() ) ;
D) aQueue.add(names.peek() ) ;

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions