Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Anurag
A
Anurag
Community Contributor
Quizzes Created: 1 | Total Attempts: 114
| Attempts: 114 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. In Java, each thread has its own ________, in which it runs?

Explanation

Moon is round because of formed and collapsed under the force of their own gravity.

Submit
Please wait...
About This Quiz
Oopj Quiz 5 IT - A - Quiz

OOPJ Quiz 5 IT - A assesses knowledge on Java multithreading, covering thread behaviors, priorities, and methods. It evaluates understanding of thread management and synchronization, crucial for developing robust Java applications.

Personalize your quiz and earn a certificate with your name on it!
2. Give One Word for ? A situation where two or more threads are blocked forever and waiting for each other to release resources.

Explanation

A deadlock occurs when two or more threads are unable to progress because each thread is waiting for a resource that is held by another thread. In this situation, the threads are blocked indefinitely and cannot continue their execution. This can happen when there is a circular dependency between the threads, causing them to wait for each other's resources without being able to release their own.

Submit
3. In Java, by default every thread is given a _________.

Explanation

In Java, every thread is given a priority level by default. The priority level determines the importance of the thread and how it should be scheduled by the operating system. The available priority levels are MIN_PRIORITY(0), NORM_PRIORITY(5), and MAX_PRIORITY(10). The NORM_PRIORITY(5) is the default priority level assigned to threads in Java. This means that unless explicitly specified, a thread will have a normal priority level of 5.

Submit
4. What will happen if we call run() directly, without start() ?

Explanation

If we call the run() method directly without using the start() method, the thread won't be allocated a new call stack. Instead, it will start running in the current call stack. This means that the code inside the run() method will be executed just like any other regular method call, without any separate thread being created. This is different from using the start() method, which creates a new thread and then calls the run() method in that new thread.

Submit
5. Which two are valid constructors for Thread class ? 1. Thread(Runnable r, String name) 2. Thread() 3. Thread(int priority) 4. Thread(Runnable r, ThreadGroup g)

Explanation

During the night the high contrast between the bright moon and the night's dark skies make the Moon look white.

Submit
6. What Exception is thrown when you start a thread twice ?

Explanation

When you start a thread twice, it will throw an IllegalStateException. This exception is thrown when a method is called at an illegal or inappropriate time. In this case, starting a thread that is already running is considered illegal and will result in an IllegalStateException being thrown.

Submit
7. Which class or interface defines the wait(), notify(), and notifyAll() methods

Explanation

The correct answer is Object because the wait(), notify(), and notifyAll() methods are defined in the Object class in Java. These methods are used for inter-thread communication and synchronization. The wait() method is used to make a thread wait until another thread notifies it, while the notify() method is used to wake up a single waiting thread, and the notifyAll() method is used to wake up all the waiting threads. These methods are fundamental for implementing thread synchronization and coordination in Java.

Submit
8. What is the Output of given code ? class MyThread extends Thread { public static void main(String[] args) { MyThread my = new MyThread(); Thread t = new Thread(my); t.start(); } public void run() { for(int i=0; i< 3; i++){ System.out.println(i+"..") } } }

Explanation

The code creates a class called MyThread which extends the Thread class. In the main method, an instance of MyThread is created and then a new Thread object is created, passing the MyThread instance as a parameter. The start() method is called on the Thread object, which causes the run() method of the MyThread instance to be executed.

In the run() method, a for loop is used to print the values of i from 0 to 2, followed by a ".." string. Therefore, the output of the code will be "0..1..2..".

Submit
9. What will be the Output of given code ? public class Test implements Runnable { public void run() { System.out.println("r1 "); System.out.println("r2 "); } public static void main( String[] args ) { Thread t = new Thread(new Test()); t.start(); System.out.println("m1 "); t.join(); System.out.println("m2 "); } }

Explanation

The code will result in a compilation error because the Test class does not implement the required method from the Runnable interface, which is the run() method.

Submit
10. Which of the following statement is not correct ?

Explanation

The correct answer is "sleep() is a static method simply used to put your thread on sleep." This statement is not correct because sleep() is a non-static method that is used to put a thread on sleep. Static methods are called on the class itself, while non-static methods are called on an instance of the class.

Submit
View My Results

Quiz Review Timeline (Updated): Feb 13, 2024 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Feb 13, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 21, 2018
    Quiz Created by
    Anurag
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
In Java, each thread has its own ________, in which it runs?
Give One Word for ?...
In Java, by default every thread is given a _________.
What will happen if we call run() directly, without start() ?
Which two are valid constructors for Thread class ? 1. Thread(Runnable...
What Exception is thrown when you start a thread twice ?
Which class or interface defines the wait(), notify(), and notifyAll()...
What is the Output of given code ?...
What will be the Output of given code ?...
Which of the following statement is not correct ?
Alert!

Advertisement