closepop
closepop

Would you like to submit the test?


Java :

Threads




1.
What is the name of the method used to start a thread execution?

init();
start();
run();
resume();




2.
Which two are valid constructors for Thread?

Thread(Runnable r, String name)
Thread()
Thread(int priority)
Thread(Runnable r, ThreadGroup g)
Thread(Runnable r, int priority)

1 and 3 
1 and 4
1 and 2
1 and 5




3.
Which three are methods of the Object class?

notify();
notifyAll();
isInterrupted();
synchronized();
interrupt();
wait(long msecs);
sleep(long msecs);
yield();

1,2,3
3,2,1
1,2,6
6,3,1




4.
class X implements Runnable 
    public static void main(String args[]) 
    {
        /* Missing code? */
    } 
    public void run() {} 
}
Which of the following line of code is suitable to start a thread ?

Thread t = new Thread(X);
Thread t = new Thread(X); t.start();
X run = new X(); Thread t = new Thread(run); t.start();
Thread t = new Thread(); x.run();




5.
Which cannot directly cause a thread to stop executing?

Calling the SetPriority() method on a Thread object.
Calling the wait() method on an object.
Calling notify() method on an object.
Calling read() method on an InputStream object.




6.
Which two of the following methods are defined in class Thread?

start()
wait()
notify()
run()
terminate()

1 and 4
1 and 2
2 and 1
1 and 3




7.
Which three guarantee that a thread will leave the running state?

yield()
wait()
notify()
notifyAll()
sleep(1000)
aLiveThread.join()
Thread.killThread()

1,2 and 3
2,5 and 6
2,5 and 4
2,5 and 1




8.
Which of the following will directly stop the execution of a Thread?

wait()
notify()
notifyall()
exits synchronized code




9.
Which method must be defined by a class implementing the java.lang.Runnable interface?

void run()
public void run()
public void start()
void run(int priority)




10.
Which will contain the body of the thread?

run();
start();
stop();
main();




11.
Which method registers a thread in a thread scheduler?

run();
construct();
start();
register();




12.
Assume the following method is properly synchronized and called from a thread A on an object B:

wait(2000);
After calling this method, when will the thread A become a candidate to get another turn at the CPU?

After thread A is notified, or after two seconds.
After the lock on B is released, or after two seconds.
Two seconds after thread A is notified.
Two seconds after lock B is released.




13.
Which of the following will not directly cause a thread to stop?

notify()
wait()
sleep()
all the above




14.
Which class or interface defines the wait(), notify(),and notifyAll() methods?

object
thraed
runnable
class




15.
public class MyRunnable implements Runnable 
{
    public void run() 
    {
        // some code here
    }
}
which of these will create and start this thread?

new Runnable(MyRunnable).start();
new Thread(MyRunnable).run();
new Thread(new MyRunnable()).start();
new MyRunnable().start();










FreshersLive - No.1 Job site in India. Here you can find latest 2016 government as well as private job recruitment notifications for different posts vacancies in India. Get top company jobs for both fresher and experienced. Job Seekers can get useful interview tips, resume services & interview Question and answer. Practice online test free which is helpful for interview preparation. Register with us to get latest employment news/rojgar samachar notifications. Also get latest free govt and other sarkari naukri job alerts daily through E-mail.


FreshersLive - No.1 Job site in India. Here you can find latest 2016 government as well as private job recruitment notifications for different posts vacancies in India. Get top company jobs for both fresher and experienced. Job Seekers can get useful interview tips, resume services & interview Question and answer. Practice online test free which is helpful for interview preparation. Register with us to get latest employment news/rojgar samachar notifications. Also get latest free govt and other sarkari naukri job alerts daily through E-mail.