Question: in Java public class Test { static int x = 11; private int y = 33; public void method1(int x) { Test t = new
in Java
public class Test
{
static int x = 11;
private int y = 33;
public void method1(int x)
{
Test t = new Test();
this.x = 22;
y = 44;
System.out.println("Test.x: " + Test.x);
System.out.println("t.x: " + t.x);
System.out.println("t.y: " + t.y);
System.out.println("y: " + y);
}
public static void main(String args[])
{
Test t = new Test();
t.method1(5);
}
}
what does this print and why? please explain the scope of the variables and reasons for the prints
Also, when t.method1(5) is called what does the 5 represent and how is the code effected by the 5?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
