EECS1030Z Test 1

Wednesday January 21, 2015, 14:30-15:00
Lab 02
Version C


/**
 * Test 1 utility class that provides fields and methods for working with
 * strings.
 * 
 */
public class TestC {

	/**
	 * The empty string ""
	 */
	public static final String EMPTY = "";

	/**
	 * The string equal to a single space " "
	 */
	public static final String SPACE = " ";

	/**
	 * Checks if a string s contains at least one space. Returns false if the
	 * string s is null.
	 * 
	 * @param s
	 *            a string to check
	 * @return true if s contains TestC.SPACE, false otherwise
	 */
	public static boolean containsSpace(String s) {
		if (s == null) {
			return false;
		}
		return s.contains(TestC.SPACE);
	}

	private TestC() {
	}
}

Question 1 Consider the following method header in the utility class Utility:
public static int someMethod(double x)

Suppose that a client invokes the method like so:

double clientX = 1;
int result = Utility.someMethod(clientX); 

Which of the following statements is correct?

A. someMethod cannot change the value of clientX
B. someMethod cannot change the value of x
C. if someMethod changes the value of x then the value of clientX also changes
D. someMethod can change the value of clientX without changing the value of x