+ 1

When is io exception used in java?

11th Dec 2016, 8:46 AM
Sritanuka Ganguly
Sritanuka Ganguly - avatar
6 Answers
+ 1
when ever u want. its just ur choice . suppose u want user to restrict on input integer values. so whenever he/she types float values or char values u throw io exception
11th Dec 2016, 8:56 AM
manish rawat
manish rawat - avatar
+ 1
int x = 1/0; = infinite......... u can't print infinite.......so this is Arithmetic Exception
12th Dec 2016, 1:43 AM
Ritesh Patidar
Ritesh Patidar - avatar
+ 1
To avoid unexpected results, termination etc. Suppose you made a program to store and retrieve info on family members, in a graph like or some other way. You want to add a new member to your family. A baby just born so an official name has to wait. You enter birthday, fathers name, mother name. But you made your database to have key name and DOB. Your program asks database to add a member but database tells no way sir. Control comes back to Java program and it cannot move forward, it has no other option other than execute addToDataBase instruction. So your program is stuck on an instruction and it has no going forward. What your Database did is throw an exception. I cannot add a field without a key. Such things happen and that's where exception handling plays a role.
14th Dec 2016, 3:27 PM
George Wells
+ 1
Thanx evry1...ths really helped
14th Dec 2016, 4:11 PM
Sritanuka Ganguly
Sritanuka Ganguly - avatar
0
for example: You want people to type the days of the week (it's 7 days, from 1 to 7) and it turns out they wrote 9, it's not a valid value, so you use an exception.
11th Dec 2016, 10:38 AM
Anthony Aguilar
Anthony Aguilar - avatar
- 1
You can use it when you reads/writes files.
11th Dec 2016, 10:38 AM
The PGDeveloper
The PGDeveloper - avatar