Newest RATED A+ 2025/2026
For a method formal parameter p, which parameter mode guarantees that #p cannot appear n
the ensures clause for the method's contract?
a. clears
b. replaces
c. restores
d. updates - CORRECT ANSWERS B. replaces
You may reason about the behavior of Java code involving immutable types exactly as if they
were primi+ve types because:
a. "Immutable" and "primi+ve" are synonyms; there is no difference between them
b. Computa+ons involving immutable types are just as efficient as those involving primi+ve
types
c. Aliasing, which can happen with immutable types but not primi+ve types, cannot cause
trouble because object values for immutable types cannot be changed
d. In any code where an immutable type is used in a way where it would not behave like a
primi+ve type, it causes a Java compile-+me error - CORRECT ANSWERS C. Aliasing
Assume n is an int variable. Which Java expression is true exactly when n is an odd number (not
divisible by 2) and should be used to check for this situa+on?
a. n%2==0
b. n%2!=0
c. n%2==1
d. n%2!=1 - CORRECT ANSWERS b. n%2!=0
, what are the values of str and num a<er the call to foo?
private sta+c void foo(String s, NaturalNumber n){
s="Columbus, " +s;
n=new NaturalNumber2(43210);
}
...String str = "Ohio";
NaturalNumber num=new NaturalNumber2(314);
foo(str,num);
a. str="Ohio", num=314
b. str="Columbus, Ohio", num=314
c. str="Ohio", num=43210
d. str="Columbus, Ohio", num=43210 - CORRECT ANSWERS c. str="Ohio", num=314
What are the values of array and index a<er the call to bar?
private sta+c void bar(int[] a, int i){
a[i]++;
i++;
}
...
int[] array={1,2,3,4};
int index=1;
bar(array,index);
a. array={1,2,3), index=1
b. array={1,2,3), index=2
c. array={1,3,3), index=1