• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

general query

 
gunjan khanuja
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which can appropriately be thrown by a programmer using Java SE technology to create
a desktop application?
A. ClassCastException
B. NullPointerException
C. NoClassDefFoundError
D. NumberFormatException
E. ArrayIndexOutOfBoundsException

Please expalin what is the answer and WHY??
 
Md. Minhajur Rahman
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello gunjan khanuja,
Exception Handling needs to be done depends on your code regardless of desktop or web, mobile or any kind of application software.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mostly programmers *throws* checked exceptions and jvm *throw* unchecked exception, again ofcourse some time programmer throw unchecked exception. ;) . but programmer is not expected to throw any Errors.
So shortly programmer can throw all the mentioned exception except NoClassDefFoundError
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Technically all the sub classes of Throwable including Error can be thrown using the throw clause. Still as the question asks for 'appropriate', as Seetharaman said Errors are not expected to be handled by the programmer and are thrown for abnormal conditions by the JVM.

If you see the API - Error

A method is not required to declare in its throws clause any subclasses of Error that might be thrown during the execution of the method but not caught, since these errors are abnormal conditions that should never occur.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic