Multiple choice technology programming languages

package constructors; class M { int i; M() { System.out.println("I am in M, No argument Constructor"); this(10); } M(int i) { this.i = i; System.out.println("I am in M, Constructor with Argument"); } } public class TestConstructor3 { M m = new M(); }

  1. I am in M, No argument Constructor I am in M, Constructor with Argument

  2. I am in M, Constructor with Argument I am in M, No argument Constructor

  3. Compiler Error

  4. Exception

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

The constructor M() attempts to call this(10) after already executing System.out.println(). In Java, this() and super() calls must be the first statement in a constructor. This code violates that rule by having the print statement before this(10). The compiler error occurs because constructor chaining calls must precede any other code in the constructor body. Additionally, this(10) and this() cannot be used in the same constructor as they would create circular initialization.