• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checked and JVM Exceptins

 
Siri Naray
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
I am so confused with the Exception types. Can someone help me.
Are JVM Exceptions Checked Exceptions?? and Programatically Thrown Exceptions Unchecked ???

In K&B there is a table with a list of JVM and Program Exceptions. but why not a table for Checked and Unchecked Exceptions(thought not all can be listed but some bsic ones)?? Are JVM and Programatically thrown Exceptions different from Checked and Unchecked??

I have my exam scheduled day after. So any help is really apprecited.
Thank You
 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well there are two types of exceptions.

The first one are the ones that are thrown by some sort of mistake in programming. Like ArrayIndexOutOfBoundsException or ArithmeticException. These exceptions can be prevented by some changes in the code. These are unchecked.

The second are the ones which are related to some kind of resources used by the program like Files or Network connections. These connections are not in the control of the programmer but they are checked so that you could take some action when they occur.

The third are the one that are internal in the JVM. They are caused by some problem during the execution of the program. The are suffixed with Error instead of Exception. They are unchecked as you cannot do anything when they occur...examples are StackOverflowError, OutOfMemoryError etc..

Best of Luck for the Exam dude....
 
Arun Krishnan Nair
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Checked exceptions are subclasses of Exception class, JVM exceptions are subclasses of RuntimeException class. I guess when you receive a JVM exception it will be occuring at runtime. So NullPointerException, ArrayIndexOutOfBoundException etc are unchecked JVM exceptions.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Arun", please check your private messages for an important administrative matter.
 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that JVM Exceptions is a confusing term. All the exceptions are thrown by the JVM. Programmatic exceptions are explicitly thrown using throw. Other exceptions are thrown at runtime automatically...
 
Brij Garg
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Programatically throwm exceptions are exception which are programed to be thrown by methods in APIs using throws keyword.

Example:-
public static int parseInt(String s) throws NumberFormatException

Above is the signature of the parseInt method in Integer class.

Programatically Thrown Exceptions can be checked and unchecked exceptions.

JVM thrown exceptions are not programed in APIs ...........I think I am correct here.
 
Siri Naray
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you everyone but I am still not clear.
Let me put the question like this.
Out of all the exceptions listed in pg 370 K&B ie.
ArrayIndexOutOfBoundsException
ClassCastException
NullPointerException
ExceptionInitializerError
StackOverFlowError
NoClassDefFoundError
IllegalArgumentException
IllegalStateException
NumberFormatException
AssertionError

any of these come under Handled Or Declare category??
 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All of them are unchecked.
 
Siri Naray
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit,
Thank you. that solves my problem.
I was wondering, you answer almost all questions anytime of the day. Are you done with your SCJP??

Thanks
Sirisha
 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No man....I am stuck heavily with Generics. I don't know why it doesn't seem to get into my mind...I am a Java EE developer. So usually I get very little time to study. Maybe that's the reason why I am not able to understand generics because I have not written too much of code for that....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic