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");

}

Which of the following best describes the output produced by code segment I and code segment II?

Both code segment I and code segment II produce correct output for all values of str.

Neither code segment I nor code segment II produce correct output for all values of str.

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".

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".

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: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:30
By refraining from constructing a building until they are certain that it will not cause harm to the environment, an organization is adhering to the
Answers: 2
question
Computers and Technology, 23.06.2019 01:40
You have a linux system that has a 1000gb hard disk drive, which has a 90gb partition containing an ext4 filesystem mounted to the / directory and a 4gb swap partition. currently, this linux system is only used by a few users for storing small files; however, the department manager wants to upgrade this system and use it to run a database application that will be used by 100 users. the database application and the associated data will take up over 200gb of hard disk space. in addition, these 100 users will store their personal files on the hard disk of the system. each user must have a maximum of 5gb of storage space. the department manager has made it very clear that this system must not exhibit any downtime as a result of hard disk errors. how much hard disk space will you require, and what partitions would you need to ensure that the system will perform as needed? where would these partitions be mounted? what quotas would you implement? what commands would you need to run and what entries to /etc/fstab would you need to create? justify your answers.
Answers: 3
question
Computers and Technology, 23.06.2019 18:50
Ais a picture icon that is a direct link to a file or folder
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Now you’re on your own. include a short summary of this section with plots in your lab report. write a matlab script file to do steps (a) through (d) below. include a listing of the script file with your report. 1 the soundsc(xx,fs) function requires two arguments: the first one (xx) contains the vector of data to be played, the second argument (fs) is the sampling rate for playing the samples. in addition, soundsc(xx,fs) does automatic scaling and then calls sound(xx,fs) to actually play the signal. mcclellan, schafer, and yoder, dsp first, 2e, isbn 0-13-065562-7. prentice hall, upper saddle river, nj 07458. c 2015 pearson education, inc. 4 mcclellan, schafer and yoder, signal processing first. prentice hall, upper saddle river, new jersey, 2003. c 2003 prentice hall. (a) generate a time vector (tt) to cover a range of t that will exhibit approximately two cycles of the 4000 hz sinusoids defined in the next part, part (b). use a definition for tt similar to part 2.2(d). if we use t to denote the period of the sinusoids, define the starting time of the vector tt to be equal to t , and the ending time as ct . then the two cycles will include t d 0. finally, make sure that you have at least 25 samples per period of the sinusoidal wave. in other words, when you use the colon operator to define the time vector, make the increment small enough to generate 25 samples per period. (b) generate two 4000 hz sinusoids with arbitrary amplitude and time-shift. x1.t / d a1 cos.2
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, 12.01.2021 20:30
question
Biology, 12.01.2021 20:30
question
Physics, 12.01.2021 20:30
Questions on the website: 13722359