162k views
2 votes
Which of the following could not be used to implement getLastPlusInitial()?

a. return (lastName + ", " + firstName.substring(0, 1) + ".");
b. return (getLastName + ", " + getFirstName.substring(0, 1) + ".");
c. return (getLastName() + ", " + getFirstName().substring(0, 1) + ".");

User Iamantony
by
5.9k points

1 Answer

3 votes

Answer:

b)

Step-by-step explanation:

in section b) we can see that we don't have parenthesis at the end of every getter method call. for example we have a getter method for lastName as getLastName() but in return statement we don't call the getter method with parenthesis, that will cause compile time error.

User Vikash Kumar Verma
by
5.9k points