1. String sentence; String str1, str2, str3, str4; int length1; sentence = \"Fir
ID: 3575958 • Letter: 1
Question
1.
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.substring(0,13);
str4 = str3.indexOf("exam");
length1 = sentence.length();
Based on the code above, what is the value of str4?
2.
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.substring(0,13);
str4 = str3.indexOf("exam");
length1 = str2.length();
Based on the code above, what is the value of length1?
Explanation / Answer
str3 contains "First exam is"
str4 contains str3 index of "exam" Then the index position of "exam" is 6
what is the value of str4 is 6
str1 contains "exam is on"
str2 contains str1 substring of "exam"
Then the length of str2 is 4
the value of length1 is 4
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.