मराठी

What will be the value stored in the variable 'c' if the following statement is executed? c = "COMPUTER".charAt("COMPUTER".indexOf('P')) - Computer Applications

Advertisements
Advertisements

प्रश्न

What will be the value stored in the variable 'c' if the following statement is executed? 

c = "COMPUTER".charAt("COMPUTER".indexOf('P')) 

पर्याय

  • 3

  • 4

  • P

  • M

MCQ

उत्तर

P

Explanation:

charAt(int index) returns a character from the given index of the string, and indexOf(char ch) returns the index of the first occurrence of a character in the string.
Since P is at 3rd position so indexOf('P') will return 3 and charAt(3) function will return the character at the third index i.e., 'P'. So, the given statement is solved as follows: 

c = "COMPUTER".charAt("COMPUTER ".indexOf('P'))
c = "COMPUTER".charAt(3)
c = 'P' 

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 4: String Handling - EXERCISES [पृष्ठ २८६]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
पाठ 4 String Handling
EXERCISES | Q I. 4. | पृष्ठ २८६
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×