Question

(1) (5 points) What does the following codes display? import java.util.; public class Test public static void main(Stringl) a

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:-

OPTION (d) the program display 10 20 30 40 50 60

import java.util.*;

class Test
{
   public static void main (String[] args) throws java.lang.Exception
   {
       PriorityQueue<Integer>queue=new PriorityQueue<Integer>(
           Arrays.asList(60,10,50,30,40,20));
       while(!queue.isEmpty())
       System.out.print(queue.poll()+" ");
   }
}

// OUTPUT

Success #stdin #stdout 0.05s 21841 92KB 10 20 30 40 50 60

Add a comment
Know the answer?
Add Answer to:
(1) (5 points) What does the following codes display? import java.util.; public class Test public static...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What is output 1 in the code below? import java.util."; public class StackDemo { public static...

    What is output 1 in the code below? import java.util."; public class StackDemo { public static void main(String [] args) { Stack<Integer> intStack = new Stack<>(); Stack<Integer> tempStack = new Stack<>(); intStack.push(18); intStack.push(21); intStack.push(25); tempStack = intStack; while (!tempStack.empty() { System.out.print(tempStack.peek()+"");//output 1 tempStack.pop(); 3 System.out.println(); System.out.println(intStack.peek()); //output 2 25 18 21 • 25 21 18

  • Given 5. import java.util. 6. public class Sortof 7. public static void main(Stringl args) [ 8. ArrayList Integer> anew ArrayList Integer 0 9. a.add(1); а.add(5); a.add(3); 11. Collections.sort(a)...

    Given 5. import java.util. 6. public class Sortof 7. public static void main(Stringl args) [ 8. ArrayList Integer> anew ArrayList Integer 0 9. a.add(1); а.add(5); a.add(3); 11. Collections.sort(a) 12. a.add(2); 13. Collections.reverse(a) 14. System.out.printin (a) 15 16 What is the result? B. 12, 1, 3, 5] C. 12, 5, 3, 1] E. [1, 3, 5, 2 F. Compilation fails G. An exception is thrown at runtime Given 5. import java.util. 6. public class Sortof 7. public static void main(Stringl args)...

  • # Java import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; public class Test extends Application {...

    # Java import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; public class Test extends Application {   @Override // Override the start method in the Application class   public void start(Stage primaryStage) {     // Create a button and place it in the scene     Button btOK = new Button("OK");     btOK.setOnAction(e -> System.out.println("OK 1"));     btOK.setOnAction(e -> System.out.println("OK 2"));     Scene scene = new Scene(btOK, 200, 250);     primaryStage.setTitle("MyJavaFX"); // Set the stage title     primaryStage.setScene(scene); // Place the scene in the stage     primaryStage.show(); // Display the stage...

  • Provide comments for this code explaining what each line of code does import java.util.*; public class...

    Provide comments for this code explaining what each line of code does import java.util.*; public class Chpt8_Project {    public static void main(String[] args)       {        Scanner sc=new Scanner(System.in);        int [][]courses=new int [10][2];        for(int i=0;i<10;i++)        {            while(true)            {                System.out.print("Enter classes and graduation year for student "+(i+1)+":");                courses[i][0]=sc.nextInt();                courses[i][1]=sc.nextInt();                if(courses[i][0]>=1...

  • I need a java flowchart for the following code: import java.util.*; public class Main {   ...

    I need a java flowchart for the following code: import java.util.*; public class Main {    public static void main(String[] args) {    Scanner sc=new Scanner(System.in);           System.out.print("Enter the input size: ");        int n=sc.nextInt();        int arr[]=new int[n];        System.out.print("Enter the sequence: ");        for(int i=0;i<n;i++)        arr[i]=sc.nextInt();        if(isConsecutiveFour(arr))        {        System.out.print("yes the array contain consecutive number:");        for(int i=0;i<n;i++)        System.out.print(arr[i]+" ");       ...

  • 1: import java.util.*; 2: class Test 3: { 4: public static void main(String[] args) 5: {...

    1: import java.util.*; 2: class Test 3: { 4: public static void main(String[] args) 5: { 6: ArrayList<Object> list = new ArrayList<Object>(); 7: list.add("First Element"); 8: list.add(new Integer(12)); 9: String str = (String) list.get(0); 10: String str2 = (String)list.get(1); 11: } 12: } There is a run time error on which line number? A) Line 9 B) Line 7 C) No errors D) Line 8 E) Line 10 in Java

  • What is the output of the following question? import java.io.IOException; import java.util. EmptyStackException: public class newclass...

    What is the output of the following question? import java.io.IOException; import java.util. EmptyStackException: public class newclass public static void main(String[] args) try System.out.printf("%d", 1); throw (new Exception()); catch (IOException e) System.out.printf("%d", 2); catch(EmptyStackException e) System.out.printf("%d", 3); catch(Exception e) System.out.printf("%d", 4); } finally System.out.printf("%d", 5); Q3) (15 points) a.Write a JAVA program that reads an arra JAVA program that reads an array from input file and invo Sort and Max ,that sorts the elements of the array and s the elements...

  • What is the output of the following codes? Line1: public class ArrayLength { Line2: public static...

    What is the output of the following codes? Line1: public class ArrayLength { Line2: public static void main(String args[]) { Line 3: int a[] = {45, 44, 39, 48, 37); Line 4: System.out.print(a.length()); Line5: Line 6: } w Compiling error Oo 05 04

  • 7. Consider the following recursive function: package javaapplication293; public class JavaApplication293 public static void main Stringl...

    7. Consider the following recursive function: package javaapplication293; public class JavaApplication293 public static void main Stringl args) recFun(7) public static void recFun int u) if (-= 1 ) System.out. print("Stop! "); else System.out.print("Go "); recFun(u-1);

  • What is the output of the following code? public class Test { pub be static void...

    What is the output of the following code? public class Test { pub be static void main(String() args) { Object o 1 -new Object(); Object o2 = new Object(); System out.print((o1 = o2) + "" + (o1 equals(o2))); } } A. false false B. true true C. false true D. true false Analyze the following code. //Program 1: public class Test { public static void main(String[] args) { Object circle 1 = new Circle(); Object circle2 = new Circle(); System...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT