Ask Question
28 May, 04:30

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

+5
Answers (1)
  1. 28 May, 08:00
    0
    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
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What is the output of the program shown below? public class SomeClass { private int x, y; public SomeClass (int xValue, int yValue) { x = ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers