Q(b). What is an exception? Explain various causes of exceptions. How exceptions are handled in java? Explain concept of exception hierarchy.
- Exception: Runtime event disrupting normal program flow, indicating an error.
- Causes: User input, resource issues (e.g., `FileNotFoundException`), programming errors (e.g., `ArithmeticException`).
- Handling: `try-catch-finally` blocks manage exceptions for graceful recovery.
- `throw` explicitly raises, `throws` declares exceptions in method signatures.
Answer: An exception in Java is an event that disrupts the normal flow of a program's execution at runtime. It signifies an abnormal or error condition that the program needs to address. When an exception occurs, the normal execution sequence is abruptly terminated, and the system attempts to find an appropriate exception handler. This mechanism is crucial for gracefully managing and recovering from unexpected situations. Exceptions can arise from various sources, indicating problems both internal and ...