What happens if a Java class has no constructors defined?

2025

What happens if a Java class has no constructors defined?

  1. A.

    The compiler throws an error

  2. B.

    The compiler adds a default constructor automatically

  3. C.

    A parameterized constructor is added by default

  4. D.

    The object cannot be created using new keyword

  5. E.

    Only static methods can be accessed

Attempted by 67 students.

Show answer & explanation

Correct answer: B

Correct answer: The compiler adds a default constructor automatically.

If no constructor is declared in a Java class, the compiler provides a default no-argument constructor. This lets objects be created normally unless another declared constructor changes the situation.

Explore the full course: Ibps So It Mains

Loading lesson…