English

Given that: String sp = "Spectroscорy"; String sq = sp.substring(8); What will be the value of sq?

Advertisements
Advertisements

Question

Given that:

String sp = "Spectroscорy";

String sq = sp.substring(8);

What will be the value of sq?

Options

  • scopy

  • copy

  • opy

  • Error

MCQ
Advertisements

Solution

copy

Explanation:

The substring(8) method extracts all characters starting from index position 8 to the end of the string. Since Java uses zero-based indexing, counting from 0 places index 8 on the letter 'c', isolating the word copy.

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

Englishहिंदीमराठी


      Forgot password?
Use app×