What Will Be The Output Of The Following Java Codep Pre #538
What will be the output of the following Java code?</p> <pre><code class="language-java"> public class Main { int a; int b; Main(int a, int b) { this.a = a; this.b = b; } Main(Main s) { a = s.a; b = s.b; } void Set() { a = 10; b = 20; } void calc() { System.out.println(a*b); } public static void main(String[] args) { Main a = new Main(20, 30); Main b = new Main(a); a.calc(); a.Set(); b.calc(); } }</code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs111 OOP Object Oriented Programming Java. It can also be found in gs gs111 Class Components (Using Java) - Copy Constructors - Quiz No.1.