0% found this document useful (0 votes)
3 views10 pages

Chap_10 ExceptionHandling in Java

This document consists of a series of multiple-choice questions focused on Exception Handling in Java, aimed at 12th-grade students. Each question tests knowledge on various aspects of exception handling, including keywords, class types, and error classifications. The total marks for the chapter are 80, and the questions cover fundamental concepts and practical scenarios in Java programming.

Uploaded by

tilakpatel1800
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
3 views10 pages

Chap_10 ExceptionHandling in Java

This document consists of a series of multiple-choice questions focused on Exception Handling in Java, aimed at 12th-grade students. Each question tests knowledge on various aspects of exception handling, including keywords, class types, and error classifications. The total marks for the chapter are 80, and the questions cover fundamental concepts and practical scenarios in Java programming.

Uploaded by

tilakpatel1800
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 10

Logo

Subject: Computer Chapter 10


Standard: 12 Marks: 80
Chapter: Exception Handling 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

04. If there are no exceptions in the try block then


e

A. catch block need not to be written B. finally block must be created


dg

C. (A) and (B) both D. (A) or (B)


le

Ans
ow

05. The last ......... can handle any type of exception.


A. try block B. catch block C. finally block D. none of these
Kn

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

A. catch B. finally C. throw D. (A) or (B)


Ans
16. .......... 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
Ans
17. 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
Ans
18. Which of the following should be within a catch block?
A. Finally block
B. Single statement that handles Exception
C. Any number of statements to handle Exception
D. Throws keyword
Ans
19. String s = "Divyakant Sir"; int i = Integer.parseInt(s); exception is applied to above code.
A. StringFormatException B. NumberFormatException
C. ArithmeticException D. ArrayIndexException
Ans
20. 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
Ans
21. Using ......... method integer values can be accepted using scanner class.
A. nextInt() B. nextFloat() C. nextNumber() D. nextperseFloat()
Ans
22. 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
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

A. A B. B C. Compilation error D. Runtime error


le

Ans
ow

26. The possibilities of arising exceptions are written in .........


A. catch B. try C. finally D. throw
Kn

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

37. ......... is considered while handling the exception situation.


e
dg

A. Program should not enter the loop


B. Program is terminated in controlled manner
le

C. Program is terminated in uncontrolled manner


ow

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

A. Alert message B. Error message C. Confirm message D. Nothing is displayed


Ans
e
dg

47. If finally or catch are not given at the perfect location then......... can happen.
le

A. program get compiled B. program does not compile


ow

C. program is terminated immediately D. program enters the loop


Ans
Kn

48. 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)
Ans
49. 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)
Ans
50. Exit code ......... suggests that program is executed successfully.
A. 0 B. 1 C. - 1 D. ∞
Ans
51. The syntax to throw an exception object is
A. throw exception_object; B. throws exception_object;
C. throws exception_object D. throw object;
Ans
52. ...... 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
Ans
53. ... package has corresponding classes to work with different exceptions.
A. java.lang B. java.io C. java.hang D. (A) and (B) both
Ans
54. .......... 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
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

D. Exceptions and Errors are the same thing.


e

Ans
dg

57. int a = 50/0; exception is applied to above code.


le

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

A. java.lang.throwable B. java.lang.string C. java.lang.scanner D. Java.lang.throw


e

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

A. illegal message B. exclusion C. error D. exception


Ans
Kn

70. ......... holds the indication of 'eobj' object.


A. Try block B. Catch block C. Finally block D. All of these
Ans
71. Exit code ......... suggests that program is not executed successfully.
A. 0 B. 1 C. - 1 D. ∞
Ans
72. Java does provide mechanism to create a ......... object and throw it explicitly.
A. illusion B. exclusion C. error D. exception
Ans
73. Catch block must be .........
A. before try block B. after try block C. at the end of program D. after finally block
Ans
74. 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
Ans
75. An attempt to access a non-existing file uses ............. exception class.
A. ArrayIndexOutOfBoundsException
B. ArithmeticException
C. FileNotFoundException
D. All of these
Ans
76. ......... 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
Ans
77. ...... is the syntax to throw the exceptions object.
A. Throw.exception_object; B. Throw exception_object
C. Throw exception_object; D. Throw exception_object;
Ans
78. Which of the following is an advantage of using a try....catch block?
A. Exceptional events are eliminated

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

A. The method's return type


B. The type of arguments the method requires
le

C. The number of statements within the method


ow

D. The type of Exceptions the method throws


Kn

Ans
ANSWERS

Subject: Computer Chapter 10


Standard: 12 Marks: 80
Chapter: Exception Handling in Java

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

15. (A) or (B)


16. java.lang.scanner
e
dg

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

62. the throws clause


dg

63. catch
le

64. Before ending the program


ow

65. finally block


66. Catch block handles the exception
Kn

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

You might also like