Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(11) (5 points) What does the following codes display? impert java.uta. public class Test ( public static void main(Stringt) args) PriorityQueuecintegerz queue- new PriorityQueuecintegern Arrays.astist(6o,

image text in transcribed
image text in transcribed
(11) (5 points) What does the following codes display? impert java.uta. public class Test ( public static void main(Stringt) args) PriorityQueuecintegerz queue- new PriorityQueuecintegern Arrays.astist(6o, 10, so, 30, 40, 201 while (Iqueue.isEmptyl) System.out.print(queue.polld- a. The program displays 60 10 50 30 40 20 b. The program displays 60 50 40 30 20 10 c. This problem displays 10 30 50 20 40 60 d. The program displays 10 20 30 40 50 60 e. There is no guarantee that the program displays 10 20 30 40 50 60 f. This problem fails to compile (12) (6 points) What is the output of the following code? import java.util.. public class Sortcompare t public static void main(Stringt) args) ArrayList(); list.add (new Student ("Peter", 65)); list.add(new student ("Jll", 50)); list.add(new Student ("Sarah", 34)); Collections.sort (list); System.out.print(list + " "); Collections.sort(list, new StudentComparator1)) System.out.printin(list); static class StudentComparator1 implements Comparator public int compare(student s1, Student s2) return s1.name.compareTo(s2.name); static class Student implements Comparable String name; int age Student (String name, int age) t this.namename; this.age # age; public int compareTo(Student s)( return this.age s.age; public String tostring) ( return "["+name",age"I

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions