Java Programming (3350703) MCQs

MCQs of Exception Handling & Multithreaded Programming

Showing 21 to 30 out of 48 Questions
21.

What is maximum priority of thread?

(થ્રેડની વધારેમાં વધારે પ્રાયોરીટી શું છે?)

(a)

20

(b)

15

(c)

10

(d)

5

Answer:

Option (c)

22.

Which method must be implemented by a Java thread?

(Java થ્રેડ દ્વારા કઈ મેથડને ઈમ્પલીમેન્ટ કરવી જરૂરી છે?)

(a)

run()

(b)

execute()

(c)

start()

(d)

launch()

Answer:

Option (a)

23.

Howmany different ways to create Thread in java?

(Javaમા થ્રેડ જુદી-જુદી કેટલી રીતે બનાવી શકાય?)

(a)

1

(b)

2

(c)

3

(d)

4

Answer:

Option (b)

24.

Thread can be created by,

(થ્રેડ બનાવવા માટે,)

(a)

Extending Thread Class

(Thread ક્લાસને એક્સટેન્ડ કરીને)

(b)

Implementing Runnable interface

(Runnable ઇન્ટરફેસને ઈમ્પલીમેન્ટ કરીને)

(c)

Both Extending Thread class and Implementing Runnable interface

(Thread ક્લાસને એક્સટેન્ડ કરી અને Runnable ઈન્ટરફેસને ઈમ્પલીમેન્ટ કરીને)

(d)

None of given

(આપેલમાંથી એકપણ નહિ)

Answer:

Option (c)

25.

How many threads will running during execution of  below given Java program?

class DemoThread extends Thread 
{
   public void run() 
   {
      System.out.println("Thread is running now");
   }
   public static void main(String[] args) 
   {
      DemoThread  d = new  DemoThread();
      d.start();
   }
}

નીચે આપેલ પ્રોગ્રામના એક્ઝીક્યુશન દરમિયાન કેટલા થ્રેડ રન થશે?

class DemoThread extends Thread 
{
   public void run() 
   {
      System.out.println("Thread is running now");
   }
   public static void main(String[] args) 
   {
      DemoThread  d = new  DemoThread();
      d.start();
   }
}
(a)

0

(b)

1

(c)

2

(d)

3

Answer:

Option (c)

26.

Which of following statement is used to know which Java Thread is currently executing?

(અત્યારે કયો Java થ્રેડ એક્ઝીક્યુટ થાય છે તે જાણવા માટે નીચે આપેલમાંથી ક્યા સ્ટેટમેન્ટનો ઉપયોગ થાય છે?)

(a)

Thread.currentThread.getName()

(b)

Thread.currentThread().getName()

(c)

Thread.CurrentThread().GetName()

(d)

Thread.CurrentThread().getName()

Answer:

Option (b)

27.

Which of following statement is correct about Java Thread?

1) After calling Thread start() method a thread is in runnable state but not yet starts its execution.

2) Thread run() method can also be called directly to create thread.

3) Thread start() method call run() method internally.

4) By calling Thread start() method, Thread will start its exceution directly.

Java થ્રેડ માટે નીચે આપેલમાંથી કયું સ્ટેટમેન્ટ સાચું છે?

1) થ્રેડની start() મેથડ કોલ કર્યાબાદ થ્રેડ runnable સ્ટેટમા હોય પરંતુ તેનું એક્ઝીક્યુશન હજુ શરૂ થશે નહિ.

2) થ્રેડ બનાવવા માટે થ્રેડની run() મેથડને પણ ડાયરેક્ટ કોલ કરી શકાય.

3) થ્રેડની start() મેથડ ઇન્ટરનલી run() મેથડને કોલ કરે છે.

4) થ્રેડની start() મેથડને કોલ કરવાથી થ્રેડનું એક્ઝીક્યુશન ડાયરેક્ટ શરૂ થાય છે.

(a)

1 & 2

(1 અને 2)

(b)

2 & 3

(2 અને 3)

(c)

2 & 4

(2 અને 4)

(d)

1 & 3

(1 અને 3)

Answer:

Option (d)

28.

Default priority of newly created thread is __________.

(નવા બનાવેલ થ્રેડની ડીફોલ્ટ પ્રાયોરિટી __________ હોય છે.)

(a)

0

(b)

5

(c)

10

(d)

15

Answer:

Option (b)

29.

Which method is used to check whether thread is  running or not?

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

(a)

isActive()

(b)

isRunning()

(c)

isAlive()

(d)

run()

Answer:

Option (c)

30.

Which thread will be executed first if two threads have same priority?

(જો બે થ્રેડની પ્રાયોરીટી સરખી હોય તો કયો થ્રેડ સૌપ્રથમ એક્ઝીક્યુટ થશે?)

(a)

Both will be executed simultaneously

(બંને થ્રેડ એકસાથે રન થશે)

(b)

They will be executed on first come first serve basis

(ફર્સ્ટ કમ ફર્સ્ટ સર્વને આધારે રન થશે)

(c)

They will fall in starvation and none will be executed

(બંને થ્રેડમાં સ્ટાર્વેશન થશે અને એકપણ થ્રેડ એક્ઝીક્યુટ નહિ થાય)

(d)

It depends upon operating system

(તે ઓપરેટીંગ સિસ્ટમ પર આધાર રાખે છે)

Answer:

Option (d)

Showing 21 to 30 out of 48 Questions