Java Programming (3350703) MCQs

MCQs of Exception Handling & Multithreaded Programming

Showing 41 to 48 out of 48 Questions
41.

Which of the following method of Thread class is used to find out the priority of given thread?

(નીચે આપેલમાંથી થ્રેડ ક્લાસની કઈ મેથડનો ઉપયોગ આપેલ થ્રેડની પ્રાયોરિટી જાણવા માટે થાય છે?)

(a)

get()

(b)

getThreadPriority()

(c)

getPriority()

(d)

ThreadPriority()

Answer:

Option (c)

42.

Which of the following method of Thread class is used to suspend a thread for a period of time?

(નીચે આપેલમાંથી થ્રેડ ક્લાસની કઈ મેથડનો ઉપયોગ થ્રેડને થોડા સમય માટે સસ્પેન્ડ કરવા માટે થાય છે?)

(a)

stop()

(b)

sleep()

(c)

suspend()

(d)

terminate()

Answer:

Option (b)

43.

What will be output of following code?

class DThread
{
   public static void main(String args[])
   {
      Thread t = Thread.currentThread();
      System.out.println(t.getPriority());
   }
}

નીચે આપેલ કોડનું આઉટપુટ શું આવશે?

class DThread
{
   public static void main(String args[])
   {
      Thread t = Thread.currentThread();
      System.out.println(t.getPriority());
   }
}
(a)

0

(b)

1

(c)

10

(d)

5

Answer:

Option (d)

44.

What will be the output of following code?

class DThread extends Thread 
{ 
   public void run() 
   { 
      System.out.print("Run called "); 
   } 
} 
class DemoThread 
{ 
   public static void main(String[] args) 
   { 
      Thread  t = new Thread(); 
      t.start(); 
      t.start(); 
      System.out.print("Main method "); 
   } 
} 

નીચે આપેલ કોડનું આઉટપુટ શું આવશે?

class DThread extends Thread 
{ 
   public void run() 
   { 
      System.out.print("Run called "); 
   } 
} 
class DemoThread 
{ 
   public static void main(String[] args) 
   { 
      Thread  t = new Thread(); 
      t.start(); 
      t.start(); 
      System.out.print("Main method "); 
   } 
} 
(a)

Run called Run called Main method

(b)

Runtime Error

રનટાઈમ એરર

(c)

Compilation error

કમ્પાઈલેશન એરર

(d)

Run called Main method

Answer:

Option (b)

45.

Which of the following method registers a thread in a thread scheduler?

(નીચે આપેલમાંથી કઈ મેથડ થ્રેડને થ્રેડ શીડ્યુલરમા રજીસ્ટર કરવા માટે ઉપયોગ થાય છે?)

(a)

run()

(b)

Thread()

(c)

Thread(Runnable r)

(d)

start()

Answer:

Option (d)

46.

Thread synchronization in a process will be required when,

(પ્રોસેસમાં થ્રેસ સિન્ક્રોનાઇઝેશનની જરૂર પડે છે જયારે,)

(a)

All threads sharing the same address space

(બધા થ્રેડ એક જ એડ્રેસ સ્પેસ શેર કરે)

(b)

All threads sharing the same global variables

(બધા થ્રેડ એક જ ગ્લોબલ વેરિએબલ શેર કરે)

(c)

All threads sharing the same files

(બધા થ્રેડ એક જ ફાઈલ શેર કરે)

(d)

All of given

(આપેલ બધા જ)

Answer:

Option (d)

47.

Which of the following is not a Thread state?

(નીચે આપેલમાંથી કયો વિકલ્પ થ્રેડનું સ્ટેટ નથી?)

(a)

New

(ન્યુ)

(b)

Runnable

(રનેબલ)

(c)

Terminated

(ટર્મિનેટેડ)

(d)

sleep

(સ્લીપ)

Answer:

Option (d)

48.

State true or false: wait(), notify() and notifyAll() methods are always called from Synchronized block only.

(આપેલ વિધાન સાચું છે કે ખોટું:  wait(), notify() અને  notifyAll() મેથડને સિન્ક્રોનાઇઝ બ્લોક માંથી જ હંમેશા કોલ કરવામાં આવે છે?)

(a)

True

(b)

False

Answer:

Option (a)

Showing 41 to 48 out of 48 Questions