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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!