English

Given that: String sb = "Satyendra Nath Bose"; String nb = ""+sb.charAt(0)+ sb.charAt(sb.indexOf(' ')+1) + sb.charAt(sb.lastIndexOf(' ')+1); What will be the value of nb?

Advertisements
Advertisements

Question

Given that:

String sb = "Satyendra Nath Bose";

String nb = ""+sb.charAt(0)+ sb.charAt(sb.indexOf(' ')+1) + sb.charAt(sb.lastIndexOf(' ')+1);

What will be the value of nb?

Options

  • SNB

  • snb

  • ahe

  • Sat

MCQ
Advertisements

Solution

SNB

Explanation:

The code extracts the first letter of each word to form initials. It grabs the first letter of the string ('S'), the letter immediately following the first blank space ('N'), and the letter immediately following the last blank space ('B'). Joining them together results in the text SNB.
shaalaa.com
  Is there an error in this question or solution?
Chapter 10: String Handling - Exercises [Page 246]

APPEARS IN

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

Englishहिंदीमराठी


      Forgot password?
Use app×