Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Unleash the power of parallel processing with multithreading! This quiz delves into the intricacies of multithreading in Java, a fundamental concept for building responsive and efficient applications.
By testing your knowledge on key aspects like thread independence, shared memory, and concurrency, this quiz will help you identify areas for improvement and solidify your understanding of multithreading.
Whether you’re a seasoned Java developer or just starting to explore multithreading, this quiz is an excellent tool to gauge your grasp of this critical programming technique.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Which of the following is not an advantage of MultiThreading in Java ?
Correct
Incorrect
Question 2 of 15
2. Question
class Threading extends thread {
public void run {
try() {
System.out.println(Thread.currentThread.getId());
}
}
catch(Exception e )
{
System.out.println(e);
}
}
class Main {
public static void main ( String args [ ] )
{
int number =3;
for(i=0;i<number;i++);
Thread t = new Thread( new Threading);
t.start();
}
}
How many times does the thread class is invoked?
Correct
Incorrect
Question 3 of 15
3. Question
Which of the following is the correct syntax to set the priority of a thread ?
Correct
Incorrect
Question 4 of 15
4. Question
Which of the following is true about threads in Java ?
Correct
Incorrect
Question 5 of 15
5. Question
class ThreadDemo extends Thread {
public void run ( )
{
System.out.println(“Thread Class is extended “);
}
public static void main ( String args [ ] )
{
ThreadDemo thread = new ThreadDemo();
thread.setPriority(Min_Priority);
}
}
What will be the output of the program ?
Correct
Incorrect
Question 6 of 15
6. Question
Which of the following is the correct syntax for returning the state of a current thread ?
Correct
Incorrect
Question 7 of 15
7. Question
Which of the following methods is used to set the priority of a thread ?
Correct
Incorrect
Question 8 of 15
8. Question
class ThreadSuspend extends Thread {
public void run ( )
{
for( int i = 0 ; i < 5 ; i ++ )
{
System.out.println(“DataFlair”);
if ( i == 3 ) {
thread.suspend();
}
}
public static void main ( String args [ ] )
{
ThreadSuspend thread = new ThreadSuspend();
thread.start();
}
}
How many times will the String DataFlair be printed in the given program ?
Correct
Incorrect
Question 9 of 15
9. Question
class MultipleThreads extends thread {
public void run ( ) {
System.out.println(“Thread One”);
}
}
class MultiThreads extends thread {
public void run ( )
{
System.out.println(“Thread two”);
}
}
class Main {
public static void main ( String args [ ] )
{
MultipleThreads thread1 = new MultipleThreads();
thread1.setPriority(Min_Priority);
thread1.start();
MultiThreads thread2 = new MultiThreads();
thread2.setPriority(Avg_Priority);
thread2.start();
}
}
Which of the given threads will be executed first ?
Correct
Incorrect
Question 10 of 15
10. Question
What is the function of a getPriority() method in a thread class ?
Correct
Incorrect
Question 11 of 15
11. Question
class SetName extends Thread {
public void run ( )
{
System.out.println( thread.getname());
}
public static void main ( String args [ ] )
{
SetName thread = new SetName ();
thread.start();
}
}
What is the error in the program ?
Correct
Incorrect
Question 12 of 15
12. Question
class Sample extends Thread {
public void run ( )
{
for ( i = 1 ; i < 4 ; i ++ )
{
System.out.println(“thread is still running “);
if( i == 2 )
{
thread.suspend();
}
if ( thread,isDaemon() == true )
{
thread.resume();
}
}
public static void main ( String args [ ] )
{
Sample s = new Sample();
s.start();
}
}
What will be the flow of the given program ?
Correct
Incorrect
Question 13 of 15
13. Question
Which of the following methods are used to check if a given thread is still working or not ?
Correct
Incorrect
Question 14 of 15
14. Question
class ThreadClass extends Thread {
public void run ( )
{
System.out.println(“Thread);
}
public static void main ( String args [ ] )
{
ThreadClass thread = new ThreadClass ();
boolean answer = thread.isDaemon();
}
}
What is the value of the variable answer in the given program ?
Correct
Incorrect
Question 15 of 15
15. Question
class MultiThread {
public void run ( )
{
System.out.println(“Thread is running”);
}
}
class Main {
public static void main ( String args [ ] )
{
MultiThread thread = new Multithread();
thread.setName(“DataFlair”);
thread.setPriority(Max_Priority);
thread.start();
}
}
What is the name of the created thread in the given program ?
Correct
Incorrect
Ready to put your multithreading knowledge to the test? This Java quiz has challenged you with various questions that assess your understanding of thread independence, shared memory, concurrency, and other core multithreading concepts.
By attempting the quiz, you’ve gained valuable insights into your strengths and weaknesses when it comes to multithreading in Java. Remember, effective learning is a continuous process. Explore additional resources beyond the quiz to deepen your knowledge and become a multithreading master!
Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google
DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.