Complete the code to peek the front element of the queue without removing it.
int front = queue.[1]();pop() which is not a Queue method.poll() which removes the element.The peek() method returns the front element of the queue without removing it.
Complete the code to check if the queue is empty before peeking the front element.
if (!queue.[1]()) { int front = queue.peek(); }
isFull() which is not a standard Queue method.size() directly without comparison.The isEmpty() method checks if the queue has no elements.
Fix the error in the code to correctly peek the front element of the queue.
int front = queue.[1]();pop() which is for stacks.top() which is not a Queue method.The correct method to peek the front element in a Java Queue is peek().
Fill both blanks to create a safe peek operation that returns -1 if the queue is empty.
int front = queue.[1]() != null ? queue.[2]() : -1;
element() which throws exception if empty.poll() which removes the element.Using peek() twice safely checks and returns the front element or -1 if empty.
Fill both blanks to peek the front element safely and print it or print 'Empty' if queue is empty.
Integer front = queue.[1](); if (front == null) { System.out.println([2]); } else { System.out.println(front); }
element() which throws exception if empty.peek() returns null if empty, so we print "Empty" or the front element.
