Click the Exhibit button. 1. public class Test { 2. int x= 12; 3. public void method(int x) { 4. x+=x; 5. System.out.println(x); 6. } 7. } Given: 34. Test t = new Test(); 35. t.method(5); What is the output from line 5 of the Test class?

  1. 5

  2. 10

  3. 12

  4. 17

  5. 24


Correct Option: B
Explanation:

The output from line 5 of the Test class would be 10.

Explanation:

In the Test class, there is an instance variable x with a value of 12.

The method takes a parameter x and performs an addition operation x += x, which is equivalent to x = x + x.

When the method is called with an argument of 5 (t.method(5)), the local variable x inside the method is set to 5.

The addition operation x += x is then performed, resulting in x being updated to 10.

Finally, System.out.println(x) prints the value of x, which is 10.

Therefore, the output from line 5 of the Test class would be 10, so the correct answer is C.

Find more quizzes: