WorksheetsFull Stack Quiz 16
Total questions: 20
Worksheet time: 10mins
Which of these keywords are used for the block to be examined for exceptions?
try
catch
throw
check
Which of these keywords are used for generating an exception manually?
try
catch
throw
check
Which of these statements is incorrect?
try block need not to be followed by catch block
try block can be followed by finally block instead of catch block
try can be followed by both catch and finally block
try need not to be followed by anything
1. What is the use of try & catch?
It allows us to manually handle the exception
It allows to fix errors
It prevents automatic terminating of the program in cases when an exception occurs
All of the mentioned
What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
try
{
int a = 0;
int b = 5;
int c = b / a;
System.out.print("Hello");
}
}
}
Hello
World
HelloWOrld
Compilation Error
Which of these keywords are used for the block to handle the exceptions generated by try block?
try
catch
throw
check
Where should you keep your Java code that helps to take action on the exceptions raised inside TRY block?
One more TRY block
CATCH block
FINALLY block
None of the above
If an exception occurs, all the lines of Java code that is below it stops executing. State TRUE or FALSE.
FALSE
TRUE
-
Java exceptions are handled by ____.
Java Compiler
Java Runtime
-
Can you add more than one CATCH block when handling exceptions in Java?
YES
NO
Which are access modifiers below in Java?
public
private
protected
All the above
Where do you keep the Java code that should be executed at all times even if an exception occurs?
inside TRY block
inside CATCH block
inside FINALLY block
All the above
Choose the correct way of writing TRY CATCH FINALLY blocks in Java.
try{} catch{} finally{}
try{} finally{}
try{} catch{}
All the above
How many extra TRY blocks may be present with an existing TRY block in Java?
0
1
2
3
The CATCH block should always be accompanied by a ____ block in Java.
TRY
CATCH
FINALLY
None
How many CATCH blocks may be present in try-catch-finally series of blocks in Java?
1
2
3
any number of catch blocks
Which are the keywords used to handle exceptions in Java?
TRY, CATCH
FINALLY
THROW, THROWS
All the above
Which is the super class in Java that bundles all classes to deal with exceptions and errors?
Error
Exception
Throwable
Throw
What is an Unchecked Exception in Java?
An exception that need not be handled
An exception that may be declared without compiler error
Exceptions which will ignored by the compiler for not catching or for throwing
All the above
A checked exception is the one that:
Needs to be dealt with explicitly by the method either by using try-catch or by propagating the exception to the caller
Need not have to be dealt with explicitly by the method.
None of the above
