Well-structured Std 12 Computer Textbook MCQ Answers and Std 12 Computer MCQ Answers Ch 10 Exception Handling in Java can serve as a valuable review tool before computer exams.
GSEB Std 12 Computer Chapter 10 MCQ Exception Handling in Java
Question 1.
What is an exception ?
(A) Not to consider
(B) Error during the compilation of program
(C) All types of error situations
(D) (B) and (C) both
Answer:
(D) (B) and (C) both
Question 2.
What is indicated by an exception ?
(A) Alert message
(B) Error message
(C) Confirm message
(D) Nothing is displayed
Answer:
(B) Error message
Question 3.
What is true about the exception ?
(A) Exception occurs infrequently
(B) Exception handling allows a program to continue as if no problem is there
(C) It notifies the user of the problem before terminating in an uncontrolled manner
(D) All of these
Answer:
(D) All of these
Question 4.
Errors are classified into ………….. categories.
(A) 2
(B) 3
(C) 4
(D) 5
Answer:
(A) 2
Question 5.
What is the use of a compiler ?
(A) To convert source code to object code.
(B) Convert high level language to machine level language
(C) (A) or (B)
(D) To find grammatical mistakes
Answer:
(C) (A) or (B)
Question 6.
When .class file is not created ?
(A) If there is syntax error
(B) If undefined variables are used
(C) If the spelling of keyword is wrong
(D) Any situation like this will not create .class file
Answer:
(D) Any situation like this will not create .class file
Question 7.
If there is no semi colon at the end of the statement then what will happen ?
(A) It will show error while compiling a program
(B) .class is not created
(C) (A) and (B) both
(D) Nothing happens
Answer:
(C) (A) and (B) both
Question 8.
In computer science, …………… indicates whether the program is executed successfully or not.
(A) Exit code
(B) Exit status
(C) (A) or (B)
(D) (A) and (B) both
Answer:
(C) (A) or (B)
Question 9.
Exit code ……………. suggests that program is executed successfully.
(A) 0
(B) 1
(C) -1
(D) ∞
Answer:
(A) 0
Question 10.
Exit code …………… suggests that program is not executed successfully.
(A) 0
(B) 1
(C) -1
(D) ∞
Answer:
(B) 1
Question 11.
When .class file is generated ?
(A) If a program is not compiled
(B) If a program is compiled
(C) (A) or (B)
(D) .class file is never created
Answer:
(B) If a program is compiled
Question 12.
What is available for each type of exception in Java ?
(A) Public class
(B) Related exception class
(C) Private class
(D) All of these
Answer:
(B) Related exception class
Question 13.
…………….. package has corresponding classes to work with different exceptions.
(A) java.lang
(B) java.io
(C) java.hang
(D) (A) and (B) both
Answer:
(D) (A) and (B) both
Question 14.
int a[ ] = new int[4];
a[13] = 99;
……………. exception is applied to the previous code.
(A) ArraylndexOutOfBoundsException
(B) ArithmeticException
(C) FileNotFound
(D) All of these
Answer:
(A) ArraylndexOutOfBoundsException
Question 15.
int a = 50/0;
………….. exception is applied to above code.
(A) ArraylndexOutOfBounds
(B) ArithmeticException
(C) NumberFormatException
(D) NullPointerException
Answer:
(B) ArithmeticException
Question 16.
String s = “Divyakant Sir”;
int i = Integer.parselnt(s);
……………. exception is applied to above code.
(A) StringFormatException
(B) NumberFormatException
(C) ArithmeticException
(D) ArraylndexException
Answer:
(B) NumberFormatException
Question 17.
What is the meaning of exception handling ?
(A) It is an object oriented technique for managing errors
(B) Not to consider the exception situation
(C) To manage the exception situation
(D) All of these
Answer:
(A) It is an object oriented technique for managing errors
Question 18.
…………… is the status of exception.
(A) Static situation
(B) Error situation
(C) Dynamic situation
(D) Status of Java programming
Answer:
(B) Error situation
Question 19.
……………… is considered while handling the exception situation.
(A) Program should not enter the loop
(B) Program is terminated in controlled manner
(C) Program is terminated in uncontrolled manner
(D) All of these
Answer:
(C) Program is terminated in uncontrolled manner
Question 20.
……………. keyword is used to make a program using exception handling.
(A) try
(B) catch
(C) finally
(D) All of these
Answer:
(D) All of these
Question 21.
Instructions raising one or more exceptions are included in …………….. .
(A) try
(B) catch
(C) finally
(D) throw
Answer:
(A) try
Question 22.
Instructions handling one or more exceptions are included in ……………….. .
(A) try
(B) catch
(C) finally
(D) throw
Answer:
(B) catch
Question 23.
Finally block is always executed ……………. .
(A) In the beginning of the program
(B) In the end of the program
(C) Before ending the program
(D) In any part of the program
Answer:
(C) Before ending the program
Question 24.
If there are no exceptions in the try block then …………….. .
(A) catch block need not to be written
(B) finally block must be created
(C) (A) and (B) both
(D) (A) or (B)
Answer:
(C) (A) and (B) both
Question 25.
…………….. is incorrect for try block.
(A) try block is a block included in braces
(B) try block may create one or more options
(C) try block tries to handle exceptions
(D) the statements of try block are the instructions which we need to look after
Answer:
(C) try block tries to handle exceptions
Question 26.
The instructions having possibilities to have errors are written in …………. .
(A) try
(B) catch
(C) finally
(D) throw
Answer:
(A) try
Question 27.
……………. block should be there after try block.
(A) catch
(B) finally
(C) throw
(D) (A) or (B)
Answer:
(D) (A) or (B)
Question 28.
Catch block must be ……………. .
(A) before try block
(B) after try block
(C) at the end of program
(D) after finally block
Answer:
(B) after try block
Question 29.
…………… is the exception handler.
(A) Try block
(B) Catch block
(C) Finally block
(D) All of these
Answer:
(B) Catch block
Question 30.
……………… is the reason that catch block is called exception handler.
(A) Catch block handles the exception
(B) Catch block is the main block
(C) Program is not possible without catch block
(D) All of these
Answer:
(A) Catch block handles the exception
Question 31.
…………… catch blocks can be there form one try block.
(A) Only one
(B) One or more
(C) 2
(D) As many try blocks that many catch blocks
Answer:
(B) One or more
Question 32.
…………. is incorrect for catch block.
(A) One parameter is given after the keyword catch
(B) Instructions for exceptions handling are written in braces
(C) If there are more than one exception then also one catch block is enough
(D) Finally block must be before catch block
Answer:
(C) If there are more than one exception then also one catch block is enough
Question 33.
……………. block creates ‘eobj’ object.
(A) Try block
(B) Catch block
(C) Finally block
(D) All of these
Answer:
(A) Try block
Question 34.
……………… holds the indication of ‘eobj’ object.
(A) Try block
(B) Catch block
(C) Finally block
(D) All of these
Answer:
(B) Catch block
Question 35.
What is the use of catch block ?
(A) To handle the exceptions
(B) It does not allow the program to terminate unexpectedly
(C) (A) and (B) both
(D) Helpful in terminating the program
Answer:
(C) (A) and (B) both
Question 36.
The possibilities of arising exceptions are written in …………… .
(A) catch
(B) try
(C) finally
(C) throw
Answer:
(B) try
Question 37.
When more catch blocks are possible ?
(A) If there are more than one exception occurred in try block
(B) To make program easier
(C) If there is a possibility to have an error in the program
(D) This is not possible
Answer:
(A) If there are more than one exception occurred in try block
Question 38.
…………….. block can throw different exceptions.
(A) The try block
(B) The catch block
(C) The finally block
(D) All of these
Answer:
(A) The try block
Question 39.
Is it necessary to make separate catch block for each type of exception ?
(A) Yes
(B) No
(C) This is not possible
(D) It is dependent on the program
Answer:
(A) Yes
Question 40.
Where is the block for default type catch division in the program ?
(A) After first catch block
(B) Last catch block
(C) At the end of the program
(D) This is not possible
Answer:
(B) Last catch block
Question 41.
…………… block handles the exceptions in Java program.
(A) The catch block
(B) Default type catch block
(C) The finally block
(D) The throw block
Answer:
(B) Default type catch block
Question 42.
What is the use of finally block ?
(A) To terminate the program
(B) To clean up at the end after executing try block
(C) To make sure that some specific instructions are to be executed
(D) (B) and (C) both
Answer:
(D) (B) and (C) both
Question 43.
Finally block does not care about ……………. .
(A) whether the exceptions are thrown or not by try block
(B) inside catch block
(C) (A) and (B) both
(D) none of these
Answer:
(A) whether the exceptions are thrown or not by try block
Question 44.
……………. is incorrect about finally block.
(A) If it is necessary to close the file after executing the program
(B) It is always at the end of the program
(C) [ ] bracket is used in creating finally block
(D) If any resources are to be released at that time it is widely used
Answer:
(C) [ ] bracket is used in creating finally block
Question 45.
What is the location of finally in java program ?
(A) If the beginning of program
(B) If catch block is not there then after try block
(C) If there is catch block then after try block and catch block
(D) (A) or (B)
Answer:
(D) (A) or (B)
Question 46.
If finally or catch are not given at the perfect location then ……………. can happen.
(A) program get compiled
(B) program does not compile
(C) program is terminated immediately
(D) program enters the loop
Answer:
(B) program does not compile
Question 47.
What is the use of throw keyword ?
(A) To move necessary statements
(B) To throw the object of an exception
(C) To exit the program
(D) To take the control of the program in the beginning
Answer:
(B) To throw the object of an exception
Question 48.
Arithmetic exception is thrown using …………. .
(A) throw keyword
(B) with try block
(C) using JVM
(D) throws statement
Answer:
(C) using JVM
Question 49.
Object which is thrown using throws keyword must be of …………….. type.
(A) java.lang.throwable
(B) java.lang.string
(C) java.lang.scanner
(D) Java.lang.throw
Answer:
(A) java.lang.throwable
Question 50.
………….. is the syntax to throw the exceptions object.
(A) Throw. exception_object;
(B) Throw exception_object
(C) Throw exception_object;
(D) Throw exception_object;
Answer:
(C) Throw exception_object;
Question 51.
The exception object which is thrown using throw keyword can be taken care of using …………….. .
(A) the try block
(B) the catch block
(C) the finally block
(D) the throw block
Answer:
(B) the catch block
Question 52.
If exceptions are generated using method or constructor then try-catch block are defined in ………………… .
(A) try-catch block is given in method or constructor
(B) invoking the method or constructor inside try block
(C) (A) or (B)
(D) invoking the method or constructor directly in catch block
Answer:
(C) (A) or (B)
Question 53.
Instruction inside the constructor or method can throw the exception to mention that ……………….. is used while defining method or constructor.
(A) the throw statement
(B) the throws clause
(C) the JVM statement
(D) the finally block
Answer:
(B) the throws clause
Question 54.
The exception which can be thrown using throw is to be indicated in …………….. .
(A) in header
(B) in footer
(C) in the middle
(D) at the end of program
Answer:
(A) in header
Question 55.
……………. class is used to accept input from the keyboard.
(A) java.util.lang
(B) java.util.library
(C) java.lang.scanner
(D) Java.util.property
Answer:
(C) java.lang.scanner
Question 56.
Using …………….. method integer values can be accepted using scanner class.
(A) nextlnt()
(B) nextFloat()
(C) nextNumber()
(D) nextperseFloat?()
Answer:
(A) nextlnt()
Question 57.
It is usually understood that a compiled program is error free and will always …………….. successfully.
(A) complete
(B) execute
(C) perform
(D) accomplish
Answer:
(B) execute
Question 58.
An ……………… is an indication of a problem that occurs during a program’s execution.
(A) exception
(B) inaccuracy
(C) error
(D) e-fault
Answer:
(A) exception
Question 59.
In Java, all kinds of error conditions are called ……………. .
(A) methods
(B) programs
(C) errors
(D) exceptions
Answer:
(D) exceptions
Question 60.
Errors can be broadly classified into …………. categories.
(A) four
(B) three
(C) two
(D) five
Answer:
(C) two
Question 61.
……………. is a type of error produced in java programs.
(A) Compile-time errors
(B) Run-time errors
(C) (A) and (B) both
(D) None of these
Answer:
(C) (A) and (B) both
Question 62.
Examples of some common syntax errors are missing like a …………….. .
(A) semicolon
(B) use of undeclared variable
(C) wrong spellings of identifier or keyword
(D) all of these
Answer:
(D) all of these
Question 63.
The array ” ……………… namelist [ ] = {“Divyakant Sir”, “Tejas Sir “, “Sanjay Sir “, “Saket Sir contains name of four different cities.
(A) string
(B) int
(C) long
(D) boolean
Answer:
(A) string
Question 64.
An attempt to access a non-existing file uses …………….. exception class.
(A) ArraylndexOutOfBoundsException
(B) ArithmeticException
(C) FileNotFoundException
(D) All of these
Answer:
(C) FileNotFoundException
Question 65.
An attempt to convert string to a number type uses …………….. exception class.
(A) StringformatException
(B) ArithmeticException
(C) NumberFormatException
(D) ArraylndexException
Answer:
(C) NumberFormatException
Question 66.
An I/O error has occurred while printing uses …………….. exception class.
(A) PrinterlOException
(B) NullPointerException
(C) NumberFormatException
(D) None of these
Answer:
(A) PrinterlOException
Question 67.
Any program which tries to access array element by specifying index position that is outside the range leads to a ………….. .
(A) illegal message
(B) exclusion
(C) error
(D) exception
Answer:
(D) exception
Question 68.
The last …………… can handle any type of exception.
(A) try block
(B) catch block
(C) finally block
(D) none of these
Answer:
(B) catch block
Question 69.
……………. try blocks can be nested together, but care must be taken to write a corresponding catch block for each try block.
(A) Various
(B) Single
(C) Multiple
(D) Some
Answer:
(C) Multiple
Question 70.
A …………… is used when the programmer wants to be sure that some particular code is to be run, no matter what exceptions are thrown within the associated try block.
(A) try block
(B) catch block
(C) finally block
(D) all of these
Answer:
(C) finally block
Question 71.
If there are no …………….. then the finally block can be positioned immediately after the try block.
(A) try blocks
(B) catch blocks
(C) finally blocks
(D) none of these
Answer:
(B) catch blocks
Question 72.
Java does provide mechanism to create a ………………. object and throw it explicitly.
(A) illusion
(B) exclusion
(C) error
(D) exception
Answer:
(D) exception
Question 73.
The syntax to throw an exception object is ………….. .
(A) throw exception_object;
(B) throws exception_object;
(C) throws exception_object
(D) throw object;
Answer:
(A) throw exception_object;
Question 74.
The …………… keyword is used with the declaration of method.
(A) throwable
(B) throws
(C) throw
(D) throws
Answer:
(D) throws
Question 75.
……………. does not provide built-in exception classes for application specific exceptions.
(A) C ++
(B) C
(C) Java
(D) PHP
Answer:
(C) Java
Question 76.
A method header can be like …………. .
(A) performDivision throws Arithmetic Exception,
ArraylndexOutOfBoundsException { // body of the method …. }
(B) performDivision() throws Arithmetic Exception,
ArraylndexOutOfBoundsException
(C) performDivision() throws Arithmetic Exception} … // body of the method …. }
(D) performDivision() throws Arithmetic Exception,
ArraylndexOutOfBoundsException { // body of the method …. }
Answer:
(D) performDivision() throws Arithmetic Exception,
ArraylndexOutOfBoundsException { // body of the method …. }
Question 77.
Which of the following is true about try/catch blocks in Java ?
(I) All try/catch blocks must have a finally block.
(II) Barring the Java virtual machine from exiting, the finally block will always be
(III) A try/catch block is limited to two or less catch blocks executed.
(A) (I) and (III)
(B) (I) only
(C) (III) only
(D) (I) and (II)
Answer:
(A) (I) and (III)
Question 78.
What will be the output of the program ? public class Test
{
public static void main(String[ ] args)
try
{
(A) Finally
(B) Compilation fails
(C) The code runs with no output
(D) An exception is thrown at runtime
Answer:
(A) Finally
Question 79.
What is the output of this program ?
{ class exception_handling public static void main(String args[ ]) try { int a, b; a = 5 / b; b = 0; System.out.print (" A"); } catch (ArithmeticException e) { System.out.print("B"); } }
(A) A
(B) B
(C) Compilation error
(D) Runtime error
Answer:
(B) B