Results 1 to 4 of 4
  1. #1
    bunny is offline Member
    Join Date
    Aug 2010
    Posts
    6
    Rep Power
    0

    Default Interview Question

    What is the difference between NoClassDefFoundException and ClassNotFoundException? When do we get these Exceptions?

  2. #2
    Prajin's Avatar
    Prajin is offline Senior Member
    Join Date
    Jun 2010
    Location
    Ktm, Nepal
    Posts
    120
    Rep Power
    0

    Default

    NoClassDefFoundException - The Java runtime can't find the class file, that's because classpath isn't set properly.

    ClassNotFoundException -Thrown when an application tries to load a class through its string name using Class.forName, ClassLoader. findSystemClass or ClassLoader. loadClass

    - for more start googling
    -Regards

  3. #3
    Ramanjaneyulu is offline Member
    Join Date
    Aug 2010
    Posts
    11
    Rep Power
    0

    Default

    Hi Bunny,

    Both are almost same Exceptions.The difference is

    If you use
    Car c=new Car(); statement in your program,then this class will statically(compiletime) load.In this case,if the runtime system cannot find the referenced class then "NoClassDefFoundException" will be thrown.

    If you use
    Class.forName ("Car"); statement in your program,then this class will dynamically(runtime) load.In this case,if the runtime system cannot find the referenced class then "ClassNotFoundException" will be thrown.

  4. #4
    bunny is offline Member
    Join Date
    Aug 2010
    Posts
    6
    Rep Power
    0

Similar Threads

  1. An Interview Question.
    By vinoth in forum New To Java
    Replies: 7
    Last Post: 04-01-2010, 12:02 PM
  2. help for java interview
    By javastuden in forum New To Java
    Replies: 2
    Last Post: 03-09-2010, 10:24 AM
  3. Java Interview Question and Answer
    By gnomeom in forum Java Software
    Replies: 3
    Last Post: 06-04-2009, 12:53 PM
  4. Java Threads Interview Question
    By _tony in forum Threads and Synchronization
    Replies: 20
    Last Post: 12-22-2008, 09:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •