1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anika [276]
3 years ago
4

Consider the following two code segments, which are both intended to determine the longest of the three strings "pea", "pear", a

nd "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".
Computers and Technology
1 answer:
GrogVix [38]3 years ago
8 0

Answer:

Check the explanation

Explanation:

What is printed as a result of executing this code segment?

true

If b1 and b2 are both initialized to true, what is printed when the code segment has finished executing?

AD

Which of the following correctly compares the outputs of the two code segments?

Code segment I and code segment II produce the same output for all values of x and y.

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

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

You might be interested in
A bug collector collects bugs every day for seven days. Write a program in Python that finds the highest number of bugs collecte
Mama L [17]

Answer:

mylist = [ ]

for i in range(7):

   mylist.append (int(input("Enter the number of bugs for each day ")))

print(mylist)

print("The highest number of bugs is ")

print(max((mylist)))

Explanation:

  1. Create and Initialize an empty (mylist)
  2. Using the .append method, we request and add the bugs for each day into the list
  3. print out the list
  4. Use the max function to find the highest number of bugs in the list and print it out

5 0
3 years ago
In what type of attack does the attacker have the ciphertext of several messages that were encrypted with the same encryption al
Alexus [3.1K]
In ciphertext-only.

EXPLANATION: it is an attack model for cryptanalysis where the attacker is assumed to have access only to a set of ciphertexts. The attack is completely successful if the corresponding plaintexts can be extracted or, even better, the key.
3 0
3 years ago
Which similar computer network components connect multiple devices?
Brut [27]

A Network Switch and Network Hub are similar computer network components that connect multiple devices in a computer network.  A Network switch is used to connect various network segments. It is a small hardware device that joins multiple computers together within one local area network (LAN). A Network Hub connects numerous Ethernet devices together, making them act as a single segment.

8 0
3 years ago
Read 2 more answers
A _____ describes two or more computers connected to each other.
WARRIOR [948]

Answer:

Computer network.

Since it is 2 or more computers connected together.

5 0
3 years ago
Read 2 more answers
No Browsing History While using the browser on your tablet, you realize that it is not keeping a history of websites you have vi
My name is Ann [436]

Answer & Explanation:

No Browsing History:

  • Your browser is probably set to incognito mode, change it to general mode.
  • space set on your drive to save the content from your browser might be completely filled, Make sure you have given your browser enough space on your drive to save contents.
  • The number of days to record the history in your browser is set to 0, Check the settings and make sure it is not set to 0.

Phishing Scam

  • Change all the credentials on the site that you have disclosed.
  • Immediately report the mail to an IT department and necessary authorities.
  • Mark the mail as span and block the mail id.

Suspicious File Attachment

  • May be that the suspicious file contains a virus file. Often such viruses are attached to external "Show-case" files so that the victim is not able to identify them. Once the external file is tried to open, the virus slips into the main memory (your RAM) and start executing in the background, creating copies of itself and executing every copy. Soon they start eating up the main memory (The memory that runs all your programs) making your PC slow to respond.

Antivirus Software Outdated

  • Connected to the Internet and update the antivirus.

Laptop's Physical Security

  • Set a password.
  • install a tracking software.
4 0
3 years ago
Other questions:
  • To what type of user does he most likely have access? Jae is using a computer at the public library to do research she's able to
    9·1 answer
  • In what order does the air flow in a canister vacuum cleaner pass through the following components?
    11·1 answer
  • What is Deep learning
    9·1 answer
  • In a TCP connection, the initial sequence number at the client site is 2,171. The client opens the connection, sends only one se
    14·1 answer
  • A source is:
    15·2 answers
  • NEED IT ASAP. Jack is an accountant. He cant access the spreadsheet software, which is installed on the server. what should jack
    13·1 answer
  • Create a new Java class called AverageWeight. Create two arrays: an array to hold 3 different names and an array to hold their w
    13·1 answer
  • What is data and information
    9·1 answer
  • Does any one know how to do addition of binary numbers​
    6·1 answer
  • Ways on how to conserve energy.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!