Advertisements
Advertisements
Question
Given that:
String pm = "Albert Einstein";
qm = pm.endsWith("in");
What is the datatype of qm?
Options
int
char
String
boolean
MCQ
Advertisements
Solution
boolean
Explanation:
The endsWith() method checks whether a string finishes with a specific suffix, which can only result in a true or false answer. Therefore, Java requires the receiving variable qm to be a boolean datatype (evaluating to true in this case).
shaalaa.com
Is there an error in this question or solution?
Chapter 10: String Handling - Exercises [Page 245]
