Java Programming (3350703) MCQs

MCQs of Exception Handling & Multithreaded Programming

Showing 11 to 20 out of 48 Questions
11.

State true or false: finally block always executes.

આપેલ વિધાન સાચું છે કે ખોટું: ફાઈનલી(finally) બ્લોક હંમેશા એક્ઝીક્યુટ થાય છે.)

(a)

True

(b)

False

Answer:

Option (a)

12.

Which exception is thrown when divide by zero statement executes?

(divide by zero સ્ટેટમેન્ટ એક્ઝીક્યુટ થાય ત્યારે કયું એક્ષેપ્શન થ્રો(throw) થાય છે?)

(a)

DivideByZeroException

(b)

ArithmeticException

(c)

NumberFormatException

(d)

NullPointerException

Answer:

Option (b)

13.

Which exception is thrown when an array element is accessed beyond  the size of array?

(જયારે એરેની સાઇઝથી બહારના એલિમેન્ટને એક્સેસ કરવામાં આવે ત્યારે કયું એક્ષેપ્શન થ્રો(throw) થાય છે?)

(a)

ArrayElementOutOfBoundsException

(b)

ArrayIndexOutOfBound

(c)

ArrayIndexOutOfBoundsException

(d)

ArraySizeOutOfBound

Answer:

Option (c)

14.

What will be the output of following code?

class demoException
{
   public static void main(String a[])
   {
         int i = Integer.parseInt("One");
   }
}

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

class demoException
{
   public static void main(String a[])
   {
         int i = Integer.parseInt("One");
   }
}
(a)

IllegalStateException

(b)

ClassCastException

(c)

Run without Exception

એક્ષેપ્શન વગર રન થશે

(d)

NumberFormatException

Answer:

Option (d)

15.

What will be the output of following code?

class demoException
{
   public static void main(String args[]) 
   {
      try 
      {
         int a, b;
         a = 15 / 0;
         System.out.print("A");
      }
      catch(Exception e) 
      {
         System.out.print("B");         
      }
      catch(ArithmeticException e)
      {
         System.out.print("C");
      }
   }
}

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

class demoException
{
   public static void main(String args[]) 
   {
      try 
      {
         int a, b;
         a = 15 / 0;
         System.out.print("A");
      }
      catch(Exception e) 
      {
         System.out.print("B");         
      }
      catch(ArithmeticException e)
      {
         System.out.print("C");
      }
   }
}
(a)

B

(b)

A

(c)

AB

(d)

Compilation error

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

Answer:

Option (d)

16.

What is multithreaded programming?

(મલ્ટીથ્રેડીંગ પ્રોગ્રમીંગ શું છે?)

(a)

It is a process in which a single process can access information from many sources.

(તે એક એવી પ્રોસેસ છે જેમાં સિંગલ પ્રોસેસ એક કરતા વધારે સોર્સમાંથી માહિતી એક્સેસ કરી શકે છે.)

(b)

It is a process in which two or more parts of same process run simultaneously.

(તે એક એવી પ્રોસેસ છે કે જેમાં એક જ પ્રોસેસના બે અથવા વધારે પાર્ટ એકીસાથે રન થાય છે.)

(c)

It is a process in which two different processes run simultaneously.

(તે એક એવી પ્રોસેસ છે કે જેમાં બે જુદી-જુદી પ્રોસેસ એકીસાથે રન થાય છે.)

(d)

It is a process in which many different process are able to access same information.

(તે એક એવી પ્રોસેસ છે કે જેમાં જુદી-જુદી પ્રોસેસ એક જ માહિતીને એક્સેસ કરી શકે છે.)

Answer:

Option (b)

17.

Which of following statement is/are true about Error?

1) An Error is sub-class of Exception

2) An Error is sub-class of IOException

3) An Error is sub-class of Throwable

4) Error indicates serious problem that aries beyond  the control of the programmer

એરર(Error) માટે નીચે આપેલ સ્ટેટમેન્ટમાંથી ક્યા સાચા છે?

1) એરર એ એક્ષેપ્શન(Exception) ક્લાસ નો સબ-ક્લાસ છે.

2) એરર એ IOException ક્લાસ નો સબ-ક્લાસ છે.

3) એરર એ થ્રોવેબલ(Throwable) ક્લાસ નો સબ-ક્લાસ છે.

4) એરર એ સીરીયસ પ્રોબ્લેમ દર્શાવે છે કે જે પ્રોગ્રામરના કંટ્રોલની બહાર છે

(a)

1 and 2 

(1 અને 2)

(b)

1 and 3

(1 અને 3)

(c)

2 and 3

(2 અને 3)

(d)

3 and 4

(3 અને 4)

Answer:

Option (d)

18.

Which of following statement is incorrect?

(નીચે આપેલમાંથી કયું સ્ટેટમેન્ટ ખોટું છે?)

(a)

A thread can exist only in two states, running and blocked

(થ્રેડ ફક્ત બે જ સ્ટેટમાં હોય શકે, રનીંગ અને બ્લોક)

(b)

By multitasking CPU idle time is minimized, and we can take maximum use of it.

(મલ્ટીટાસ્કીંગ દ્વારા CPUનો આઈડલ ટાઈમ ઘટે છે અને આપણે તેનો ઉપયોગ મહતમ કરી શકીએ છીએ.)

(c)

Two thread in Java can have the same priority.

(Javaમાં બે થ્રેડની પ્રાયોરિટી સરખી હોય શકે છે.)

(d)

By multithreading CPU idle time is minimized, and we can take maximum use of it.

(મલ્ટીથ્રેડીંગ દ્વારા CPUનો આઈડલ ટાઈમ ઘટે છે અને આપણે તેનો ઉપયોગ મહતમ કરી શકીએ છીએ.)

Answer:

Option (a)

19.

State true or false: Thread is light weight process.

(આપેલ વિધાન સાચું છે કે ખોટું: થ્રેડ એ લાઈટવેઈટ પ્રોસેસ છે.)

(a)

True

(b)

False

Answer:

Option (a)

20.

Which method is called internally by Thread start() method?

(Threadની start() મેથડ ઇન્ટરનલી કઈ મેથડને કોલ કરે છે?)

(a)

main()

(b)

run()

(c)

execute()

(d)

launch()

Answer:

Option (b)

Showing 11 to 20 out of 48 Questions