Question
JAVA Choose one correct answer. Thank you. (d) When passing parameters to a Java method that are PRIMITIVE DATA TYPES, the corresponding actual and formal
JAVA Choose one correct answer. Thank you.
(d) When passing parameters to a Java method that are PRIMITIVE DATA TYPES, the corresponding actual and formal parameters (respectively, the corresponding parameters when calling the method and those declared in the called method):
1) are references to different objects
2) become aliases
3) are static variables
4) are variables containing the same value
5) cannot be references to arrays
(f) In order to preserve the encapsulation of an object, we would do the following in the class defining the object:
1) declare the instance variables as private in the class
2) write a Tester class associated to the class defining the object
3) declare the methods of the class defining the object as void
4) include private getter and setter methods inthe class
5) define only one constructor method and not more
(g) Assume that a method receives an array of Strings as a parameter and the method modifies some elements of the array.
To be able to see the changes in the array outside the method:
1) The method necessarily has to be defined of type String[ ] and the modified array needs to be returned from the method
2) The method may be defined to return any type. The changes in the array can be seen outside the method regardless.
3) No elements of the array can be changed because they are of type String
4) The elements of the array may be changed. While the elements of the array will refer to a different String object, the array will be changed.
5) Because it is an array, the parameter was passed to the method by value, and thus the changes cannot be seen outside the method.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started