Java Tutorial - 7 | Edureka

Take instructor-led Live class on Java Tutorial at : <br /> <a href="http://www.edureka.co/java-course" title="http://www.edureka.co/java-course" target='_blank'>http://www.edureka.co/java-course</a><br /> <br /> <br /> The following topics were covered in this Java Tutorial:<br /> Exception, Exception handling, Throw and Throws keyword, Finally keyword, Runtime Exception, Error, Error handling.<br /> <br /> Exceptions:<br /> Exception is the one that stops the execution of the program unexpectedly. All of the sudden the program stops and returns an error. The process of handling these exceptions is called Exception Handling.<br /> If you want to write a program and if you know that an exception can occur at a particular point of code then you can handle that exception using some mechanisms. Now that application will not stop even if an exception occurs in the program. This is the advantage of exception handling.<br /> Types of Exceptions:<br /> Run-time exceptions: These exceptions will occur at run- time i.e when you run your application. Due to this exception your java application will halt. These exceptions are also called as Unchecked Exceptions. These exceptions are handled at run-time i.e by JVM after they have occurred by using try and catch block. Example: ArrayIndexOutOfBoundsException, ArithmeticException, NullPointerException<br /> Compile Enforced Exceptions: Before running, the compiler itself tells you that there is a chance of getting an exception or something wrong with your program. These exceptions are also called as Checked Exceptions. These exceptions are handled by java complier before they occur by using throws keyword. Example: IOException, FileNotFoundException.<br /> <br /> Exception Classes: <br /> Once you have an object there is &quot;Throwable&quot; class. Within which you have two things Error and Exception. Again the exceptions are of two types: compile-enforced exception, Run-time exception.<br /> Exception Handling Mechanism:<br /> There are 3 ways to handle the run-time exceptions: try block, catch block, finally block.In try block we try some part of the code where you feel that an exception will occur. If an exception has occurred then that exception will be sent to catch block to handle. If no exception arises then the program will execute normally.<br /> <br /> <br /> &quot;throw&quot; is a keyword which is used to call the sub class of an exception class. This keyword is also used to throw the exception occurred in try block to catch block. While throwing an exception you can also send message to catch block which has to be printed when an exception occurs.<br /> Finally:<br /> When we want a set of statements to be executed even after an exception has occurred then we use finally block. <br /> throws:<br /> To handle the compiler-enforced exceptions we use &quot;throws&quot; keyword. &quot;throws&quot; is applied to methods or a class for which there is a chance of rising an exception during its execution.<br /> <br /> User-defined Exception:<br /> Across built-in exceptions user can also define his own exceptions. It can be done by defining a class that extends Exception class and creating a constructor of the class (user-defined) with string argument to print that message when exception occurs. Here why we need to string argument to the constructor because every exception will return a message in the form of a string.<br /> <br /> Error and Error Handling:<br /> There are two types of error: Design- time error and Logical error.<br /> <br /> Design-time error: These are the errors that occur while designing the programs. Example for Design errors is syntax errors. These errors will be shown with a red mark in eclipse IDE so that you can easily find and correct it. Missing a semicolon will return design time error.<br /> <br /> Advantages of Exception:<br /> The program will still execute even if an exception arises i.e finally block i.e if you need a part of code to be executed necessarily then place that code in finally block.<br /> <br /> If you can&#039;t handle the exception JVM will handle the exception if we use throws keyword.<br /> <br /> We can differentiate the exceptions that have occurred. If you get array index out of bound exception then it indicates that we are trying to perform an action on the array element exceeding the size of the array. When you divide a number by zero you will get an arithmetic exception. So you can differentiate the exceptions that have occurred.<br /> <br /> Logical error: These are the errors done by programmer. Even though the program is syntactically correct the program will not produce expected output i.e. the programs with these errors will run but does not produce desired results. Such type of errors is called logical errors. Example for logical error is getting division of two numbers as output instead of expected output of multiplication of numbers. These errors can be rectified by understanding the logic and checking whether it is works out correctly or not. <br /> <br /> Please write back to us at support@edureka.in or call us at +91-8880862004 for more information. <br /> <br /> Visit - <a href="http://www.edureka.co/java-course" title="http://www.edureka.co/java-course" target='_blank'>http://www.edureka.co/java-course</a><i class="fa fa-language transViewIcon clickable" title="Translation"></i>

Java Tutorial - 7 | Edureka
Video date 2013/03/27 00:55
Play musics without ads!
Java Tutorial - 7 | Edureka
Once shared, this message disappears.
https://i.ytimg.com/vi/I138kfQCorw/mqdefault.jpg
https://www.youtube.com/embed/I138kfQCorw
Java Tutorial - 7 | Edureka
30
01:41:08Java Tutorial - 7 | Edureka
Java Tutorial - 7 | Edureka
00:00
Loading...
Take instructor-led Live class on Java Tutorial at :
http://www.edureka.co/java-course


The following topics were covered in this Java Tutorial:
Exception, Exception handling, Throw and Throws keyword, Finally keyword, Runtime Exception, Error, Error handling.

Exceptions:
Exception is the one that stops the execution of the program unexpectedly. All of the sudden the program stops and returns an error. The process of handling these exceptions is called Exception Handling.
If you want to write a program and if you know that an exception can occur at a particular point of code then you can handle that exception using some mechanisms. Now that application will not stop even if an exception occurs in the program. This is the advantage of exception handling.
Types of Exceptions:
Run-time exceptions: These exceptions will occur at run- time i.e when you run your application. Due to this exception your java application will halt. These exceptions are also called as Unchecked Exceptions. These exceptions are handled at run-time i.e by JVM after they have occurred by using try and catch block. Example: ArrayIndexOutOfBoundsException, ArithmeticException, NullPointerException
Compile Enforced Exceptions: Before running, the compiler itself tells you that there is a chance of getting an exception or something wrong with your program. These exceptions are also called as Checked Exceptions. These exceptions are handled by java complier before they occur by using throws keyword. Example: IOException, FileNotFoundException.

Exception Classes:
Once you have an object there is "Throwable" class. Within which you have two things Error and Exception. Again the exceptions are of two types: compile-enforced exception, Run-time exception.
Exception Handling Mechanism:
There are 3 ways to handle the run-time exceptions: try block, catch block, finally block.In try block we try some part of the code where you feel that an exception will occur. If an exception has occurred then that exception will be sent to catch block to handle. If no exception arises then the program will execute normally.


"throw" is a keyword which is used to call the sub class of an exception class. This keyword is also used to throw the exception occurred in try block to catch block. While throwing an exception you can also send message to catch block which has to be printed when an exception occurs.
Finally:
When we want a set of statements to be executed even after an exception has occurred then we use finally block.
throws:
To handle the compiler-enforced exceptions we use "throws" keyword. "throws" is applied to methods or a class for which there is a chance of rising an exception during its execution.

User-defined Exception:
Across built-in exceptions user can also define his own exceptions. It can be done by defining a class that extends Exception class and creating a constructor of the class (user-defined) with string argument to print that message when exception occurs. Here why we need to string argument to the constructor because every exception will return a message in the form of a string.

Error and Error Handling:
There are two types of error: Design- time error and Logical error.

Design-time error: These are the errors that occur while designing the programs. Example for Design errors is syntax errors. These errors will be shown with a red mark in eclipse IDE so that you can easily find and correct it. Missing a semicolon will return design time error.

Advantages of Exception:
The program will still execute even if an exception arises i.e finally block i.e if you need a part of code to be executed necessarily then place that code in finally block.

If you can't handle the exception JVM will handle the exception if we use throws keyword.

We can differentiate the exceptions that have occurred. If you get array index out of bound exception then it indicates that we are trying to perform an action on the array element exceeding the size of the array. When you divide a number by zero you will get an arithmetic exception. So you can differentiate the exceptions that have occurred.

Logical error: These are the errors done by programmer. Even though the program is syntactically correct the program will not produce expected output i.e. the programs with these errors will run but does not produce desired results. Such type of errors is called logical errors. Example for logical error is getting division of two numbers as output instead of expected output of multiplication of numbers. These errors can be rectified by understanding the logic and checking whether it is works out correctly or not.

Please write back to us at support@edureka.in or call us at +91-8880862004 for more information.

Visit - http://www.edureka.co/java-course
View comments
This playlist has no title.
Java Tutorial - 7 | Edureka
Share with your friends!
Press emoticons to leave feelings.
#Like
#Like
1
#Funny
#Funny
0
#Sad
#Sad
0
#Angry
#Angry
0
#Cool
#Cool
0
#Amazing
#Amazing
0
#Scary
#Scary
0
#Want more
#Want more
0
100932 https://www.youtube.com/watch?v=I138kfQCorw Java Tutorial - 7 | Edureka 3
Mark LIKE on the tags!
363653 Advanced java Tutorial
363660 java Lesson
363664 java for Beginners
363663 edureka java
363662 Learn java
363147 java tutorial
363661 java Video Tutorial
363148 java basics
363659 java Concepts
320383 Java
1
363658 java Introduction
363657 edureka
363656 java Lecture
363655 What is java
363654 java Class
363154 java course
363149 java training
363665 java Fundamentals
Vlogger
Vlogger
8K+
7K+
Subscribe Popular Videos! :)
 
Share page of @Vlogger
UnMark |Edit |Search
Mark |Dislike |Search
Mark |Del |Search
Open
Report
Full screen
Timer
Translation