Card 22 / 76: Which append declaration does not exist in Java 7?
A)
public StringBuilder append (short s) {…}
B)
public StringBuilder append (int i) {…}
C)
public StringBuilder append (long l) {…}
D)
public StringBuilder append (float f) {…}
E)
public StringBuilder append (double d) {…}
Answer:
A) public StringBuilder append (short s) {…}
Previous Card | ← Previous Card Button |
Next Card | → Next Card Button |
Flip Card | Space-Bar |
This is because the short value is automatically casted to an integer when passed for integer literal. Therefore, the following declaration will also handle a short argument: public StringBuilder append (int i) {…}
B, C, D, and E are incorrect.
B is incorrect because the append declaration that includes an int is included in the StringBuilder class.
C is incorrect because the append declaration that includes a long is included in the StringBuilder class.
D is incorrect because the append declaration that includes a float is included in the StringBuilder class.
E is incorrect because the append declaration that includes a double is included in the StringBuilder class.
|