Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 193

Given:

What is the result?

    Correct Answer: D

    In the provided code, x is an instance variable and y is a static variable. The values of x are unique to each instance of the Tester class, while y is shared among all instances. When t1.x is set to 2 and Tester.y is set to 3, it modifies the class variable y. When t2.x is set to 4 and t2.y (which is Tester.y) is set to 5, it changes the class variable y to 5 for all instances. Therefore, the output would be: 2,5 (t1.x = 2 and Tester.y = 5), 4,5 (t2.x = 4 and Tester.y = 5), 4,5 (t2.x = 4 and Tester.y = 5).

Discussion
d7bb0b2Option: A

Only with first system.out can answered, 2, 5 (y is static So his value is for class no for instance)