Ask Question
9 July, 23:06

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

+2
Answers (1)
  1. 10 July, 01: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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers