Home Login

Java Multiple Choice Question MCQ

Categories: Java

What is output for below 

    

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


Ques 8. 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


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

a) check

b) throw

c) catch

d) try

Answer: d


Ques 10. 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
Basic Java Interview Questions Published at:- Simple Tips for Learning Java Faster Published at:- Java Multiple Choice Question MCQ Published at:- Java Multiple Choice Question MCQ Published at:-
Main Category
|| Java || Technology || US Education News || Others || Spring || PROGRAMMING LANGUAGE || NEW SCHEMES || Education || UK EDUCATION NEWS || US EDUCATION GRADE 9 || WORLD EDUATION NEWS || UNITED STATE COMPUTER EDUCATION || PEBC Exam Canada || Software Engineering || science education || GRE QUESTION PAPER || History || Health ||
closeConn($conn); ?>