English

Given that: String kr = "Albert Einstein"; int pr = kr.indexOf('e'); What will be the value of pr?

Advertisements
Advertisements

Question

Given that:

String kr = "Albert Einstein";

int pr = kr.indexOf('e');

What will be the value of pr?

Options

  • 4

  • 3

  • 12

  • 13

MCQ
Advertisements

Solution

3

Explanation:

  • The string is Albert Einstein.
  • indexOf('e') returns the index of the first lowercase 'e'.
  • The first lowercase 'e' is in Albert at index 3 (counting starts from 0).
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. (iii) | Page 245
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×