Computers and Technology, 06.05.2020 02:58 austinmiller3030
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".
Answers: 2
Computers and Technology, 22.06.2019 08:00
What is the algorithm for building a binary tree program
Answers: 2
Computers and Technology, 22.06.2019 16:30
Which of the following statements best describes it careers?
Answers: 2
Computers and Technology, 22.06.2019 18:00
Which of the following physical laws can make the flow of water seem more realistic? a. motion b. gravity c. fluid dynamics d. thermodynamics
Answers: 2
Computers and Technology, 24.06.2019 02:00
How are we able to create photographs differently than 100 years ago? explain your answer in relation to your photograph you selected.
Answers: 1
Consider the following two code segments, which are both intended to determine the longest of the th...
Biology, 24.05.2021 14:00
Mathematics, 24.05.2021 14:00
Chemistry, 24.05.2021 14:00
Mathematics, 24.05.2021 14:00
Mathematics, 24.05.2021 14:00
Biology, 24.05.2021 14:00
Chemistry, 24.05.2021 14:00
Mathematics, 24.05.2021 14:00
Mathematics, 24.05.2021 14:00
Mathematics, 24.05.2021 14:00
History, 24.05.2021 14:00
Mathematics, 24.05.2021 14:00
Business, 24.05.2021 14:00
English, 24.05.2021 14:00