I had a test in AP Computer Science and I got the following question incorrect:
Given the following class A public Person class is written, and the class has two private String instance variables to store the person's name: one named firstName and one named lastName. The class has two public accessor methods for these instance variables: public String getFirstName() and public String getLastName(). The class has another method: public String getLastPlusInitial(). This method returns a String consisting of the last name, then a comma and a space, then the first initial, and then a period. For example, if the person's name is Fred Flintstone, then getLastPlusInitial() would return "Flintstone, F." The class has a fourth method: public String getFirstInitialPlusLast(). This method returns a String consisting of the first initial, then a period, and then the last name. For example, if the person's name is Wilma Flintstone, then getfirsInitialPlusLast() would return "W. Flintstone." Which of the following could not be used to implement getfirstInitialPlusLast()? (3 points) I. return (firstName.substring(0,1) + ". " + lastName); II. return (getFirstName().substring(0,1) + ". " + getLastName()); III. return (getFirstName.substring(0,1) + ". " + getLastName); Choose one answer. a. Statement III only. b. Statements I and II only. c. Statement II only. d. Statements II and III only. e. Statements I, II, and III. Incorrect
I chose e as my answer but it was wrong. I was thinking the correct answer is b? Could someone explain it to me just so I know for future reference? Thank you!