Java Multiple Choice Question MCQ

Categories: Java MCQ

What may output for following  list is 

    

Collections.sort(list);

            while(i.hasNext())

        System.out.print(i.next() + " ");

        }

    }


a) 1 2 5 8

b) 2 1 8 5

c) 1 5 8 2

d) 2 8 5 1

Answer: a


18. Which of these statements is incorrect about Thread?

a) start() method is used to begin execution of the thread

b) run() method is used to begin execution of a thread before start() method in special cases

c) A thread can be formed by implementing Runnable interface only

d) A thread can be formed by a class that extends Thread class

Answer: b


19. Which of these keywords are used for the block to be examined for exceptions?

a) check

b) throw

c) catch

d) try

Answer: d


20. What will be the output of the following Java code?


    class newthread extends Thread

    {

Thread t;

newthread()

        {

    t1 = new Thread(this,"Thread_1");

    t2 = new Thread(this,"Thread_2");

    t1.start();

    t2.start();

}

public void run()

        {

    t2.setPriority(Thread.MAX_PRIORITY);

    System.out.print(t1.equals(t2));

        }    

    }

    class multithreaded_programing

    {

        public static void main(String args[])

        {

            new newthread();        

        }

    }


a) truetrue

b) falsefalse

c) true

d) false

Answer: b

Top articles
Advantages and Disadvantages of Java Published at:- Java General Interview Questions and Answer Published at:- Java Threads Interview Question and Answer for experienced Published at:- Java Collections Interview Question and Answer for freshers and experienced Published at:- Garbage Collector in Java Frequently Asked Questions and Answers Published at:- Difference between Exception and Error in java Exception Handling Published at:- Java Applets Interview Questions with Answer Published at:- Java Swing Interview Questions with Answer for freshers and experienced Published at:- Java Database Connectivity (JDBC) Interview Question and answer Published at:- Remote Method Invocation (RMI) Interview Question and Answer Published at:- Jakarta Server Page (JSP) programming language Interview Question and Answer Published at:- Write a program in Java to display the first 10 terms of the following series: 10, 20, 30, 40, …….. Published at:- Write the program in Java to display the first ten terms of the following series: 1, 4, 9, 16, Published at:- Write a program in Java to find the sum of the given series: Published at:- Write a program in Java to find the sum of the given series: Published at:- Java Multiple Choice Question MCQ Published at:- Java Multiple Choice Question MCQ Published at:-
R4Rin Team
The content on R4Rin.com website is created by expert teams.