Menu

(Solved) : Question 1 3 Marks 11 Consider Code Fragment String Sentence Strl Str2 Str 3 Int Lenl Len2 Q43931524 . . .

Question 1 [3 MARKS] 1.1 Consider the code fragment: String sentence, strl, str2, str 3; int lenl, len2; sentence = Today is

Question 1 [3 MARKS] 1.1 Consider the code fragment: String sentence, strl, str2, str 3; int lenl, len2; sentence = “Today is Wednesday.”; stri – sentence.substring(8, 18); str2 = strl.substring(1,9); str3 = str2.replace(‘d’,’S’); What is the value of str3? 1.2 Consider the code fragment: int x – 3, y = 0; if (x > 5) y = 1; else if (x < 5) ( if ( x < 3) y = 2; else y = 3; If x = 3, what is the value of y? 1.3 Consider the code fragment: public static int minimum (int x, int y) int smaller; if (x < y) smaller = x; else smaller – y; return smaller; Give a statement that is a valid call to the method above. Show transcribed image text Question 1 [3 MARKS] 1.1 Consider the code fragment: String sentence, strl, str2, str 3; int lenl, len2; sentence = “Today is Wednesday.”; stri – sentence.substring(8, 18); str2 = strl.substring(1,9); str3 = str2.replace(‘d’,’S’); What is the value of str3? 1.2 Consider the code fragment: int x – 3, y = 0; if (x > 5) y = 1; else if (x

Expert Answer


Answer to Question 1 [3 MARKS] 1.1 Consider the code fragment: String sentence, strl, str2, str 3; int lenl, len2; sentence = “Tod…

OR