What is the output of the program shown below?

public class SomeClass
{
private int x, y;

public SomeClass (int xValue, int yValue)
{
x = xValue;
y = yValue;
}
public void m1()
{
x = 30;
System.out.print((y + 1) + " ");
}
public void m2()
{
m1();
System.out.print(x + " ");
}
}
public class SomeTester
{
public static void main (String[] args)
{
int x = 10;
int y = 20;
SomeClass z = new SomeClass(x, y);
z.m2();
z.m1();
}
}

21 10 21
21 30 21
11 30 11
1 10 11
11 30 21

Respuesta :

Answer:

21 10 21

Explanation:

The called functions are m2() first which has the following implementation it called m1() which changes the value of x to 30 and print out y + 1 = 21 note x = 30 within m1() after execution of m1() x = 10 then called m1 x = 30 and print out y + 1 = 21 therefore answer is

21 10 21