Question:
In Java, which block is always guaranteed to execute regardless of whether an exception is thrown or caught?
जावा में, कौन-सा ब्लॉक अपवाद (Exception) आने या न आने की परवाह किए बिना हमेशा निष्पादित होने की गारंटी देता है?
Options:
- finally block
- catch block
- try block
- throw block
- finally ब्लॉक
- catch ब्लॉक
- try ब्लॉक
- throw ब्लॉक
Correct Answer: a)
Explanation:
The finally block in Java executes after the try/catch blocks finish, ensuring cleanup code (closing files, db connections) is run under all circumstances (Option a).
जावा में finally ब्लॉक हमेशा निष्पादित होता है, चाहे कोई अपवाद उत्पन्न हुआ हो या नहीं (विकल्प a)।