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, 21.06.2019 19:30
Raveena is making a professional presentation for a newly launched product of her company. she wants to incorporate the following features in her presentation. a) to add serial numbers in each slide b) to add name of her company on top of each slide. c) to add the picture of her product on the second slide(the picture of her product is stored on her computer) write the commands/features of her presentation tool using which she can perform the above operations.
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
Jason needs to learn a new web tool. he went through his books to understand more about it. now he wants hands-on experience with using that tool. what would him? jason can use websites where workspace is provided to test the results of your code.
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
To move an excel worksheet tab, simply right-click on it drag and drop it double-click on it delete it
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
Physics, 30.01.2020 17:56
question
English, 30.01.2020 17:56
Questions on the website: 13722367