STD 12-CHAPTER-10
STD 12-CHAPTER-10
Textbook Solution
1. Which of the following refers to an error condition in object-oriented
programming Terminology?
a. Anomaly
b. abbreviation
c. exception
d. deviation
7. What will happen when a try block does not generated an Exception and
you have included multiple catch blocks?
a. they all execute
b. only the first matching one executes
c. no catch block executes
d. only the first catch block executes
10. Which of the following is least 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 throw
Exam-oriented Questions
1. Which program is error free and will always be executed successfully?
a) complied b) interpreted c) debug d) coded
2. What is an indication of a problem that occurs during a program’s execution
which usually signals an error?
a) Exception b) compiled c) interpreted d) coded
3. Which of the following allows a program to continue executing as if no problem
had been encountered or it may modify the use of the program before
terminating
in an uncontrolled manner?
a) Exception handling b) termination c) Exception code d) Error
4. What is called all kinds of error conditions in Java?
a) Exceptions b) Warm c) Compilation d) termination
5. What is used to convert source code into object code?
a) compiler b) Interpretation c) Termination d) debugging
6. If there is a syntax error in the program we will get a compilation error and will
not
be able to create the……………………file.
a) class b) java c) javac d) document
7. In how many categories, Error can be broadly classified?
a) Compile-time errors b) Run-time errors c) exe time d) both a and b
8. Which of the following are the common syntax errors in Java programs?
a)Missing semicolon, Use of undeclared variable
b) Wrong spellings of identifier or keyword
c) Mismatch of bracket d) All of above
9. Which type of errors are usually the mistakes of programmer?
a) Compile-time errors b) Run-time errors
c) Exe time d) None of above
10. If there are no syntax errors in the source code then the program will compile
successfully and we will get a ……………………..file.
a) class b) java c) javac d) document
11. In ………………..exception, the exception will be generated during runtime in Java.
a) Compile-time b) Run-time c) Exe time d) None of
above
12. In the field of Computer Science, indicates whether the command or a program
is
executed successfully or not.
a) “Exit code” b) “Exit status” c) Exit d) Both a or b
13. Which code indicates that the command has been executed successfully?
a) Code “0” b) Exit 0 c) text 0 d) Code 1
14. Which code indicates that some problem has occurred while executing the
command?
a) Code “0” b) Exit 0 c) text 0 d) Code “1”
15. Which package contains a hierarchy of dealing with various exceptions?
a) Java.lang b) java.io c) java.* d) both a and b
16. An attempt to access the array element with an index value that is outside the
range of array uses Which of the following exception. Ex. A[13]=99;
a) ArrayIndexOutOfBound b) ArrayOutOfBound
c) ArrayIndex d) ArrayIndOutBound
17. An attempt to divide any number by 0 (zero) uses which of the following
exception. Ex. Int a=50/0;
a) ArithmeticException b) ArrayIndexOutOfBound
c) ArithException d) NumberFormatException
18. An attempt to use null in a case where an object is required uses Which of the
following exception.
Example – String s=null; System.out.println(s.lengh());
a) NullPointerException b) ArithmeticException
c) ArrayIndexOutOfBound d) All
19. An attempt to convert string to a number type uses which of the following
exception?
Example- String s=”xyz” int i=Integer.parseInt(s);
a) NumberFormatException b) AirthmeticException
c) ArrayIndexOutOfBound d) NullPointer
20. An I/O error has occurred while printing uses which of the following
exception?
a) PrinterIOException b) NullPointerException
c) ArrayIndexException d) NullPrinter
21. Which type of keywords are used to write an exception handler in Java?
a) try b) catch c) finally d) All of these
22.Which keywords are used in the presence of exception which represent block of
statements?
a) try b) catch c) finally d) All of these
23.Which block contains the code that may give rise to one or more exceptions?
a) try b) catch c) finally d) All of these
24. Which block contains the code that is intended to handle exceptions of a
particular type that were created in the associated try block?
a) try b) catch c) finally d) All of these
25.Which block is always executed before the program ends, regardless of whether
any exceptions are generated in the try block or not?
a) try b) catch c) finally d) All of these
26.Which of the following statement contains a block of statements within the
curly
braces?
a) try b) catch c) finally d) All of these
27.The syntax for try block :
try
{ // set of statements that may generate one or more exceptions
}
28. Which is the code that we want to monitor for exceptions, if a problem
occurs
during its execution, an exception is thrown?
a) try b) catch c) finally d) All of these
29.Which block must immediately follow the try block?
a) try b) catch c) finally d) All of these
30. Which block contains the code that is to be executed to handle an
exception?
a) try b) catch c) finally d) All of these
31. Which block is an exception handler, for a single try block there can be one or
more catch blocks?
a) try b) catch c) finally d) All of these
32.The syntax for catch block.
try
{ // set of statements that may generate one or more exceptions
}
catch(Exception_Type Exception_object)
{ //code to handle the exception
}
33. Which block contains a reference to an object which was created and
thrown by
the try block?
a) try b) catch c) finally d) All of these
34. Which block is generally used to clean up at the end of executing a try
block?
a) try b) catch c) finally d) All of these
35.Which block is used when we want to be sure that some particular code is to
run, no matter what exceptions are thrown within the associated try block?
a) try b) catch c) finally d) All of these
36. Which block 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 b) catch c) finally d) All of these
37.The syntax for finally block :
finally
{ // clean-up code to be executed last
// statements within this block always get executed even
through if runtime errors terminate the programabruptly
}
38. Which block must always be followed by at least one block that is either a
catch
block or a finally block?
a) try b) catch c) finally d) All of these
39.Which block is associated with a particular try block and it must be located
immediately following any catch blocks for the corresponding try block?
a) try b) catch c) finally d) throw
40. Which keyword is used to explicitly throw an Exception object?
a) try b) catch c) finally d) throw
41. Who created an exception object and was throwing it automatically?
a) JVM b) JDK c) JRE d) UML
42. The syntax to throw an exception object is :
a) throw exception object; b) throw object;
c) threw object d) THROW
43. Which cause 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) try b) catch c) throw d) throws
44. How many alternate approaches to handle exception created by a
method? Two
1)Write a try-catch block within the method or a constructor that may generate
an exception
2) involving a method or constructor within a try block
45. A throws clause can be used in a method declaration as follows :
method_Modifiers return_type method_Name(parameters)
throws Exception list….
{ ……….
// body of the method
}
46. Which exception classes are not provided by the Java for application
specific
exceptions?
a) Built-in b) user define c) method d) constructor
47.Which method of the Scanner class helps in reading integer input from the
console?
a) nextInt() b) Int( ) c) nextint( ) d) NEXTINT( )