---
title: "If I write System.exit (0); at the end of the try block, will the finally block still execute?"  
description: "If I write System.exit (0); at the end of the try block, will the finally block still execute?"  
author: "Sumit Kesarwani"  
published: 2014-11-20  
updated: 2020-09-17  
canonical: https://www.mindstick.com/interview/2256/if-i-write-system-exit-0-at-the-end-of-the-try-block-will-the-finally-block-still-execute  
category: ".net"  
tags: [".net", "exception handling"]  
reading_time: 1 minute  

---

# If I write System.exit (0); at the end of the try block, will the finally block still execute?

No in this case the finally block will not execute because when you say system.exit(0),the control immediately goes out of the program, and thus finally never executes.

## Answers

### Answer by Sumit Kesarwani

No in this case the finally block will not execute because when you say system.exit(0),the control immediately goes out of the program, and thus finally never executes.


---

Original Source: https://www.mindstick.com/interview/2256/if-i-write-system-exit-0-at-the-end-of-the-try-block-will-the-finally-block-still-execute

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
