Question 11
EasyCan a single try block be followed by several catch blocks in Java?
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Object-Oriented Programming
Can a single try block be followed by several catch blocks in Java?
No, only one
Only if they are nested
Only for checked exceptions
Yes, one for each exception type to handle
Sign up free to see the answer and a step-by-step explanation.
Which of these is an unchecked exception in Java?
SQLException
ArithmeticException
FileNotFoundException
IOException
Sign up free to see the answer and a step-by-step explanation.
What happens if an exception is never caught anywhere in the program?
The program restarts
It is silently ignored
The exception turns into a warning
The program stops and reports the error
Sign up free to see the answer and a step-by-step explanation.
In Python, which class do ordinary built-in exceptions such as ValueError derive from?
Error
Throwable
Exception
RuntimeError
Sign up free to see the answer and a step-by-step explanation.
Which exception does Java throw for integer division by zero?
NullPointerException
ArithmeticException
NumberFormatException
DivideByZeroError
Sign up free to see the answer and a step-by-step explanation.
Which exception does Python raise for int('abc')?
ValueError
SyntaxError
TypeError
KeyError
Sign up free to see the answer and a step-by-step explanation.
Which exception does Python raise when a list index is out of range?
IndexError
RangeError
KeyError
ValueError
Sign up free to see the answer and a step-by-step explanation.
Which exception does Python raise when a dictionary key doesn't exist?
LookupException
IndexError
NameError
KeyError
Sign up free to see the answer and a step-by-step explanation.
In a Python try statement, when does the else block run?
Always
Only if the try block raised no exception
Never
Only if an exception occurred
Sign up free to see the answer and a step-by-step explanation.
What is a user-defined (custom) exception?
An exception class you create, usually by extending an existing exception class
An exception typed by the user at run time
A syntax error
A warning from the compiler
Sign up free to see the answer and a step-by-step explanation.