0

When Exceptions occur there runtime or compiletime??

Exceptions

13th Oct 2019, 3:52 AM
MANISH KUMAR 🌐
MANISH KUMAR  🌐 - avatar
2 Respostas
0
Checked Exceptions are the exceptions that we can typically foresee and plan ahead in our application. These are also exceptions that the Java Compiler requires us to either handle-or-declare when writing code. The handle-or-declare rule refers to our responsibility to either declare that a method throws an exception up the call stack - without doing much to prevent it or handle the exception with our own code, which typically leads to the recovery of the program from the exceptional condition. The compiler can detect them before runtime, and you're aware of their potential existence while writing code. Unchecked Exceptions are the exceptions that typically occur due to human, rather than an environmental error. These exceptions are not checked during compile-time, but at runtime, which is the reason they're also called Runtime Exceptions. They can often be countered by implementing simple checks before a segment of code that could potentially be used in a way that forms a runtime exception.
13th Oct 2019, 4:59 AM
Alice
Alice - avatar
0
"exception is an event, which occurs during the execution" https://docs.oracle.com/javase/tutorial/essential/exceptions/definition.html exception is something what you can catch (with try-catch statement), and you can do it only in runtime
13th Oct 2019, 1:25 PM
zemiak