Sobes.tech
Junior — Middle

Will the code in the finally block be executed if System.exit is called during the try block?

sobes.tech AI

Answer from AI

If during the execution of a try block System.exit() is called, the JVM begins the process of shutting down the application, and the finally block will not be executed. This is because System.exit() initiates an immediate JVM shutdown, and no subsequent code, including finally, is executed.