Which of the following classifications of method behavior produces acceptable side effects?
Blog
Consider the method in the following code snippet: public v…
Consider the method in the following code snippet: public void getRewardPoints() { System.out.println(“Your Reward Points balance is now “ + pointBalance); } Which of the following statements would not be a valid criticism of the design of this method?
Given the following code snippet: public static int newCalc(…
Given the following code snippet: public static int newCalc(int n) { if (n < 0) { return -1; } else if (n < 10) { return n; } else { return (1 + newCalc(n / 10)); } } What value will be returned when this code is executed with a call to newCalc(15)?
The use of the static keyword in a method declaration implie…
The use of the static keyword in a method declaration implies which of the following?
Complete the code for the calcPower recursive method shown b…
Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method: public static int calcPower(int baseNum, int exponent) { int answer = 0; ________________________ { answer = 1; } else { answer = baseNum * calcPower (baseNum, exponent – 1); } return answer; }
Suppose an object is intended to store its current position…
Suppose an object is intended to store its current position in a 2D array using private instance variables: private int row; private int column; Which code represents a method that would move the current position of the object one column to the right on the grid?
In Java, which of the following mechanisms describe the copy…
In Java, which of the following mechanisms describe the copying of an object reference into a parameter variable?
Given the following code snippet: public static int newCalc(…
Given the following code snippet: public static int newCalc(int n) { if (n < 0) { return -1; } else if (n < 10) { return n; } else { return (n % 10) + newCalc(n / 10); } } What value will be returned when this code is executed with a call to newCalc(15)?
Which of the following can potentially be changed by a Java…
Which of the following can potentially be changed by a Java method?
Complete the code for the myFactorial recursive method shown…
Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: public int myFactorial(int anInteger) { _____________________________ { return 1; } else { return(anInteger * myFactorial(anInteger – 1)); } }