• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
  • Himai Minh
  • Carey Brown
  • salvin francis

general query

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??
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.
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • 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
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.

Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic