Question
Consider the following Java code snippet: Â Â
import java.util.PriorityQueue; Â Â public class HeapQuestion5 { Â Â Â Â public static void main(String[] args) { Â Â Â Â Â Â PriorityQueue pq = new PriorityQueue(); Â Â Â Â Â Â pq.add("apple"); Â Â Â Â Â Â pq.add("banana"); Â Â Â Â Â Â pq.add("cherry"); Â Â Â Â Â Â System.out.println(pq.peek()); Â Â Â Â Â Â System.out.println(pq.size()); Â Â Â Â Â Â System.out.println(pq.peek()); Â Â Â Â } Â Â } Â Â What will be the output of this program?Solution
PriorityQueue for String uses natural ordering (alphabetical) by default, making it a min-heap.   1. pq.add("apple"); pq.add("banana"); pq.add("cherry");     The elements are added. "apple" is the smallest alphabetically.   2. System.out.println(pq.peek());     peek() retrieves the head of the queue (the highest-priority element) *without removing it*. So, "apple" is printed.   3. System.out.println(pq.size());     The size of the queue is still 3, as peek() does not remove elements. So, 3 is printed.   4. System.out.println(pq.peek());     Again, peek() retrieves the head without removal. "apple" is still the head. So, "apple" is printed.   Therefore, the output is apple, 3, apple.
Which document shows changes in equity during the reporting period?
As per Ind AS 1, an entity must present a Statement of Changes in Equity (SOCIE) to show:
ABC Ltd. follows Ind AS and presents its balance sheet as per Schedule III of the Companies Act. The company receives ₹5 crore from the issue of deben...
Which of the following best explains the purpose of notes to accounts in financial statements?
Which of the following is not shown in the statement of profit and loss under Ind AS?
As per Ind AS 1, comprehensive income includes:
XYZ Ltd. classifies bank overdraft under 'Cash and Cash Equivalents' in the balance sheet. The overdraft is repayable on demand and regularly fluctuates...
Select the most appropriate ANTONYM of the given word.
Perilous
In the context of a company, calls-in-arrears is shown:
As per Schedule III of the Companies Act, 2013, which is NOT a part of the financial statements?