Friday 11 November 2011

A Thesis on Program and Exceptions


A program is very much like a train which runs on track of instructions.



While an Exception is an end of line in the track of instructions. As Exceptions are events for which no instruction is given to the computer. So on reaching such an event (end) the program crashes.

In the above picture the train (program) is about to crash on reaching the end (exception). 
Exceptions are therefore called events for which no instructions are given to the computer. In other words the program runs out of the track of instructions.
While exception handling is very similar to safe changing of track of the train.
Just ponder upon the following picture.

The try-block is very similar to a radar that detects the exception before hand if it finds any exception it lets the program on a safe track called catch-block.
Isn't it amazing! to think like that.

No comments:

Post a Comment