73.7k views
3 votes
For String c = ""Now is the time for all"";

The Java statements
String i = c.substring(7);
String j = c.substring(4, 15);
will result in:

a. i = ""he time for all"" and j = ""is the time""
b. i = ""the time for all"" and j = ""s the time""
c. i = ""the time for all"" and j = ""is the time ""
d. i = ""he time for all"" and j = ""s the time"""

1 Answer

7 votes

Final answer:

In Java, c.substring(7) will result in "the time for all" and c.substring(4, 15) will give "is the time ", making the correct answer option c.

Step-by-step explanation:

The Java statements in question are using the substring method on a String object to extract segments of the text within the String c. For the String c given as "Now is the time for all", the substring starting at index 7 would be "the time for all" because indexing starts at 0. Therefore, i = c.substring(7) will result in i being "the time for all". Likewise, for the substring that begins at index 4 and ends at index 15 (not including 15), the String j = c.substring(4, 15) will be "is the time". Therefore, the correct answer is c. i = "the time for all" and j = "is the time ".

User Citrullin
by
7.9k points