<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Java%2FC3%2FException-Handling%2FEnglish-timed</id>
		<title>Java/C3/Exception-Handling/English-timed - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Java%2FC3%2FException-Handling%2FEnglish-timed"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Java/C3/Exception-Handling/English-timed&amp;action=history"/>
		<updated>2026-04-06T15:55:01Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Java/C3/Exception-Handling/English-timed&amp;diff=39013&amp;oldid=prev</id>
		<title>Jyotisolanki: Created page with &quot; {| border=1 | &lt;center&gt;Time&lt;/center&gt; | &lt;center&gt;Narration&lt;/center&gt;  |- | 00:01 |  Welcome to the spoken tutorial on''' Exception Handling.'''  |- | 00:06 |In this tutorial we w...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Java/C3/Exception-Handling/English-timed&amp;diff=39013&amp;oldid=prev"/>
				<updated>2017-09-14T07:14:16Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot; {| border=1 | &amp;lt;center&amp;gt;Time&amp;lt;/center&amp;gt; | &amp;lt;center&amp;gt;Narration&amp;lt;/center&amp;gt;  |- | 00:01 |  Welcome to the spoken tutorial on&amp;#039;&amp;#039;&amp;#039; Exception Handling.&amp;#039;&amp;#039;&amp;#039;  |- | 00:06 |In this tutorial we w...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
{| border=1&lt;br /&gt;
| &amp;lt;center&amp;gt;Time&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;Narration&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:01&lt;br /&gt;
|  Welcome to the spoken tutorial on''' Exception Handling.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:06&lt;br /&gt;
|In this tutorial we will learn about:   What is an ''' exception ''' '''Checked '''and '''unchecked exceptions '''  Handling the '''exceptions''' using   '''try-catch''' '''block '''and  '''finally block '''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  00:20&lt;br /&gt;
|  Here we are using '''Ubuntu Linux 16.04 OS'''  '''JDK 1 .8 '''and  '''Eclipse 4.3.1'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:32&lt;br /&gt;
|  To follow this tutorial, you must have knowledge of basics of''' Java''' and''' Eclipse IDE.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:39&lt;br /&gt;
| If not, for relevant''' Java '''tutorials, please visit the link shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  00:45&lt;br /&gt;
|  An '''exception''' is an unexpected event, which occurs during the execution of a program.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  00:52&lt;br /&gt;
|It interrupts the normal flow of the program and results in an abnormal termination. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:00&lt;br /&gt;
|Based on their occurrence, '''exceptions''' are classified as  '''unchecked''' exceptions and  '''checked''' exceptions. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:08&lt;br /&gt;
|  Now we will open''' eclipse''' and create a new project called '''ExceptionDemo.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:16&lt;br /&gt;
|Inside this project we will create the necessary classes to demonstrate '''exception handling.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:24&lt;br /&gt;
|  We will create a new '''class Marks.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:28&lt;br /&gt;
|  Now type the following code to represent the '''Marks class.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:34&lt;br /&gt;
| This program prints the marks of 5 students that is stored in an array '''marks'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:41&lt;br /&gt;
|  Let us run this program and verify the output.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:45&lt;br /&gt;
| We can see that the values in the '''array''' are getting printed.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:50&lt;br /&gt;
|  Let us check what will happen if we are trying to access an array element which is not existing.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:57&lt;br /&gt;
| Now type the following code.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:00&lt;br /&gt;
| We know that there are only 5 elements in our '''array'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:04&lt;br /&gt;
| But in this '''statement''' we are trying to access the '''element''' at '''index 50''' which is not existing.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:12&lt;br /&gt;
|  Let us '''run''' this program now.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:15&lt;br /&gt;
|We can see that the program terminates with an error message:“'''ArrayIndexOutOfBoundsException''' “at line number 7.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:25&lt;br /&gt;
|The error message indicates the details of the exception like type of '''exception'''&lt;br /&gt;
where it occurred  and other details.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:35&lt;br /&gt;
|Note that the '''print statement''' is not executed as the program terminates after the error.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:42&lt;br /&gt;
|This is an example of '''Unchecked exception.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:46&lt;br /&gt;
|   '''Unchecked exceptions''' are called as '''Runtime exception''' as it is checked only during the execution.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:54&lt;br /&gt;
| They handle the programming bugs and logical errors such as Dividing a number by zero and Accessing an array element which is not existing .&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:07&lt;br /&gt;
|  Now let us learn about how to handle an '''exception '''using''' try catch block'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:13&lt;br /&gt;
|  This portion of the code within a '''try block''', can possibly raise an '''exception. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:19&lt;br /&gt;
|The corresponding '''catch block''' can receive the '''exception''' details in object '''e.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:26&lt;br /&gt;
|Inside the '''catch block''' we can write the code for displaying error messages or recovering from the error.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:34&lt;br /&gt;
|  Now let us switch to '''eclipse'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:37&lt;br /&gt;
|  First let us add a '''try block '''around the code which caused the '''exception''' like this.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   03:44&lt;br /&gt;
|  Now we have to add a corresponding '''catch block.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   03:48&lt;br /&gt;
| So type the following code.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   03:51&lt;br /&gt;
| Here we are printing a custom message '''“Array Overflow Exception occurred”'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   03:57&lt;br /&gt;
| Inside the round brackets we have created an instance of '''ArrayIndexOutOfBoundsException. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   04:05&lt;br /&gt;
| So this block can catch '''exceptions''' of type '''ArrayIndexOutOfBoundsException.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:11&lt;br /&gt;
|  Now let us run the program.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:14&lt;br /&gt;
| We can see that the error message gets printed.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:18&lt;br /&gt;
| But this time, note that printing the '''marks array''' is also executed.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:24&lt;br /&gt;
| In this way we can handle '''exceptions'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:27&lt;br /&gt;
|  Next let us see how to use multiple '''catch blocks.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:32&lt;br /&gt;
| We can use them when different types of '''exceptions''' are raised by a '''block'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:38&lt;br /&gt;
|  Type the following code inside the '''try block'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:42&lt;br /&gt;
| This line of code divides an '''array element''' by '''zero''' as the value of '''a '''is '''zero'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:49&lt;br /&gt;
| So an '''ArithmeticException''' will be raised first.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   04:53&lt;br /&gt;
|  Let us now add one more '''catch block''' to handle the '''ArithmeticException.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   04:58&lt;br /&gt;
| So type the following code after the existing '''catch block'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:03&lt;br /&gt;
|  Let us '''run''' the program again.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:06&lt;br /&gt;
| This time the error message '''&amp;quot;Arithmetic Exception occurred&amp;quot;''' gets printed as it is caught first.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:13&lt;br /&gt;
| The remaining portion of the code outside the '''try catch block '''executes. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:19&lt;br /&gt;
|  Next let us see about '''checked exceptions'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:23&lt;br /&gt;
| '''Checked exceptions''' are checked at '''compile time'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:27&lt;br /&gt;
| So they must be handled before running the program.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:31&lt;br /&gt;
| For example: Accessing a '''file''' which is not existing or Accessing a '''network system''' when the network is down .&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:41&lt;br /&gt;
|  Now let us switch to '''Eclipse''' and create a new '''class MarksFile. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:47&lt;br /&gt;
|  Let us add '''main method'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:50&lt;br /&gt;
|  Now we want to read a file located in the computer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:54&lt;br /&gt;
| So type the following code.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:57&lt;br /&gt;
|  Here the '''FileReader''' object '''fr '''is initialized as '''null'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:03&lt;br /&gt;
| '''FileReader''' object can be used to access and read a particular file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:08&lt;br /&gt;
|  '''Eclipse''' will show an error. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:11&lt;br /&gt;
| To rectify the error, click on it and double click '''import FileReader java dot io.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:19 &lt;br /&gt;
| The '''FileReader class''' is imported from the '''java dot io package.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:25 &lt;br /&gt;
| We will learn about '''package''' and its usage in detail in a later tutorial.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  06:31&lt;br /&gt;
|  To allow '''fr '''to access a file called''' Marks''' which is located in the home folder, type the following code.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  06:40&lt;br /&gt;
| The path shown here is to be replaced with that of your system's home folder.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  06:46&lt;br /&gt;
|Now an error comes up. It indicates that this line of code can create a '''FileNotFoundException.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  06:55&lt;br /&gt;
|  Click on the error and double click '''Surround with try/catch'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  07:00&lt;br /&gt;
| We can see that '''Eclipse''' automatically inserts the '''try catch block''' to rectify this error.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   07:08&lt;br /&gt;
| So we can understand that this is a '''checked exception'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   07:12&lt;br /&gt;
|  Next let us see how to use '''finally block.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   07:16&lt;br /&gt;
|  Type the following code.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   07:18&lt;br /&gt;
| '''finally block''' usually follows a '''try-catch block .'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   07:22&lt;br /&gt;
| The code inside this '''block''' is executed whether exception has occurred or not. It contains a '''print statement'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   07:32&lt;br /&gt;
|  Now let us close the file reference inside the '''finally block.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   07:37&lt;br /&gt;
| So type, '''fr dot close'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   07:40&lt;br /&gt;
|  Now '''Eclipse''' indicates that this will raise an '''IOException.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   07:45&lt;br /&gt;
| So click on the error and double click '''Surround with try/catch'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  07:51&lt;br /&gt;
|  Now let us '''run''' the program.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   07:54&lt;br /&gt;
|  We can see that''' FileNotFoundException''' message is printed.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   07:59&lt;br /&gt;
| This is because we don't have a file named '''Marks''' in our home folder.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   08:04&lt;br /&gt;
| We can also see a '''NullPointerException '''as '''fr '''still refers to a null value.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|   08:12&lt;br /&gt;
| But we can see that the '''print statement''' inside '''finally block''' gets executed.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:18&lt;br /&gt;
|  Let us now create a text file '''Marks''' in our home folder.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:23&lt;br /&gt;
|  If you are a windows user, create a text file in your local drive and mention its path.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:29&lt;br /&gt;
| For example it can be specified as '''D:\\Marks.txt'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:37&lt;br /&gt;
|  Let us now run the program again.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:40&lt;br /&gt;
|  We can verify that there are no exceptions once the '''Marks''' file is created.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:46&lt;br /&gt;
| And '''“Inside finally block”''' gets printed.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:50&lt;br /&gt;
| The '''cleanup operation''' i.e closing the '''FileReader''' Object '''fr '''is also executed successfully.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:58&lt;br /&gt;
|  With this we come to the end of this tutorial.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  09:02&lt;br /&gt;
| Let us summarize.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  09:04&lt;br /&gt;
| In this tutorial we have learnt about: What is an '''Exception''' ''Checked '''and '''Unchecked Exceptions ''' Handling the '''Exceptions''' using  the ''try-catch''' '''block''' '''finally block '''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:17&lt;br /&gt;
|  As an assignment, Learn about another '''Runtime Exception''' called '''NullPointerException. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:24&lt;br /&gt;
|Refer to the '''Java''' program named '''Demo.java '''provided in the '''Assignment''' link of this tutorial.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:31&lt;br /&gt;
|An '''exception''' will be raised when you run this code.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:35&lt;br /&gt;
|Identify the code which is responsible for the '''exception'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:40&lt;br /&gt;
|Rectify it using a''' try-catch block.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:43&lt;br /&gt;
|  The video at the following link summarizes the''' Spoken Tutorial Project.''' Please download and watch it.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:52&lt;br /&gt;
|  The''' Spoken Tutorial Project Team''' Conducts workshops using spoken tutorials , Gives certificates on passing the online tests.For more details, please write to us.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:04&lt;br /&gt;
|  '''Spoken Tutorial Project''' is funded by the NMEICT, MHRD, Government of India. More information on this Mission is available at the link shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|10:15&lt;br /&gt;
|  This script has been contributed by:'''Dept. of Information''' '''Technology, Amal Jyothi College of Engineering'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|10:23&lt;br /&gt;
|This is Priya from IIT Bombay. Thanks for joining.&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Jyotisolanki</name></author>	</entry>

	</feed>