ID: 12933 Date: 08/04/2024 Subject: Visual Programming: Name: Shahid Iqbal

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Name: Shahid Iqbal

ID: 12933
Date: 08/04/2024
Subject: Visual
Programming
Assignment 4
Total Marks: 10

Assignment Details:
1. Explain different types of exception handling and define when and where it can used in your
own words.
2. Write a C# window interface program and print its output that prompts the user to input two
numbers and divide them. Handle an exception when the user enters non-numeric values.

Question No 01 Answer:
Programming's essential component of exception handling aids in the management of
unforeseen mistakes or extraordinary circumstances that may occur while a program is being
executed. Three main categories of exception handling exist:

Try-Catch:
This style of handling exceptions entails encapsulating potentially problematic code in a try
block, and then using one or more catch blocks to capture and handle the exception. It makes
it possible for the software to handle failures politely and avoid crashing.

Throw:
This is the process of manually utilizing the throw keyword to throw exceptions. It is helpful
when you wish to state clearly that an extraordinary condition has occurred in accordance
with the standards that you have specified in your code.
Whether or not an exception occurs, code is executed in the finally block. Usually, it's used to
free up resources or carry out some essential tasks that must always be completed, such
shutting down files or releasing memory.

Anywhere there's a chance of unexpected behaviors or runtime failures in your code, you
should employ exception handling. It's crucial in scenarios like file input/output, network
activities, and user interactions when there is some degree of control over outside influences
or human input. You can improve the robustness and dependability of your software by using
exception handling, which makes sure that failures are handled gracefully and that
unexpected crashes are avoided.

Question NO 02 Answer:

You might also like