• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception

 
Ranch Hand
Posts: 47
Redhat Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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. NoClassDefFoundException
D. NumberFormatException [Correct]
E. ArrayIndexOutOfBoundsException

Why not NoClassDefFoundException is correct answer ?
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

NoClassDefFoundException is a runtime exception thrown by a program that has been successfully compiled. A programmer would never have a reason to throw it.

http://download.oracle.com/javase/6/docs/api/java/lang/NoClassDefFoundError.html

Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.



 
gaurav gupta sitm
Ranch Hand
Posts: 47
Redhat Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK NoClassDefFoundException is a runtime exception.......
but NumberFormatException is also runtime exception.......
so why NumberFormatException......??
 
Cole Tarbet
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The programmer might throw a NumberFormatException from a method he writes to tell the user that they passed in a poorly formatted value.

For example, a method that takes a phone number as a String like "(555) 555-5555" could throw NumberFormatException if the user sent in some text like "asdfasdfasdf".

 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gaurav please QuoteYourSources when you post a mock exam question...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic