136k views
1 vote
Which of the following can potentially be changed by a Java method?

a) An object reference parameter.
b) The state of an object reference parameter's attribute.
c) A primitive parameter.
d) A String parameter.

User Markemus
by
8.0k points

1 Answer

4 votes

Final answer:

A Java method can potentially change an object reference parameter, the state of an object reference parameter's attribute, and a primitive parameter. However, a String parameter cannot be changed by a Java method because Strings are immutable.

Step-by-step explanation:

The following options can potentially be changed by a Java method:

  1. An object reference parameter: In Java, when an object reference is passed as a parameter to a method, the method can modify the state of the object.
  2. The state of an object reference parameter's attribute: If an object reference parameter has attributes, the method can modify the values of those attributes.
  3. A primitive parameter: Java methods can change the value of a passed-in primitive parameter.

A String parameter, however, cannot be changed by a Java method. Strings in Java are immutable, which means they cannot be modified once they are created.

User BurebistaRuler
by
7.8k points