Asked by Kattelin Crocker on May 17, 2024

verifed

Verified

String sentence;
String str1, str2, str3, str4;
Int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12) ;
Str2 = str1.substring(0, 4) ;
Str3 = sentence.replace('i', '#') ;
Str4 = sentence.indexOf("on") ;length1 = sentence.length() ;Based on the code above, what is the value of str1?

A) exam i
B) exam
C) exam is
D) on Monday

Sentence.substring()

A method in Java that extracts and returns a new string that is a part of the original string, starting from a specified index to the end or between specified indices.

  • Determine and implement the procedures for manipulating strings in Java skillfully.
verifed

Verified Answer

JW
Jacob WhiteMay 20, 2024
Final Answer :
A
Explanation :
str1 is assigned the value of the substring of sentence starting from index 6 to index 11 (12 is exclusive), which corresponds to "exam i".