Exception handling with try-throw-catch-finally constructs - Java test

Exception handling with try-throw-catch-finally constructs - Java test


1) The classes that extend Throwable class except RuntimeException and Error are known as?

A) Checked Exception
B) Unchecked Exception
C) Error
D) None of the above
View Answer / Hide Answer

ANSWER: A) Checked Exception




2) Exception Handling is a mechanism to handle runtime errors?

A) True
B) False
View Answer / Hide Answer

ANSWER: A) True




3) These five keywords are used in try, catch, finally, throw, and throws?

A) Exception Handling
B) String Handling
C) Event Handling
D) None of the above
View Answer / Hide Answer

ANSWER: A) Exception Handling




4) Which provides a default exception handler that performs the following tasks?

- Prints out exception description.
- Prints the stack trace (Hierarchy of methods where the exception occurred).
- Causes the program to terminate.

A) JVM
B) JDK
C) JRE
D) None of the above
View Answer / Hide Answer

ANSWER: A) JVM




5) Which provides the mechanism to handle the runtime errors so that normal flow of the application can be maintained?

A) Exception Handling
B) String Handling
C) Event Handling
D) None of the above
View Answer / Hide Answer

ANSWER: A) Exception Handling




6) If the superclass method does not declare an exception, subclass overridden method cannot declare the checked exception?

A) True
B) False
View Answer / Hide Answer

ANSWER: A) True




7) Which allows us to control the normal flow of the program by using exception handling in program?

A) Exception Handling
B) String Handling
C) Event Handling
D) None of the above
View Answer / Hide Answer

ANSWER: A) Exception Handling




8) These exceptions are seen in

NullPointerException,
ArrayIndexOutOfBoundsException,
ArithmeticException,
NumberFormatException ?

A) Checked exception
B) Unchecked exception
C) Both A & B
D) None of the above
View Answer / Hide Answer

ANSWER: B) Unchecked exception




9) Which block contains a block of program statements within which an exception might occur?

A) Catch
B) try
C) throw
D) final
View Answer / Hide Answer

ANSWER: B) try




10) The Exception class has two main subclasses?

A) IOException class
B) RuntimeException Class
C) ClassCastException
D) Both A & B
View Answer / Hide Answer

ANSWER: D) Both A & B




11) PatternSyntaxException Class Methods is an unchecked exception that indicates a syntax error in a regular expression pattern?

A) True
B) False
View Answer / Hide Answer

ANSWER: A) True




12) Which is a superclass of all exception classes?

A) Throwable
B) Exception
C) RuntimeException
D) IOException
View Answer / Hide Answer

ANSWER: A) Throwable




13) If we want to create our own exception class then we have to?

A) Use throw keyword
B) Use final keyword
C) Extend exception class
D) Use try and catch block
View Answer / Hide Answer

ANSWER: C) Extend exception class




14) Which Exception occurs when a class is not found while dynamically loading a class using the class loaders?

A) ClassNotFoundException
B) ClassFoundException
C) NoClassDefFoundError
D) ClassDefFoundError
View Answer / Hide Answer

ANSWER: A) ClassNotFoundException




15) Which class is used when a program does not want to handle exception?

A) Throws
B) Try
C) Catch
D) Final
View Answer / Hide Answer

ANSWER: A) Throws




16) Which keyword is used for the block to handle the exceptions generated by try block?

A) Catch
B) Final
C) throw
D) try
View Answer / Hide Answer

ANSWER: A) Catch




17) The classes that extend Throwable class except RuntimeException and Error are known as?

A) Checked Exception
B) Unchecked Exception
C) Error
D) None of the above
View Answer / Hide Answer

ANSWER: A) Checked Exception




18) Unchecked exceptions are checked at compile-time rather they are checked at runtime?

A) True
B) False
View Answer / Hide Answer

ANSWER: B) False




19) Which is irrecoverable?

A) Error
B) Checked Exception
C) Unchecked Exception
D) Both B & C
View Answer / Hide Answer

ANSWER: A) Error




20) If you are inserting any value in the wrong index as shown below, it would result in

1. int a[]=new int[5];
2. a[10]=50;

A) NullPointerException
B) ArrayIndexOutOfBoundsException
C) ArithmeticException
D) NumberFormatException
View Answer / Hide Answer

ANSWER: B) ArrayIndexOutOfBoundsException



Post your comment

    Discussion

  • RE: Exception handling with try-throw-catch-finally constructs - Java test -jitender (11/08/15)
  • Super class of all exceptions is Exception instead of throwable.