1. Which of the following are the most common run-time errors in Java programming.
i) Missing semicolons
ii) Dividing an integer by zero
iii) Converting invalid string to number
iv) Bad reference of objects
A) i and ii only
B) ii and iii only
C) iii and iv only
D) i and iv only
2. Which of the following are the most common compile time errors in Java programming.
i) Missing semicolons
ii) Use of undeclared variables
iii) Attempting to use a negative size for an array
iv) Bad reference of objects
A) i, ii and iii only
B) ii, iii and iv only
C) i, ii and iv only
D) All i, ii, iii and iv
3. The unexpected situations that may occur during program execution are
i) Running out of memory
ii) Resource allocation errors
iii) Inability to find a file
iv) Problems in network
A) i, ii and iii only
B) ii, iii and iv only
C) i, ii and iv only
D) All i, ii, iii and iv
4. The class at the top of the exception classes hierarchy is called ……………………
A) throwable
B) catchable
C) hierarchical
D) ArrayIndexOutofBounds
5. ………………… exception is thrown when an exceptional arithmetic condition has occurred.
A) Numerical
B) Arithmetic
C) Mathematical
D) All of the above
6. ……………………….. exception is caused when an applet tries to perform an action not allowed by the browser’s security setting.
A) Throwable
B) Restricted
C) Security
D) ArrayIndexOutofBounds
7. …………………….. exception is thrown when an attempt is made to access an array element beyond the index of the array.
A) Throwable
B) Restricted
C) Security
D) ArrayIndexOutofBounds
8. You can implement exception-handling in your program by using which of the following keywords.
i) Try ii) NestTry iii) Catch iv) Finally
A) i, ii and iii only
B) ii, iii and iv only
C) i, iii and iv only
D) All i, ii, iii and iv
9. When a ……………………. block is defined, this is guaranteed to execute, regardless of whether or not in exception is thrown.
A) throw
B) catch
C) finally
D) try
10. The ……………………. statement is passed a single parameter, which is reference to the exception object thrown.
A) throw
B) catch
C) finally
D) try
Read Also: Top 20 Objective Questions On Applets In Java
11. Every try statement should be followed by at least one catch statement; otherwise …………………. will occur.
A) no execution
B) null
C) zero
D) compilation error
12. If an exception occurs within the …………………….. block, the appropriate exception-handler that is associated with the try block handles the exception.
A) throw
B) catch
C) finally
D) try
13) Exception classes are available in the ……………………package.
A) java.lang
B) java.awt
C) java.io
D) java.applet
14. …………………….. is caused by general I/O failures, such as inability to read from file.
A) I/O failure
B) I/O exception
C) I/O inability
D) I/O distortion
15. Consider the following try…….. catch block:
class TryCatch
{
public static void main(String args[ ])
{
try
{
double x=0.0;
throw(new Exception("Thrown"));
return;
}
catch(Exception e)
{
System.out.println("Exception caught");
return;
}
finally
{
System.out.println("finally");
}
}
}
What will be the output.
A) Exception caught
B) Exception caught finally
C) finally
D) Thrown
16. Consider the following code snippet:
...................
...................
try {
int x=0;
int y=50/x;
System.out.println("Division by zero");
}
catch(ArithmeticException e) {
System.out.println("catch block");
}
..................
..................
What will be the output?
A) Error.
B) Division by zero
C) Catch block
D) Division by zero Catch block
17. State whether the following statements are True or False.
i) A catch can have comma-separated multiple arguments.
ii) Throwing an Exception always causes program termination.
A) True, False
B) False, True
C) True, True
D) False, False
18. Java uses a keyword ………………… to preface a block of code that is likely to cause an error condition and ‘throw’ an exception.
A) throw
B) catch
C) finally
D) try
19. When an exception in a try block is generated, the Java treats the multiple ………………. statements like cases in switch statement.
A) throw
B) catch
C) finally
D) try
20. The …………………. statement can be used to handle an exception that is not caught by any of the previous catch statement.
A) throw
B) catch
C) finally
D) try
Answers
1. B) ii and iii only
2. C) i, ii and iv only
3. D) All i, ii, iii and iv
4. A) throwable
5. B) Arithmetic
6. C) Security
7. D) ArrayIndexOutofBounds
8. C) i, iii and iv only
9. C) finally
10. B) catch
11. D) compilation error
12. D) try
13. A) java.lang
14. B) I/O exception
15. B) Exception caught finally
16. C) Catch block
17. D) False, False
18. D) try
19. B) catch
20. C) finally
Read Next:Top 20 MCQ Questions On Streams In Java
1 Comment
How can I download all these MCQ