Java Programming (3350703) MCQs

MCQs of Exception Handling & Multithreaded Programming

Showing 1 to 10 out of 48 Questions
1.

When does Exceptions aries in Java?

(Javaમા એક્ષેપ્શન ક્યારે આવે છે?)

(a)

Compile Time

(કમ્પાઈલ ટાઈમ)

(b)

Runtime

(રનટાઈમ)

(c)

Any Time

(ગમે ત્યારે)

(d)

None of given

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

Answer:

Option (b)

2.

Which of following keyword is not a part of exception handling?

(નીચે આપેલમાંથી કયો કીવર્ડ એક્ષેપ્શન હેન્ડલીંગનો પાર્ટ નથી?)

(a)

try

(ટ્રાય)

(b)

throw

(થ્રો)

(c)

thrown

(થ્રોવ્ન)

(d)

finally

(ફાઈનલી)

Answer:

Option (c)

3.

Which of following keyword must be used to check whether exception generated or not?

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

(a)

try

(ટ્રાય)

(b)

finally

(ફાઈનલી)

(c)

catch

(કેચ)

(d)

throw

(થ્રો)

Answer:

Option (a)

4.

Which keyword is used to manually throw an exception?

(મેન્યુઅલી એક્ષેપ્શન થ્રો(throw) કરવા માટે કયો કીવર્ડ ઉપયોગી છે?)

(a)

try

(ટ્રાય)

(b)

finally

(ફાઈનલી)

(c)

catch

(કેચ)

(d)

throw

(થ્રો)

Answer:

Option (d)

5.

Which keyword is used to specify the exception thrown by method?

(એક્ષેપ્શન મેથડ દ્વારા થ્રો(throw) થયુ છે તે દર્શાવવા કયો કીવર્ડ ઉપયોગી છે?)

(a)

try

(ટ્રાય)

(b)

throw

(થ્રો)

(c)

throws

(થ્રોવ્સ)

(d)

finally

(ફાઈનલી)

Answer:

Option (c)

6.

State true or false: We can use try block without catch block.

(આપેલ વિધાન સાચું છે કે ખોટું: આપણે ટ્રાય(try) બ્લોકનો ઉપયોગ કેચ(catch) બ્લોક વગર કરી શકીએ છીએ.)

(a)

True

(b)

False

Answer:

Option (b)

7.

Which of following package contains Exception class?

(નીચે આપેલમાંથી ક્યા પેકેજમા એક્ષેપ્શન(Exception) ક્લાસ આવેલ છે?)

(a)

java.io

(b)

java.util

(c)

java.net

(d)

java.lang

Answer:

Option (d)

8.

State true or false: We can write more than one catch block for one try block.

(આપેલ વિધાન સાચું છે કે ખોટું: આપણે એક ટ્રાય(try) બ્લોક માટે એક કરતા વધારે કેચ(catch) બ્લોક લખી શકીએ છીએ.)

(a)

True

(b)

False

Answer:

Option (a)

9.

What will be the output of following code?

class demoException 
{
   public static void main(String args[]) 
   {
      try 
      {
         System.out.print("Hello" + " " + 1 / 0);
      }
      catch(ArithmeticException e) 
      {
         System.out.print("World");         
      }
   }
}

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

class demoException 
{
   public static void main(String args[]) 
   {
      try 
      {
         System.out.print("Hello" + " " + 1 / 0);
      }
      catch(ArithmeticException e) 
      {
         System.out.print("World");         
      }
   }
}
(a)

Hello

(b)

HelloWorld

(c)

Hello Wrold

(d)

World

Answer:

Option (d)

10.

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(ArithmeticException e) 
      {
         System.out.print("B");       
      }
      finally 
      {
         System.out.print("C");
      }
   }
}

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

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

B

(b)

AC

(c)

BC

(d)

ABC

Answer:

Option (c)

Showing 1 to 10 out of 48 Questions