Multiple choice

Which of the given classes has default constructor? Class X { }

Class Y { Y() {} }

Class Z { Z(int i) { } }

  1. X Only

  2. Y Only

  3. Z Only

  4. X and Z

  5. X and Y

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

This is the correct choice as if a class doesn’t explicitly declare the default constructor, java compiler automatically creates a non-argument constructor for that class. So, a default constructor for class X will be created at run time automatically. So, this answer is true.