What Will Be The Output Of The Following Codep Pre Langcpp #312
What will be the output of the following code?</p> <pre><code class="language-cpp"> public class Test { public int a=0; class innerClass { public int a=1; void innermethod(int x) { System.out.println(“value of x = ” + x); System.out.println(“value of this.x = ” + this.x); System.out.println(“value of Test.this.x = ” + Test.T=this.x); } } } public static void main( String args[] ) { Test t=new Test(); Test.innerClass im=t.new innerClass(); im.innermethod(55); } </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 Members & Types - Object Oriented Programming MCQ: Nested Class - Quiz No.2.
What will be the output of the following code?
public class Test { public int a=0; class innerClass { public int a=1; void innermethod(int x) { System.out.println(“value of x = ” + x); System.out.println(“value of this.x = ” + this.x); System.out.println(“value of Test.this.x = ” + Test.T=this.x); } } } public static void main( String args[] ) { Test t=new Test(); Test.innerClass im=t.new innerClass(); im.innermethod(55); }
value of x = 55 value of this.x = 0 value of Test.this.x = 1 value of x = 1 value of this.x = 0 value of Test.this.x = 55 value of x = 55 value of this.x = 1 value of Test.this.x = 0 value of x = 0 value of this.x = 55 value of Test.this.x = 1