Runtime Error Groups Exception causes
Summary: In this "Runtime Error Groups Exception causes" tutorial, you will come to know the classification of excetpions and causes in detail.
Runtime Error – Groups
We know earlier, the runtime errors cause the unwarranted termination of the execution of a smooth running process. The runtime errors can be broadly categorized into three groups.
- Exceptions caused due to Input errors
- Exceptions caused due to Hardware errors
- Exceptions caused due to Logical errors
1. Input Errors
Mostly, the exceptions are due to input errors only. Input error means that the user gives some wrong data (like through scanf() or some front-end) as input at runtime which the execution environment is unable to decide what to do with the data. It is a bad situation; we can expect this, naturally, as user may not have any computer background. For example, giving an IP address at runtime that does not exist at all in the network, now OS should connect to what system? There exist many similar problems which we discussed in Exceptions – Causes.
2) Hardware Errors
These are caused occasionally. Sometimes, the system or hardware also may not cooperate with the running program for its smooth execution. Everyone knows pretty well that in file copying, if the destination file does not exist, a new file is created and the source file contents are copied. If the hard disk is already full, then how the system creates new a file? It is a sort of system problem. For this type of problems, the programmer cannot do anything (by keeping a try-catch block, he cannot save one more file). He simply should come out of the program, do something needful to the hardware and then again resume the execution. For this reason, the programmer does not bother about this type of exceptions and thereby ignores; does not handle them.
3) Logical errors
In computer terminology, a logical error, also known as semantic error, is a bug in code development which must be debugged. If a logical error exists, you may get unexpected and incorrect results that may differ at different times of execution.
Exceptions – Causes (Runtime Error Groups Exception causes)
Following are a few causes for raising exceptions.
- In file copying, the file you would like to open may not exist all or the write mode file you open may not have write permission (handled by FileNotFoundException).
- The file you would like to open may be in a wrong format. For example, a Java file should have an extension like Demo.java and it may be like Demo.java.txt (handled by ClassNotFoundException ).
- The network is unable to connect as you might have given a wrong IP address (handled by MalformedURLException).
- Giving wrong a zero value which cannot be used as a divider in a division operation. (handled by ArithmeticException ).
- Giving wrong index number to an array where such an element does not exist at all. (handled by ArrayIndexOutOfBoundsException).
- The sleep time (inactive time) of a thread may be interrupted. (handled by InterruptedException).
- The system is unable to convert the data into such format required by it . (handled by NumberFormatException).
Like this hundreds of reasons may exist that can interrupt your program execution. Programmer should be aware of these and he need not read them specifically as he gets them slowly in each chapter in relevant topics.