हिंदी

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

प्रश्न

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?

विकल्प

  • SNB

  • snb

  • ahe

  • Sat

MCQ
Advertisements

उत्तर

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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 10: String Handling - Exercises [पृष्ठ २४६]

APPEARS IN

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

Englishहिंदीमराठी


      Forgot password?
Use app×