Exception Handling Interview Questions In Java

Pubblicato il: 30 maggio 2022
sul canale di: CloudTech
10,220
232

In this video, we will discuss exception handling interview questions. We will all the questions with practical examples.

Q.1.) What is an exception?
Exception is an abnormal condition that occurs during program execution and disrupts the normal flow of the program
If an exception is not handled, then it terminates the program abruptly

Q.2.) How are exceptions handled in Java?
Exceptions are handled with the help of try, catch and finally block.
try - surround the code in try block where exception might occur
catch - catch block handles the exception gracefully

Q.3.) What is finally Block?
Finally blocks are executed every time
Finally blocks are executed when exception occurs or doesn’t occur

Q.4.) Can we avoid the execution of finally block?
Finally block is not executed when System.exit is called either from try or catch block
This is the only case when finally block is not executed

Q.5.) Can we have multiple catch block for a try block?
Yes. We can have multiple catch block for a try block

Q.6.) What is unreachable catch block in Java?
Catch block becomes unreachable when broader exception is handled before specific exception.

Q.7.) Can we have try block without catch or finally?
No. You cannot write try block without catch or finally


In questa pagina del sito puoi guardare il video online Exception Handling Interview Questions In Java della durata di ore minuti seconda in buona qualità , che l'utente ha caricato CloudTech 30 maggio 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 10,220 volte e gli è piaciuto 232 spettatori. Buona visione!