Friends Anyone Knows the Full Explanation About Exception Handling.Why it came's how it can be useful in Programming Development and what are the problems we are having through Exception.Below I place The Answers for these Questions.
Updated Exception Handling In Java
Q)What is Exception?
Exception is an abnormal condition.In java, exception is an event that disrupts the normal flow of the program.
syntax:
public class MyException
{
public static void main(String[] args)
{
try
{
return;
}
finally
{
System.out.println( "Finally" );
}
}
}
Use Of Exception Handling
The core advantage of exception handling is to maintain the normal flow of the application.
Exception normally disrupts the normal flow of the application that is why we use exception
handling. Let's take a scenario:
statement1;
statement1;
statement2;
statement3;
statement4;
statement5;
statement6;/*exception occurs at statement 6*/
statement7;
statement8;
statement9;
statement10;
statement11;
Suppose there is 11 statements in your program and there occurs an exception at statement 6, rest of the code will not be executed i.e. statement 6 to 11 will not run. If we perform exception handling, rest of the statement will be executed. That is why we use exception handling in java.
Friends You Like My Post Please Share to your Friends because sharing is caring.Share the Link through Social Medial Like Facebook,Google+,Twitter etc and You feel to ask any Question about this Topic i clarify your doubts.
statement1;
statement1;
statement2;
statement3;
statement4;
statement5;
statement6;/*exception occurs at statement 6*/
statement7;
statement8;
statement9;
statement10;
statement11;
Suppose there is 11 statements in your program and there occurs an exception at statement 6, rest of the code will not be executed i.e. statement 6 to 11 will not run. If we perform exception handling, rest of the statement will be executed. That is why we use exception handling in java.
Friends You Like My Post Please Share to your Friends because sharing is caring.Share the Link through Social Medial Like Facebook,Google+,Twitter etc and You feel to ask any Question about this Topic i clarify your doubts.
0 comments:
Post a Comment