Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[Java] Please help me to figure out why the code below returns the such output ( why t.x: 22 but t.y: 33) ------------------------------------------------------------------------------------------------------------------------------------------------ public class

[Java] Please help me to figure out why the code below returns the such output ( why t.x: 22 but t.y: 33)

------------------------------------------------------------------------------------------------------------------------------------------------

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);

}

}

-----------------------------------------------------------------------

output

Test.x: 22 t.x: 22 t.y: 33 y: 44

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+Will the use of sex appeal make the source more persuasive?

Answered: 1 week ago

Question

3. Identify the methods used within each of the three approaches.

Answered: 1 week ago