Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

String sentence; String str1, str2, str3, str4; int length1; sentence = \"First

ID: 3574827 • Letter: S

Question

String sentence;

String str1, str2, str3, str4;

int length1;

sentence = "First exam is on Monday.";

str1 = sentence.substring(6, 16);

str2 = str1.substring(0, 4);

str3 = sentence.replace('i', '#');

str4 = sentence.indexOf("on");

length1 = sentence.length();

1. Based on the code above, what is the value of str1?

2. Based on the code above, what is the value of str2?

3. Based on the code above, what is the value of str1.length?

4. Based on the code above, what is the value of str3?

5. Based on the code above, what is the value of str4?

Explanation / Answer

1)Ans)exam is on

2)Ans)exam

3)Ans)10

4)F#rst exam #s on Monday

5)Here sentence.index("on"); returns integer type value.But we are trying to store that resultant value into the str4 which is of String type.So its not possible.which results compilation error.

The correct one is

int pos=sentence.indexOf("on");

Ans)14

______Thabk You