What is meant by Exception?
- Answer: An Exception is a problem that can occur during the normal flow of execution. A method can throw an exception when something wails at runtime. If that exception couldn’t be handled, then the execution gets terminated before it completes the task.
- If we handled the exception, then the normal flow gets continued. Exceptions are a subclass of java.lang.Exception
Example for handling Exception:
try{
//Risky codes are surrounded by this block
}catch(Exception e){
//Exceptions are caught in catch block
}