Question: When you can omit constructor keyword from the primary constructor?

  1. It can be omitted only if an init block is defined.
  2. It can be omitted anytime; it is not mandatory.
  3. It can be omitted if secondary constructors are defined.
  4. It can be omitted when the primary constructor does not have any modifiers or annotations.

Answer: The correct answer of the above question is Option D:It can be omitted when the primary constructor does not have any modifiers or annotations.