Exceptions or OCA Flashcards
how many types of exceptions to be recognized
runtime exceptions, checked exceptions and errors
what is exception
is an event alters the program flow, un wanted event
when occur in execution the program
exceptions are objects?
yes
behind the exceptions generating?
- object created by the JVM
2. thrown to the program
throw keyword?
is used throwing the exception manually, throw aib(object name)--->JVM by using this keyword we can see the exception code in councel.
how could be prove that exceptions are class and throw keyword
for ex; ArithmeticExceptions art= new ArithmeticExceptions(); throw art; // JVM how throw it to program.....
what is the try keyword—-(try catch block)
try {
some code written} catch (name of the exceptions subject name)
if we change the catch- with other exceptions does it work?
no it does not catch anything,-so IndexOutOfBOund Exceptions- not catch the Arithmetics Exceptions
can I add second catch block-multi catch buyer?
yes, it is goingto be same, catch() System.out…
catch()System out….
what is the more one to cover all exceptions like arithmetics, indexoutof bound…
Exception—instead of arithmeticsExceptions, replace the exceptions…
how many types exceptions
uncheked exceptions(runtime exceptions) checked exceptions(Exception and subclasses)
handle or declare rule
Java requires the code either handle or declare in the method signature
difference between Errors and Exception?
Errors indicate serious problems that does not try and catch, Exceptions indicates the situation that can try and catch_ both is child class of throwable
Exceptions—Checked?runtime exceptions
Checked exception must be handled before we can run the program. If ignored then program won’t compile.
Unchecked Exceptions/Runtime Exception
Type of exception where will be thrown during runtime.
It is very challenging to predict. Because it won’t complain during compile time.