Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Exception & Error HandlingEasy
Q1. What is an exception?
- A.A function call to a subroutine in the program
- B.An abnormal event disrupting normal program flow✓ Correct
- C.A normal expected program event during execution
- D.A variable type for storing error code values
Explanation
An exception is an event during execution that disrupts the normal flow.
Report an error in this question
Exception & Error HandlingEasy
Q2. What is a try-catch block?
- A.A function definition with parameters and body
- B.A looping construct for repeated iteration
- C.A construct attempting code and handling exceptions✓ Correct
- D.A conditional statement for branching logic
Explanation
A try-catch block executes code in the try section and catches/handles any exceptions in the catch section.
Report an error in this question
Exception & Error HandlingEasy
Q3. What is the purpose of the 'finally' block?
- A.To define a new function with a specific name
- B.To terminate the program execution immediately
- C.To execute code regardless of exception outcome✓ Correct
- D.To finalize a variable and prevent changes
Explanation
The finally block always executes after try/catch, whether or not an exception was thrown.
Report an error in this question
Exception & Error HandlingEasy
Q4. What is a NullPointerException?
- A.A compile-time syntax error in the code
- B.A valid and expected operation result
- C.A warning generated by the code linter
- D.An exception from using a null reference✓ Correct
Explanation
A NullPointerException occurs when trying to access a member or method on a reference that is null.
Report an error in this question
Exception & Error HandlingEasy
Q5. What does 'throw' do in exception handling?
- A.Ignores an exception and continues running
- B.Explicitly raises and creates an exception✓ Correct
- C.Logs an exception message to the console
- D.Catches an exception from the try block
Explanation
The throw keyword explicitly raises an exception, transferring control to the nearest matching catch block.
Report an error in this question
Exception & Error HandlingEasy
Q6. What is an ArithmeticException?
- A.A type mismatch between two variable types
- B.A file not found error during I/O access
- C.An exception for illegal arithmetic operations✓ Correct
- D.A syntax error in the source code text
Explanation
ArithmeticException is thrown when an illegal arithmetic operation occurs, most commonly division by zero.
Report an error in this question
Exception & Error HandlingEasy
Q7. What is the difference between compile-time and runtime errors?
- A.Compile-time errors cause the running program to crash unexpectedly
- B.Runtime errors are detected and caught by the compiler before running
- C.Compile-time errors are caught before execution; runtime during it✓ Correct
- D.There is no meaningful difference between the two error types
Explanation
Compile-time errors are detected by the compiler before running. Runtime errors occur during program execution.
Report an error in this question
Exception & Error HandlingEasy
Q8. What is an ArrayIndexOutOfBoundsException?
- A.A type error from wrong array element types
- B.An exception for accessing an invalid index✓ Correct
- C.A memory leak from unreleased array memory
- D.A valid and expected array access result
Explanation
This exception is thrown when trying to access an array element with an index that is negative or beyond the array length.
Report an error in this question
Exception & Error HandlingEasy
Q9. Can you have multiple catch blocks for one try?
- A.Yes, to handle different exception types differently✓ Correct
- B.No, only one catch block is allowed per try statement
- C.Only for a maximum of exactly two exception types total
- D.Only in Python, not in any other programming language
Explanation
Multiple catch blocks can follow a single try block, each handling a different exception type.
Report an error in this question
Exception & Error HandlingEasy
Q10. What is an error message?
- A.A variable name used for storing error data
- B.A text description about what went wrong✓ Correct
- C.A function output returned to calling code
- D.A comment written inside the source code
Explanation
An error message is a descriptive text associated with an exception that explains what went wrong.
Report an error in this question
Exception & Error HandlingMedium
Q11. What is the difference between checked and unchecked exceptions in Java?
- A.Unchecked exceptions are always more severe than checked exceptions
- B.Checked exceptions are always faster to handle than unchecked ones
- C.Checked must be declared or caught; unchecked RuntimeExceptions do not✓ Correct
- D.There is no meaningful difference between the two exception types
Explanation
Checked exceptions must be either caught or declared. Unchecked exceptions don't require explicit handling.
Report an error in this question
Exception & Error HandlingMedium
Q12. What is exception propagation?
- A.Unhandled exception moving up the call stack to find a handler✓ Correct
- B.Fixing an exception by catching and logging it
- C.Logging all exceptions to a file for later review and analysis
- D.Throwing multiple exceptions at the same time from one method
Explanation
When a method doesn't handle an exception, it propagates up the call stack until a handler is found or the program terminates.
Report an error in this question
Exception & Error HandlingMedium
Q13. What is a custom exception?
- A.A user-defined exception class for domain-specific errors✓ Correct
- B.A syntax error detected during the compilation process
- C.A warning generated by the IDE during code development
- D.A built-in exception provided by the language runtime
Explanation
Custom exceptions are user-created exception classes for representing specific error conditions in the application domain.
Report an error in this question
Exception & Error HandlingMedium
Q14. What is the 'throws' keyword in Java?
- A.A keyword for suppressing exceptions so they are ignored
- B.A mechanism for catching and handling thrown exceptions
- C.It is exactly the same as the throw keyword in Java
- D.A declaration of which checked exceptions a method may throw✓ Correct
Explanation
'throws' in a method signature declares which checked exceptions the method may throw.
Report an error in this question
Exception & Error HandlingMedium
Q15. What is a stack trace?
- A.A log file containing all program output and error data
- B.The call stack data structure itself in memory
- C.A memory dump of the entire program state at crash
- D.A report showing the method call chain to an exception✓ Correct
Explanation
A stack trace displays the chain of method calls from the point where the exception occurred, aiding in debugging.
Report an error in this question
Exception & Error HandlingMedium
Q16. What is the purpose of try-with-resources in Java?
- A.To automatically close resources when the try block finishes✓ Correct
- B.To try executing multiple methods in parallel simultaneously
- C.To retry the try block harder if the first attempt fails
- D.To allocate additional resources for the try block execution
Explanation
Try-with-resources automatically closes resources that implement AutoCloseable when the try block exits.
Report an error in this question
Exception & Error HandlingMedium
Q17. What is the difference between Error and Exception in Java?
- A.Errors are serious JVM problems; Exceptions are recoverable issues✓ Correct
- B.Exceptions cannot be caught or handled by any catch block
- C.They are the same thing with no meaningful differences at all
- D.Errors are less serious and easier to handle than Exceptions
Explanation
Errors represent serious JVM problems. Exceptions represent conditions that applications can reasonably catch and recover from.
Report an error in this question
Exception & Error HandlingMedium
Q18. What is a try-except-else block in Python?
- A.An advanced loop construct for iterating with error handling
- B.try runs risky code; except handles; else runs if no exception✓ Correct
- C.Invalid syntax that causes a compilation error
- D.A triple try block for handling three exceptions at once
Explanation
In Python, else after except runs only when no exception was raised in the try block.
Report an error in this question
Exception & Error HandlingMedium
Q19. What is exception chaining?
- A.Throwing many exceptions at the same time from one method call
- B.Catching exceptions in a specific order from most to least severe
- C.Wrapping one exception inside another to preserve original cause✓ Correct
- D.A linked list of error objects stored in chronological order
Explanation
Exception chaining wraps the original exception inside a new one, preserving the full error context for debugging.
Report an error in this question
Exception & Error HandlingMedium
Q20. What is the principle of 'fail fast'?
- A.Testing the speed of program execution under various load levels
- B.Detecting and reporting errors as soon as they occur in the program✓ Correct
- C.Making programs crash as quickly as possible for testing purposes
- D.Running programs as quickly as possible to improve the performance
Explanation
Fail fast means detecting problems at the earliest possible point and reporting them immediately.
Report an error in this question
Exception & Error HandlingHard
Q21. What is the difference between fault tolerance and exception handling?
- A.Exception handling prevents all errors from ever occurring in the program
- B.Exception handling manages code errors; fault tolerance is system resilience✓ Correct
- C.They are exactly the same concept with no practical differences at all
- D.Fault tolerance is always faster and easier to implement than exceptions
Explanation
Exception handling is a programming mechanism for managing errors. Fault tolerance is a broader system design principle for continued operation despite failures.
Report an error in this question
Exception & Error HandlingHard
Q22. What is an exception safety guarantee?
- A.A guarantee that no exceptions will ever occur in the program
- B.Levels of state guarantees after exception: no-throw, strong, basic✓ Correct
- C.A compiler feature that eliminates all runtime exceptions automatically
- D.A testing tool that verifies exception handlers work correctly always
Explanation
Exception safety guarantees define what happens to program state when an exception is thrown: no-throw, strong (rollback), basic (valid state), or no guarantee.
Report an error in this question
Exception & Error HandlingHard
Q23. What is the 'catch-all' anti-pattern?
- A.A testing pattern for verifying exception handler correctness
- B.Catching all exceptions generically which hides bugs in code✓ Correct
- C.Catching only specific well-defined exceptions in the code
- D.A recommended design pattern for robust exception handling
Explanation
Catching all exceptions with a generic handler masks unexpected errors and makes debugging significantly harder.
Report an error in this question
Exception & Error HandlingHard
Q24. What is the difference between recoverable and unrecoverable errors?
- A.There is no meaningful difference between the two error categories
- B.All errors in every program are always recoverable with proper code
- C.All errors in every program are always unrecoverable without fixes
- D.Recoverable errors can be handled; unrecoverable require termination✓ Correct
Explanation
Recoverable errors can be handled gracefully. Unrecoverable errors typically require program termination.
Report an error in this question
Exception & Error HandlingHard
Q25. What is Result/Either type as an alternative to exceptions?
- A.A logging mechanism for recording exception messages
- B.A type representing either success value or error value✓ Correct
- C.A direct replacement for try-catch in all situations
- D.A simple boolean type with true or false values
Explanation
Result/Either types encode success or failure in the return type, making error handling explicit and checked at compile time.
Report an error in this question
Exception & Error HandlingHard
Q26. What is the problem with exceptions and concurrency?
- A.Exceptions in one thread may not be visible in another thread✓ Correct
- B.No problems exist between exceptions and concurrency at all
- C.Concurrency completely prevents all exceptions from occurring
- D.Exceptions are inherently thread-safe in all implementations
Explanation
In concurrent programming, exceptions in child threads don't automatically propagate to the parent thread.
Report an error in this question
Exception & Error HandlingHard
Q27. What is a panic in Rust/Go?
- A.A regular exception like any other in the language
- B.A warning message that can be safely ignored by developers
- C.An unrecoverable error that unwinds the stack and terminates✓ Correct
- D.A debug log entry recorded during program execution review
Explanation
A panic represents an unrecoverable error that unwinds the call stack and terminates the current thread or program.
Report an error in this question
Exception & Error HandlingHard
Q28. What is structured concurrency's approach to exception handling?
- A.Ignoring all exceptions thrown by child tasks completely
- B.Propagating child exceptions to parent and cancelling siblings✓ Correct
- C.Logging exceptions only without any propagation to parents
- D.Catching all exceptions silently without any further action
Explanation
Structured concurrency ensures that when a child task fails, its exception propagates to the parent and all sibling tasks are cancelled.
Report an error in this question
Exception & Error HandlingHard
Q29. What is the difference between resumable and non-resumable exceptions?
- A.Resumable allows continuing at throw point; non-resumable unwinds✓ Correct
- B.There is no meaningful difference between the two exception types
- C.Non-resumable exceptions can be resumed after the handler finishes
- D.Resumable exceptions are always slower than non-resumable exceptions
Explanation
Non-resumable exceptions unwind the stack. Resumable exceptions allow the handler to fix the issue and resume at the throw point.
Report an error in this question
Exception & Error HandlingHard
Q30. What is the 'exception specification' problem in C++?
- A.Exception specifications are completely reliable and always enforced
- B.They always improve performance of exception handling in all cases
- C.They are required by the C++ standard for every function definition
- D.C++ throw() specs were problematic and replaced by noexcept keyword✓ Correct
Explanation
C++ dynamic exception specifications were deprecated because they couldn't be verified at compile time; noexcept is the modern replacement.
Report an error in this question