हिंदी

Given that: String ab = "Aaron Bernstein"; String db = ab.substring(ab.lastIndexOf('e'); What will be the length of db?

Advertisements
Advertisements

प्रश्न

Given that:

String ab = "Aaron Bernstein";

String db = ab.substring(ab.lastIndexOf('e');

What will be the length of db?

विकल्प

  • 8

  • 3

  • 2

  • 0

MCQ
Advertisements

उत्तर

3

Explanation:

The lastIndexOf('e') method finds the last occurrence of the letter 'e' in "Aaron Bernstein", which is at index position 12. The substring(12) method then extracts everything from that index to the end of the string, resulting in the word "ein", which contains exactly three characters.
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 10: String Handling - Exercises [पृष्ठ २४६]

APPEARS IN

रुपा पंडित Computer Applications [English] Class 10 ICSE
अध्याय 10 String Handling
Exercises | Q 1. (ix) | पृष्ठ २४६
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×