Question
Option 1 : `Student(String n) { System.out.println("hi"); this(n, 0); }` — calling this() as the second statement / `this()` को दूसरे statement के रूप में बुलाना
Detailed Solution
सही उत्तर `Student(String n) { System.out.println("hi"); this(n, 0); }` — calling this() as the second statement / `this()` को दूसरे statement के रूप में बुलाना है।
Question:
Which of the following Java constructors causes a COMPILATION error? / निम्नलिखित में से कौन-सा Java constructor कंपाइलेशन त्रुटि उत्पन्न करता है?
Correct Answer: `Student(String n) { System.out.println("hi"); this(n, 0); }` — calling this() as the second statement / `this()` को दूसरे statement के रूप में बुलाना
A constructor's `this(...)` or `super(...)` call must be its very first statement; placing any statement before it is a compile-time error. The other three obey the rule. The trap is thinking constructor chaining can appear anywhere in the body. / constructor का `this(...)` या `super(...)` कॉल उसका पहला statement होना चाहिए; इससे पहले कोई statement रखना compile-time त्रुटि है। अन्य तीनों नियम का पालन करते हैं। जाल यह सोचना है कि constructor chaining body में कहीं भी आ सकती है।