Q) Execution of a java thread begins on which method call?
- Start ()
- Run ()
- Execute ()
- Launch ()
On thread start method create a thread and execute it. Note that thread start() method calls run() method internally.
Q) How many ways a thread can be created in Java multithreading?
Threads in Java multithreading can be created in two ways. First, by implementing runnable interface and second as by extending thread class.
Read two ways to create java thread with example program
Q) Which statements is/are correct
- On calling Thread start () method a new thread get created.
- Thread start () method call run () method internally
- Thread run () method can also be called directly to create thread.
- All correct
Answer: 1 and 2
Notes: Thread run method can be called directly, but, it will behave as a normal method and will not create any thread.
Q) Which method is used to make main thread to wait for all child threads
- Join ()
- Sleep ()
- Wait ()
- Stop ()
Q) Default value of a java thread is
Default priority of thread is = 5. And minimum Priority = 1 & maximum Priority = 10.
MCQ- Java thread