Which exception is thrown in Java when a class is not found at runtime?

2025

Which exception is thrown in Java when a class is not found at runtime?

  1. A.

    NullPointerException

  2. B.

    ClassNotFoundException

  3. C.

    IOException

  4. D.

    ArithmeticException

  5. E.

    NoClassDefFoundError

Attempted by 72 students.

Show answer & explanation

Correct answer: B

Correct answer: ClassNotFoundException.

ClassNotFoundException is thrown when Java tries to load a class by name and cannot find it on the classpath. It is commonly seen with reflective loading such as Class.forName().

Explore the full course: Ibps So It Mains

Loading lesson…