Question: (a) Given the following String declaration String text = Sooner or later the day is coming: What is the result of the following statements? i.

 (a) Given the following String declaration String text = "Sooner or

(a) Given the following String declaration String text = "Sooner or later the day is coming": What is the result of the following statements? i. text.length(); ii. text.substring(2,4) + text.substring(27, text.length()-1); iii. "a" + text.substring(text. indexof("a"), text.indexOf("a")+3) + text.substring(9,14): (b) Write Java code that takes an input string and a search string and then prints out the location of the second oecurrence of the search string in input. You may assume that the search string always occurs at least once in the input string. For example, if input is "cat sat on the hat" and search is "at". your program will print out 5, the index of the second occurrence. In the previous example, if search is now changed to "on". your program will print out - I because "on" does not have a second occurrence in the input string. You only have to write the code fragment; some of the code is stubbed out below. 7/Assume inputs are declared and already initialized String input- String search . + 1/1. Now provide the code to find the second occurrence, you may declare and 7/use intermediate variables as needed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!