subject

Consider the following two code segments, which are both intended to determine the longest of the three strings "pea", "pear", and "pearl" that occur in String str. For example, if str has the value "the pear in the bowl", the code segments should both print "pear" and if str has the value "the pea and the pearl", the code segments should both print "pearl". Assume that str contains at least one instance of "pea".I. if (str. indexOf("pea") >= 0){System. out. println("pea");}else if (str. indexOf("pear") >= 0){System. out. println("pear");}else if (str. indexOf("pearl") >= 0){System. out. println("pearl");}II. if (str. indexOf("pearl") >= 0){System. out. println("pearl");}else if (str. indexOf("pear") >= 0){System. out. println("pear");}else if (str. indexOf("pea") >= 0){System. out. println("pea");}
1. Which of the following best describes the output produced by code segment I and code segment II?O Both code segment I and code segment II produce correct output for all values of str. O Neither code segment I nor code segment II produce correct output for all values of str. O Code segment II produces correct output for all values of str, but code segment I produces correct output only for values of str that contain "pear" but not "pearl".O Code segment II produces correct output for all values of str, but code segment I produces correct output only for values of str that contain "pearl".O Code segment II produces correct output for all values of str, but code segment I produces correct output only for values of str that contain "pea" but not "pear".

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:50
Using least squares fitting, you are to fit the data sets to the following models and solve for the parameters ai , where i is the index of the parameter. the input/output data for the systems are linked in the bblearn site. for each of the systems use matlab to plot the supplied data vs. the model fit on one plot. include your code in the solutions. (a) linear fit "lineardata.mat" y=a1x^3 + a2x^2 + a3x + a4 (b) plant fit "plantdata.mat g(s) = a1/(s + a2)
Answers: 1
question
Computers and Technology, 23.06.2019 03:00
Your business be in google top rank.more the rank more the business leads.for best seo and digital marketing services be confident to contact you can get best seo solutions by assistance experts provide digital marketing, website development, seo expert services and social media internet seo expert services your branding solutions. seo expert services ,best seo expert services,online seo expert services,
Answers: 3
question
Computers and Technology, 23.06.2019 06:30
When early motion pictures played in movie theaters, they were often accompanied by live organ or piano music. which of the following are the most likely reasons that this happened? (select all that apply). the music was provided to distract audience members from the loud sounds made when filmstrips were changed. the music accompanied the movies because the movies were silent and audiences were used to hearing music during plays in theaters. the music usually was played before, and sometimes after the movie, as an alternative form of entertainment. the music viewers to interpret the dramatic action in the films.
Answers: 2
question
Computers and Technology, 23.06.2019 20:50
3.11.3 quiz: comparing and analyzing function typesquestion 4 of 102 pointswhat can you say about the y-values of the two functions f(x) = 3x2-3 andg(x)=2* - 3?
Answers: 2
You know the right answer?
Consider the following two code segments, which are both intended to determine the longest of the th...
Questions
question
Mathematics, 22.10.2019 23:10
question
Mathematics, 22.10.2019 23:10
question
Social Studies, 22.10.2019 23:10
Questions on the website: 13722363