nerdexam
Oracle

1Z0-803 · Question #220

Given: public class Test1 { static void doubling (Integer ref, int pv) { ref =20; pv = 20; } public static void main(String[] args) { Integer iObj = new Integer(10); int iVar = 10; doubling(iObj++, iV

The correct answer is A. 11, 11. The codedoubling(iObj++, iVar++);increases both variables from to 10 to 11.

Working with Methods and Encapsulation

Question

Given:

public class Test1 { static void doubling (Integer ref, int pv) { ref =20; pv = 20; } public static void main(String[] args) { Integer iObj = new Integer(10); int iVar = 10; doubling(iObj++, iVar++); System.out.println(iObj+ ", "+iVar); What is the result?

Options

  • A11, 11
  • B10, 10
  • C21, 11
  • D20, 20
  • E11, 12

How the community answered

(41 responses)
  • A
    80% (33)
  • B
    12% (5)
  • C
    2% (1)
  • D
    5% (2)

Explanation

The codedoubling(iObj++, iVar++);increases both variables from to 10 to 11.

Topics

#pass by value#Integer immutability#method parameters#autoboxing

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice