GSEB-XII: COMPUTER SCIENCE CH-10: EXCEPTION HANDLING IN JAVA (Ref. to Guide)
Ch-10
: Exception Handling in Java
1)
It
is usually understood that a compiled program is error free and will
always…………… successfully.
(a) complete
(b) execute
(c) perform
(d) accomplish
2)
In
few cases a compiled program can…………….. while it its executing.
(a) terminate
(b) finish
(c) dismiss
(d) discharge
3)
The
…… in a program results in an abnormal execution and it may lead to abnormal
termination and it may lead to abnormal termination of the program.
(a) exception
(b) error
(c) message
(d) mistake
4)
An………
is an indication of a problem that occurs during a program’s execution.
(a) exception
(b) inaccuracy
(c) error
(d) e-fault
5)
An
exception usually signals an……… .
(a) Exception
(b) inaccuracy
(c) error
(d) e-fault
6)
Although
exceptions occur infrequently, one has to be careful in handing such cases
while writing the………. .
(a) program
(b) message
(c) data
(d) code
7)
……….handling
allows a program to continue executing as if no problem had been encountered or
it may notify the user of the problem before terminating in an uncontrolled
manner.
(a) Data
(b) Program
(c) Error
(d) Exception
8)
There
are few standard……… available in java, a technique to guarantee that a
particular block of code will always be executed, even if exceptions are
present in our program.
(a) data info
(b) programs
(c) errors
(d) exceptions
9)
In
java, all kinds of error conditions are called ……….. .
(a) methods
(b) programs
(c) errors
(d) exceptions
10)
Error
can be broadly classified into……… categories.
(a) four
(b) three
(c) two
(d) five
11)
………….is
type of error produced in java programs.
(a) Compile-time errors
(b) Run-time errors
(c) Both (a) and (b)
(d) None of these
12)
A
…….. is used to convert source code into object code.
(a) compiler
(b) interpreter
(c) translator
(d) decoder
13)
A
compiler is used to convert…… code into object code.
(a) home
(b) source
(c) beginning
(d) program
14)
If
there is a syntax error in the program, a compilation error is displayed and…..
file is not created.
(a) .source
(b) .dat
(c) .class
(d) .obj
15)
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
16)
The
java……… suggests in an output, the type of error, along with the line number
where the error has occurred.
(a) compiler
(b) interpreter
(c) translator
(d) decoder
17)
Compile-time……..
are usually the mistake of a programmer and it does not allow the program to
compile unless they are solved.
(a) methods
(b) programs
(c) errors
(d) exceptions
18)
In
the field of computer Science, “Exit code” or
“Exit status” indicates whether the command or a……. executed successfully
or not.
(a) data type
(b) program
(c) error
(d) method
19)
Code……
indicates that the command executed successfully.
(a) 1
(b) -1
(c) 0.0
(d) 0
20)
Code…………..
indicates that some problem occurred while executing the command.
(a) 1
(b) -1
(c) 0.0
(d) 0
21)
If
there are no syntax errors in the source code then the program will compile
successfully and will get a…….. file.
(a) .source
(b) .dat
(c) .class
(d) .obj
22)
The
array “……… citylist [ ] = {“Ahmedabad”, “Baroda”, “Rajkot”, “Surat”};” contains
name of four different cities.
(a) string
(b) int
(c) long
(d) boolean
23)
for
each type of exception, there are corresponding…….. classes in java.
(a) programs
(b) exceptions
(c) java.lang
(d) java.io
24)
the
…….. contains a hierarchy of classes dealing with various exceptions.
(a) java.lang package
(b) java.io package
(c) both (a) and (b)
(d) none of these
25)
An
attempt to access the array element with an index value that is outside the
range of array uses……. Exception class.
(a) ArrayIndexOutOfBoundsException
(b) ArithmeticException
(c) FileNotFoundException
(d) All of these
26)
An
attempt to divide any number be 0 uses …….. exception class.
(a) ArrayIndexOutOfBoundsException
(b) ArithmeticException
(c) FileNotFoundException
(d) All of these
27)
An
attempt to access a non-existing file uses …….. exception class.
(a) ArrayIndexOutOfBoundsException
(b) ArithmeticException
(c) FileNotFoundException
(d) All of these
28)
An
attempt to use null in a case where an object is required uses…….. exception
class.
(a) PrinterIOException
(b) NullPointeException
(c) NumberFormatException
(d) None of these
29)
An
attempt to convert string to a number type uses…….Exception class.
(a) PrinterIOException
(b) NullPointeException
(c) NumberFormatException
(d) None of these
30)
An
I/O error has occurred while printing uses ………. Exception class.
(a) PrinterIOException
(b) NullPointeException
(c) NumberFormatException
(d) None of these
31)
The
following code will result in…….. Exception.
Int numerator 15; int
denominator =0;Answer;
Answer = numerator /
denominator;
(a) ArrayIndexOutOfBoundsException
(b) ArithmeticException
(c) FileNotFoundException
(d) All of these
32)
What
is the full form of JVM ?
(a) Java Virtual Mechanism
(b) Java Virtual Method
(c) Java Virtual Machine
(d) Java Virtual Manner
33)
An………
is an error condition.
(a) allowance
(b) error
(c) exclusion
(d) exception
34)
………….handling
is an object-oriented technique for managing errors.
(a) Allowance
(b) Error
(c) Exclusion
(d) Exception
35)
While
performing exception handling, one has to try to ensure that the program does
not…………. abruptly nor does it generate unexpected.
(a) terminate
(b) finish
(c) Dismiss
(d) Discharge
36)
Java
uses keywords like……… to write an exception handler.
(a) try
(b) catch
(c) finally
(d) all of these
37)
The
keywords……… are used in the presence of exceptions, these keywords represent
block of statements.
(a) try
(b) catch
(c) finally
(d) all of these
38)
A………..
contains the code that may give rise to one or more exceptions.
(a) try block
(b) catch block
(c) finally block
(d) all of these
39)
A……….
contains the code that is intended to handle exceptions of a particular type
that were created in the associated try block.
(a) try block
(b) catch block
(c) finally block
(d) all of these
40)
A………..
is always executed before the program ends, regarding of whether any exceptions
are generated in the try block or not.
(a) try block
(b) catch block
(c) finally block
(d) all of these
41)
The……..
statement contains a block of statement within the braces.
(a) try
(b) catch
(c) finally
(d) none of these
42)
A………..
block may give rise to one or more exceptions.
(a) try
(b) catch
(c) finally
(d) none of these
43)
The
code between a try block creates a……… exception.
(a) double
(b) single
(c) triple
(d) none of these
44)
The………
must immediately follow the try block.
(a) try block
(b) catch block
(c) finally block
(d) all of these
45)
………… contains the code that is to be created to
handle an exception.
(a) try block
(b) catch block
(c) finally block
(d) all of these
46)
The
……….is an exception handler.
(a) try block
(b) catch block
(c) finally block
(d) all of these
47)
For
a …………try block there can be one or more catch blocks.
(a) single
(b) double
(c) triple
(d) none of these
48)
A
catch block consists of the keyword catch followed by a single…………..
(a) operator
(b) method
(c) block
(d) parameter
49)
The
catch code to handle exception has to be written between.
(a) codes
(b) blocks
(c) parentheses
(d) parameters
50)
The……..
identifies the type of exception that the block is to deal with.
(a) operator
(b) method
(c) block
(d) parameters
51)
Java
supports…….. types of exceptions.
(a) various
(b) single
(c) multiple
(d) some
52)
Any
program which tries to access array element by specifying index position that is outside the range leads to
an…. .
(a) illegal message
(b) exclusion
(c) error
(d) exception
53)
When
above kind of exception occurs, an object of type ………… is created and is
thrown.
(a) ArrayIndexOutOfBoundsException
(b) ArithmeticException
(c) FileNotFoundException
(d) All of these
54)
A
corresponding ………… handles the above exception and does not allow the program
to terminate unexpectedly.
(a) try block
(b) catch block
(c) finally block
(d) all of these
55)
The catch block contains a…………to object
“eobj”which is created and thrown by the try block.
(a) space
(b) cell
(c) memory
(d) reference
56)
In
a single program………exceptions can occur.
(a) various
(b) single
(c) multiple
(d) some
57)
if
a particular file has to be uploaded to a remote computer, it may lead
to…………distinct exceptions.
(a) one
(b) two
(c) three
(d) four
58)
If
a particular file has to be uploaded to a remote computer, and exception may
occur if the file is not present in the…………….
(a) computer
(b) network
(c) internet
(d) system
59)
if
a particular file has to be uploaded to a remote computer, another exception
mayo occur if the computer is not connected to the………………
(a) computer
(b) network
(c) internet
(d) system
60)
There
is a provision in java to support…………… exceptions.
(a) various
(b) single
(c) multiple
(d) some
61)
The
code that generates exception should be written within the………………
(a) try block
(b) catch block
(c) finally block
(d) all of these
62)
There
can be multiple…………… to handle each type of exception separately.
(a) try blocks
(b) catch blocks
(c) finally blocks
(d) all of these
63)
The
last………… can handle any type of exception.
(a) try block
(b) catch block
(c) finally block
(d) none of these
64)
The………………
catch block, must be the last block when there are multiple catch blocks.
(a) first
(b) second
(c) third
(d) default
65)
While
writing the program, the order of the specific catch blocks does not matter but
the……………… block has to be placed at the end of all catch blocks.
(a) first
(b) second
(c) third
(d) default
66)
……………
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
67)
The
…………… is generally used to clean up to end of executing a try block.
(a) try block
(b) catch block
(c) finally block
(d) all of these
68)
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
69)
A…………
is always executed, regardless of whether or not exceptions are thrown during
the execution of the associated try block.
(a) try block
(b) catch block
(c) finally block
(d) all of these
70)
A………
is widely used if a file needs to be closed or a critical resource is to be
released at the completion of the program.
(a) try block
(b) catch block
(c) finally block
(d) all of these
71)
Each
of block must always be followed by at least…………… that is either a catch block
or a finally block.
(a) one block
(b) two block
(c) three block
(d) none of these
72)
However,
in the presence of………… the program executes the statements within the finally
block before it gets terminated.
(a) try block
(b) catch block
(c) finally block
(d) all of these
73)
A…………
is associated with a particular try block and it must be located immediately
following any catch blocks for the
corresponding try block.
(a) finally block
(b) catch block
(c) try block
(d) none of these
74)
If
these are no …………………, then the finally block can be positioned immediately
after the try block.
(a) try blocks
(b) catch block
(c) finally block
(d) all of these
75)
If
the finally block or catch blocks are not positioned correctly, then the
program willnot …………………
(a) compile
(b) interpret
(c) translate
(d) decode
76)
The…………………
keyword is used to explicitly throw an Exception object.
(a) Throws
(b) throws
(c) throw
(d) Try
77)
For
example, an object of…………………… was created when one tries to perform a divide by
zero operation.
(a) ArrayIndexOutOfBoundException
(b) ArithmeticException
(c) FileNotFoundException
(d) None of these
78)
Java
does provide mechanism to create an ……………… object and throw it explicitly.
(a) illusion
(b) exclusion
(c) error
(d) exception
79)
The
object that one throws, must be of type java.lang. …………………… otherwise a compile
error occurs.
(a) Throwable
(b) Throws
(c) throw
(d) throws
80)
The
syntax to throw an exception object is ………………….
(a) throw exception_object;
(b) throws
exception_object;
(c) throws exception_object
(d) throw object;
81)
when
a …………………… statement is encountered, a search for matching catch block begins.
(a) Throwable
(b) Throws
(c) throw
(d) throws
82)
Any
subsequent statements in the……………………… are
not executed.
(a) try block
(b) try or catch block
(c) catch block
(d) try or finally block
83)
There
are……………………… alternative approaches to handle, when an exception occurs in
method or a constructor.
(a) one
(b) two
(c) three
(d) four
84)
A…..clause
can be used in a method declaration or constructor declaration to inform that
the code within the constructor or method may throw an Exception.
(a) Throwable
(b) Throws
(c) throw
(d) throws
85)
When
a…………… or a method that can throw exceptions is written to its caller, it is
useful to document that fact.
(a) constructor
(b) variable
(c) operator
(d) compiler
86)
The……………………
keyword is used with the declaration of method.
(a) Throwable
(b) Throws
(c) throw
(d) throws
87)
A……………………
can throw multiple exceptions.
(a) method
(b) variable
(c) operator
(d) compiler
88)
Each
type of………………… that a method can throw must be start in the method header.
(a) declaration
(b) variable
(c) error
(d) exception
89)
………………
allows creating own exception classes according to application-specific
exceptions.
(a) C ++
(b) C
(c) Java
(d) PHP
90)
……..does
not provide built-in exception classes for application specific exceptions.
(a) C++
(b) C
(c) Java
(d) PHP
91)
User-defined
exceptions can be created by creating a subclass of……………………………. Class.
(a) declaration
(b) input
(c) method
(d) exception
92)
If
the ……………………… accepts data from the keyboard, it is advisable to execute the
program at command prompt.
(a) program
(b) application
(c) user
(d) compiler
93)
A
good program must always handle…………………
rather than the program being terminated abruptly.
(a) declaration
(b) inputs
(c) methods
(d) exceptions
94)
Advantage
of using exception-handling in java programs is………..
(a) it allows maintaining
normal flow of program. In the absence of exception handling, the flow of
program is disturbed.
(b) it allows writing
separate error handling code from the normal code.
(c) error types can be
grouped an differentiated within the program.
(d) All of these
95)
Advantage of using exception-handling in java
programs is…………………
(a) assertion can be used
to debug the program before deploying it to the clients.
(b) it provides an easy
mechanism to log various run-time error while executing the program.
(c) both (a) and (b)
(d) none of these
96)
Which
of the following is the correct syntax in a user defined exception ?
(a) catch(InvalidMarksException eobj)
(b) catch(ArithmeticException
eobj)
(c) catch
(ArrayIndexOutOfBounds e)
(d) all of these
97)
A
throws clause can be used in the following manner:
(a) Method_Modifiers
method_Name ([arameters) throws Exception list. . .{………… // body of the
method……………}
(b) Method_Modifiers return_type method_Name(parameters) throws
Exception list . . .{…………//body of the method………}
(c) return_type method_Name
(parameters) throws Exception list. . .{………// body of the method……}
(d) none of these
98)
A
method header can be like ………………
(a) performDivision throws
Arithmetic Exception. ArrayIndexOutOfBoundsException { . . . . .//body of the
method ……}
(b) performDivision()
throws Arithmetic Exception, ArrayIndex ArrayIndexOutOfBoundsException
(c) performDivison() throws
Arithmetic Exception, { . . . . .//body of the method ……}
(d) performDivison() throws Arithmetic Exception,
ArrayIndexOutOfBoundsException { . . . . .//body of the method ……}
99)
The
statement “throw myobject;”………………………
(a) Throws the exception
object implicitly
(b) Throws the exception object explicitly
(c) Throws The object
implicitly
(d) None of these
100)
Which
of these keywords must be used to monitor for exceptions ?
(a) Try
(b) Finally
(c) Throw
(d) Catch
101)
The
finally block is executed when an exception is thrown, even if no catch matches
it.
Choose the correct option.
Choose the correct option.
(a) True
(b) False
(c) Can’t say
(d) None of these
102)
Exceptions can be caught or re-thrown to a calling method. Choose the
correct option.
(a) True
(b) False
(c) Can’t say
(d) None of these
103)
The
throw keyword in a program are not executed. Choose the correct option.
(a) True
(b) False
(c) Can’t say
(d) None of these
104)
Which
of these keywords is not a part of exception handling ?
(a) Try
(b) Finally
(c) Thrown
(d) Catch
105)
Which
of the following is true about try/catch blocks in java ?
I.
All
try/catch blocks must have a finally block.
II.
A
try/catch block is limited to two or less catch blocks.
III.
Barring
the java virtual machine from exiting, the finally block will always be executed.
(a) (I) and (III)
(b) (I) only
(c) (I) only
(d) (I) and (II)
106)
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
107)
The
key words used with exception handling are
(a) generate, handled,
conclude
(b) generate, catch,
finally
(c) throw, catch, conclude
(d) try, catch, finally
108)
What
happen behind the code int a=50/0 ?
(a) Object of exception class thrown
(b) Error in Code
(c) Error message
(d) None of these
109)
When an array is accessed beyond the array
size, …… exception in thrown.
(a) Array ElementOut Of
Limit
(b) Array Index Out Of Bounds
Exception
(c) Array Index Out Of
Bounds
(d) Array ElementOut Of
Bounds
110)
What
is the output of this program ?
class
exception_handling
{
Public static void main(String args [ ])
Try {
int a, b;
b = 0;
a = 5 / b;
System.out.print(“A”);
}
Catch(ArithmeticException e) {
System.out.print(“B”);
}
}
(a)
A
(b)
B
(c)
Compilation
error
(d)
Runtime
error
111)
Which
of the following is the most important to know if you want to be able to use a
method to its full potential ?
(a) The method’s return
type
(b) The type of arguments
the method requires
(c) The number of
statements within the method
(d) The type of Exceptions the method throws
No comments
Post your comments