473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

why checked and unchecked exception?

dmjpro
2,476 2GB
why java provides two flavour exceptions?

why java tells programmer to handle or throw anyway some exceptions and some not?
as jvm can catch it and throw it then why java provided so?

plz explain ....
Regards.
May 8 '07 #1
3 1464
JosAH
11,448 Expert 8TB
Some exceptions can't be checked by the compiler; think of NullPointerException
or OperationNotSupportedException. Only during runtime these exceptional
conditions can show up. Maybe the best example is: OutOfMemoryException,
i.e. there is no way a compiler can check that condition and neither can you or
anyone else. That's why it was made an unchecked exception.

The class of the checked exceptions indicate events that in real life can happen
and your program should deal with them: an IOException is a nice example.
That's the reason why it was made a checked exception.

kind regards,

Jos
May 8 '07 #2
dmjpro
2,476 2GB
can we catch or should we catch the OutOfMemoryException?

Is this the subclass of Exception?

Plz help.
Regards.
May 9 '07 #3
JosAH
11,448 Expert 8TB
can we catch or should we catch the OutOfMemoryException?

Is this the subclass of Exception?

Plz help.
Regards.
All bets are off when the JVM is out of memory; of course you can catch that
error but all you can do is release (a substantial amount of) memory by setting
a bunch of references to null. Most of the time when this error is thrown there's
an error in your program logic.

kind regards,

Jos
May 9 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Hung Jung Lu | last post by:
Hi, Just ran into this article http://www.mindview.net/Etc/Discussions/CheckedExceptions And I felt kind of reliefed. When I programmed in Java I always thought its usage of "checked...
26
by: OvErboRed | last post by:
I just read a whole bunch of threads on microsoft.public.dotnet.* regarding checked exceptions (the longest-running of which seems to be <cJQQ9.4419 $j94.834878@news02.tsnz.net>. My personal...
9
by: Jeff Louie | last post by:
I drank too much coffee last night and came up with a suggestion about how to add checked exceptions to C# http://www.geocities.com/jeff_louie/OOP/oop14.htm Comments expected <g> Regards,...
0
by: keithv | last post by:
I've created my own value type which will overload the "+" operator. I have two routines to do addition, differing only in that one throws an error on overflow. Is there a way to get the...
4
by: RodBillett | last post by:
I have a situation where I have 3 checkboxes - and at least 1 needs to be selected at all times... I have implemented the code that allows this behavior to happen, BUT Viewstate gets all messed...
1
by: Dennis | last post by:
I have a checked list box and am trying to use the SetItemCheck method as follows: mylistbox.SetItemChecked(indextoset, True) It seems to have no effect and the display does not show the box...
1
by: Hareth | last post by:
how do I save and open checked and unchecked items in my listview to a txt file this is kinda what I have in mind but doesnt work; I need it for listview w/ checked items and unchecked ...
2
by: Aaron Reimann | last post by:
I have a lot of check boxes. This is an update of the check boxes, I want something was checked, then to do an insert (which is currently working), if something is no longer checked...delete the...
1
by: ttamilvanan81 | last post by:
Hai i have using the checkbox in for loop. I need the urgent help from anyone, for example in the loop there is having 5 checkbox if i checked 3 of the ckeckboxes and 2 of the checkboxes are...
0
by: J | last post by:
I'm dynamically adding checkboxes in the Page_Load (regardless of PostBack). When IsPostBack, the checkboxes display as I expected and their checked/unchecked status is also as expected. At this...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.