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, 23.06.2019 23:30
A. in packet tracer, only the server-pt device can act as a server. desktop or laptop pcs cannot act as a server. based on your studies so far, explain the client-server model.
Answers: 2
question
Computers and Technology, 24.06.2019 11:00
Need fast im timed in a paragraph of 125 words, explain at least three ways that engineers explore possible solutions in their projects.
Answers: 2
question
Computers and Technology, 24.06.2019 11:00
In three to five sentences, describe how you can organize written information logically and sequentially
Answers: 1
question
Computers and Technology, 24.06.2019 12:50
When is it most apprpriate for a development team to change the definition of done
Answers: 1
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, 14.12.2020 19:20
question
Mathematics, 14.12.2020 19:20
question
Mathematics, 14.12.2020 19:20