English

Given that String hh = "Isaac Newton was a great scientist"; char pp = hh.charAt(7); What will be the value in pp?

Advertisements
Advertisements

Question

Given that

String hh = "Isaac Newton was a great scientist"; 

char pp = hh.charAt(7);

What will be the value in pp?

Options

  • N

  • w

  • e

  • t

MCQ
Advertisements

Solution

e

Explanation:

The value in pp will be e. In Java, strings utilise zero-based indexing, which means character counting begins at zero rather than one. By counting sequentially from left to right across the string "Isaac Newton was a great scientist", index 0 corresponds to 'I', index 5 is the space character, index 6 holds the uppercase letter 'N', and index 7 lands directly on the lowercase letter e.

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. (iv) | Page 245
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×