Give a full description of exception handling with relevant examples
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter14: Exception Handling
Section: Chapter Questions
Problem 24SA
Related questions
Question
Give a full description of exception handling with relevant examples
Expert Solution
Exception Handling
Exception Handling is a process of handling few things which cause the program to terminate
Exceptions are different from Errors and these Exceptions can be handled by user
The Exceptions can be caught by using catch block when you expect an Exception might occur and this must be written in try block to make compiler understand
Thought the Exception is caught, the statements after the Exception occurred doesn't gets executed.
So, to make any statements to gets executed, we use finally block.
Example:
int a=5;
int b=0;
System.out.println(a/b); //it throws an Exception as denominator cannot be 0
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning