Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Bonni Garcia   on May 08 In Java Category.

  
Question Answered By: Freda Lane   on May 08

There are few points that you need to take care.

# BadObjectException belongs to Non-Runtime exception  category hence
if the called method throws  this exception then the calling method
should either catch the exception and handle the same OR re-throw the
exception in its throws clause.

# BadIndexException belongs to Runtime Exception category hence the
programmer is not forced to catch it or re-throw it. It is his wish
to decide on how to handle that exception OR simply ignore it.

# In your program, doSometing() does NOT throw any exception (I am
stressing on Non-Runtime exception.. ) hence an attempt to catch
exception will cause the compile time error. The reason is,
BadObjectException is never thrown in the body of corresponding try
statement.

Hope it clarifies your doubt. Write me if you need more details.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Wats Wrong With this Code ? Or get search suggestion and latest updates.


Tagged: