Chap_10 ExceptionHandling in Java
Chap_10 ExceptionHandling in Java
Section - A
‣ Choose the correct option from those given below each question. (Each question carries 1 Marks) (80)
01. It is usually understood that a compiled program is error free and will always successfully.
d
A. complete B. execute C. perform D. accomplish
an
Ans
An
02. ......... keyword is used to make a program
A. try B. catch C. finally D. All of these
ol
Ans
ho
03. What is available for each type of exception in Java?
Sc
A. Public class B. Related exception class
C. Private class D. All of these
h
ig
Ans
H
Ans
ow
Ans
06. A method header can be like ......... .
A. performDivision throws Arithmetic Exception, ArrayIndexOutOfBoundsException { ...... // body of the
method .... }
B. perform Division() throws Arithmetic Exception, ArrayIndexOutOfBoundsException
C. perform Division() throws Arithmetic Exception{ // body of the method .... }
D. performDivision() throws Arithmetic Exception, ArrayIndexOutOfBoundsException { ...... // body of the
method.... }
Ans
07. ..... is the status of exception.
A. Static situation B. Error situation
C. Dynamic situation D. Status of Java programming
Ans
08. 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
Ans
09. ......... block creates 'eobj' object.
A. Try block B. Catch block C. Finally block D. All of these
Ans
10. What will be the output of the program ? public class Test { public static void main(String[ ] args) try { {
return ; } finally { System.out.println("Finally"); } } }
A. Finally B. Compilation fails
C. The code runs with no output D. An exception is thrown at runtime
Ans
11. Which of the following is a correct word for all Java Exceptions?
A. Errors B. Runtime Exceptions C. Throwables D. Omissions
Ans
12. What is the meaning of exception handling?
d
an
A. It is an object oriented technique for managing errors
B. Not to consider the exception situation
An
C. To manage the exception situation
D. All of these
ol
Ans
ho
13. Errors can be broadly classified into ...... categories.
Sc
A. four B. three C. two h D. five
Ans
ig
14. int a[ ] = new int[4]; a[13] = 99; ..... exception is applied to the previous code.
H
A. ArrayIndexOutOfBoundsException
e
B. ArithmeticException
dg
C. FileNotFound
le
D. All of these
ow
Ans
15. ...... block should be there after try block.
Kn
d
D. All of these
an
Ans
An
23. ......... does not provide built-in exception classes for application specific exceptions.
A. C++ B. C C. Java D. PHP
ol
ho
Ans
24. ......... try blocks can be nested together, but care must be taken to write a corresponding catch block for each
Sc
try block.
A. Various B. Single C. Multiple D. Some
h
ig
Ans
H
25. 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"); } }
e
dg
Ans
ow
Ans
27. ..... is the exception handler.
A. Try block B. Catch block C. Finally block D. All of these
Ans
28. ......... block handles the exceptions in Java program.
A. The catch block B. Default type catch block
C. The finally block D. The throw block
Ans
29. 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
Ans
30. 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
Ans
31. The ......... keyword is used with the declaration of method.
A. throwable B. throws C. throw D. throws
Ans
32. 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
Ans
33. Arithmetic exception is thrown using
A. throw keyword B. with try block C. using JVM D. throws statement
Ans
34. In Java, all kinds of error conditions are called
A. methods B. programs C. errors D. exceptions
Ans
d
35. What is the use of finally block?
an
A. To terminate the program
An
B. To clean up at the end after executing try block
C. To make sure that some specific instructions are to be executed
ol
D. (B) and (C) both
ho
Ans
Sc
36. Which of the following methods can throw an Exception ?
A. Methods with throws clause B. Methods with a catch block
h
C. Methods with a try block D. Methods with finally block
ig
Ans
H
D. All of these
Kn
Ans
38. 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
Ans
39. .... 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
Ans
40. 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
Ans
41. 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
Ans
42. 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
Ans
43. What will happen when a try block does not generate an Exception and you have included multiple catch
blocks ?
A. They all execute B. Only the first matching one excecutes
C. No catch block executes D. Only the first catch block executes
Ans
44. ......... is incorrect for catch block.
d
A. One parameter is given after the keyword catch
an
B. Instructions for exceptions handling are written in braces
An
C. If there are more than one exception then also one catch block is enough
D. Finally block must be before catch block
ol
Ans
ho
45. Instructions raising one or more exceptions are included in ...... .
Sc
A. try B. catch C. finally D. throw
Ans
h
ig
46. What is indicated by an exception?
H
47. If finally or catch are not given at the perfect location then......... can happen.
le
d
D. If any resources are to be released at that time it is widely used
an
Ans
An
55. The instructions having possibilities to have errors are written in ......... .
A. try B. catch C. finally D. throw
ol
ho
Ans
56. Which of the following statements is true?
Sc
A. Exceptions are more serious than Errors. h
B. Errors are more serious than Exceptions.
ig
C. Errors and Exceptions are equally serious.
H
Ans
dg
A. ArrayIndexOutOfBounds B. ArithmeticException
ow
C. NumberFormatException D. NullPointerException
Ans
Kn
58. 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
Ans
59. ......... block can throw different exceptions.
A. The try block B. The catch block C. The finally block D. All of these
Ans
60. Which of the following refers to an error condition in object-oriented programming terminology?
A. Anomaly B. Abbreviation C. Exception D. Deviation
Ans
61. An... is an indication of a problem that occurs during a program's execution.
A. exception B. inaccuracy C. error D. e-fault
Ans
62. 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
Ans
63. Instructions handling one or more exceptions are included in ...... .
A. try B. catch C. finally D. throw
Ans
64. 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
Ans
65. 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 on the associated try block.
A. try block B. catch block C. finally block D. all of these
Ans
66. ......... is the reason that catch block is called exception handler.
d
an
A. Catch block handles the exception
B. Catch block is the main block
An
C. Program is not possible without catch block
D. All of these
ol
Ans
ho
67. Errors are classified into.......... categories.
Sc
A. 2 B. 3 C. 4 h D. 5
Ans
ig
68. Object which is thrown using throws keyword must be of......... type.
H
Ans
dg
69. Any program which tries to access array element by specifying index position that is outside the range leads
le
to a ..........
ow
d
B. Exceptional events are reduced
an
C. Exceptional events are integrated with regular events
An
D. Exceptional events are isolated from regular events
Ans
ol
79. If exceptions are generated using method or constructor then try-catch block are defined in ..... .
ho
A. try-catch block is given in method or constructor
Sc
B. invoking the method or constructor inside try block
C. (A) or (B)
h
D. invoking the method or constructor directly in catch block
ig
Ans
H
80. Which of the following is least important to know if you want to be able to use a method to its full potential?
e
dg
Ans
ANSWERS
Section - A
‣ Choose the correct option from those given below each question. (Each question carries 1 Marks) (80)
01. execute
02. All of these
03. Related exception class
04. (A) and (B) both
05. catch block
06. performDivision() throws Arithmetic Exception, ArrayIndexOutOfBoundsException { ...... // body of the
d
method.... }
an
07. Error situation
An
08. (A) and (B) both
09. Try block
ol
10. Finally
ho
11. Runtime Exceptions
Sc
12. It is an object oriented technique for managing errors
13. two
h
ig
14. ArrayIndexOutOfBoundsException
H
17. Yes
18. Any number of statements to handle Exception
le
ow
19. NumberFormatException
20. Last catch block
Kn
21. nextInt()
22. All of these
23. Java
24. Multiple
25. B
26. try
27. Catch block
28. Default type catch block
29. If a program is compiled
30. To throw the object of an exception
31. throws
32. catch blocks
33. using JVM
34. exceptions
35. (B) and (C) both
36. Methods with a try block
37. Program is terminated in uncontrolled manner
38. (A) or (B)
39. try block tries to handle exceptions
40. Any situation like this will not create .class file
41. string
42. whether the exceptions are thrown or not by try block
43. No catch block executes
44. If there are more than one exception then also one catch block is enough
45. try
46. Error message
47. program does not compile
48. (A) or (B)
49. (i) and (iii)
50. 0
51. throw exception_object;
d
52. One or more
an
53. (A) and (B) both
An
54. [ ] bracket is used in creating finally block
55. try
ol
56. Exceptions and Errors are the same thing.
ho
57. ArithmeticException
Sc
58. (A) and (B) both
59. The try block
h
ig
60. Exception
H
61. exception
e
63. catch
le
67. 2
68. java.lang.throwable
69. exception
70. Catch block
71. 1
72. exception
73. after try block
74. the catch block
75. FileNotFoundException
76. (A) and (B) both
77. Throw exception_object;
78. Exceptional events are integrated with regular events
79. (A) or (B)
80. The number of statements within the method