Do you consider yourself a good programmer? How much do you know about exception handling? Take this trivia quiz and check your programming skills. Applications in a computer are expected to run smoothly with no downtime, but this is entirely not the case. When there is an anomaly in the application, a program is expected to have some information on exceptional handling to correct it. The quiz below is designed to check just what you know about this process. Try it out!
If run with no arguments, the program will produce no output.
If run with no arguments, the program will print "The end".
The program will throw an ArrayIndexOutOfBoundsException
If run with one argument, the program will simply print the given argument
If run with one argument, the program will print the given argument followed by "The end"
Rate this question:
The main()method must declare that it throws B.
The finally block must follow the catch block in the main()method.
The catch block in the main()method must declare that it catches B rather than A.
A single tryblock cannot be followed by both a finallyand a catchblock
The declaration of class A is illegal
Rate this question:
Does not need to specify any exceptions.
Needs to specify that it throws ArithmeticException
Needs to specify that it throws InterruptedException.
Needs to specify that it throws RuntimeException
Needs to specify that it throws both ArithmeticExceptionand InterruptedException.
Rate this question:
The code will fail to compile because the main()method does not declare that it throws RuntimeExceptionin its declaration
The program will fail to compile because it cannot throw re.
The program will compile without error and will throw java.lang.RuntimeExceptionwhen run.
The program will compile without error and will throw java.lang.NullPointerExceptionwhen run
The program will compile without error and will run and terminate without any output
Rate this question:
If an exception is not caught in a method, the method will terminate and normal execution will resume.
An overriding method must declare that it throws the same exception classes as the method it overrides
The main()method of a program can declare that it throws checked exceptions.
A method declaring that it throws a certain exception class may throw instances of any subclass of that exception class
Finallyblocks are executed if, and only if, an exception gets thrown while inside the corresponding tryblock
Rate this question:
The program will only print 5.
The program will only print 1and 4, in that order.
The program will only print 1, 2, and 4, in that order
The program will only print 1, 4, and 5, in that order
The program will only print 1, 2,4, and 5, in that order.
The program will only print 3 and 5, in that order.
Rate this question:
The program will print 5.
The program will print 1and 4, in that order.
The program will print 1,2, and 4, in that order.
The program will print 1,4, and 5, in that order.
The program will print 1,2, 4, and 5, in that order
The program will print 3and 5, in that order.
Rate this question:
The main()method must declare that it throws RuntimeException.
The overriding f()method in MyClassmust declare that it throws ArithmeticException, since the f()method in class Adeclares that it does
The overriding f()method in MyClassis not allowed to throw InterruptedException, since the f()method in class Adoes not throw this exception
The compiler will complain that the catch(ArithmeticException)block shadows the catch(Exception)block
You cannot throw exceptions from a catchblock
Nothing is wrong with the code, it will compile without errors.
Rate this question:
The program will print 2and throw InterruptedException.
The program will print 1and 2, in that order.
The program will print 1,2, and 3, in that order.
The program will print 2 and 3, in that order.
The program will print 3 and 2, in that order.
The program will print 1 and 3, in that order.
Rate this question:
Exception
Catchable
Option 3
Throwable
Rate this question:
Quiz Review Timeline +
Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.
Wait!
Here's an interesting quiz for you.