Java Interview Exception Concept

 

Exception Handling:- 

1) If There are parent child class and if parent class throws exception than child class override method should throws the same exception otherwise compiler will give an error . 





2)  If Parent throws IO Exception than child should also throw the same any thing other than IOException will give an error.




3) Can we use try alone no we can't 



4)  try with multiple resource 


5) finally, final, and finalize in Java 


Above image source :- Google



6) NoClassDefFoundError and ClassNotFoundException


                                Above image source :- Google
 
7)  try catch finally






A finally block will not execute due to other conditions like when JVM runs out of memory when our java process is killed forcefully from task manager or console when our machine shuts down due to power failure and deadlock condition in our try block.


















8) Finally block will be executed always until unless some one use System.exit either in try block or catch block . 

9) try with multiple catch are allowed by Exception should't be defined in first catch since it's parent class for exception . 


10)  Inside finally we can use try catch block .

11) try with resource after Java 7  is allowed



java.lang.Throwable is the superclass for all types of errors and exceptions in java.



Collection Concept :- Link  




















Comments

Popular posts from this blog

Converting JSONArray into CSV file in java

Java Design pattern

Map class field to map