Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions