English

Given that: String pm = "Albert Einstein"; qm = pm.endsWith("in"); What is the datatype of qm?

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]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 10 String Handling
Exercises | Q 1. (vii) | Page 245
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×