Computers and Technology

Consider the following method, inCommon, which takes two Integer ArrayList parameters. The method returns true if the same integer value appears in both lists at least one time, and false otherwise. public static boolean inCommon(ArrayList a, ArrayList b)
{
for (int i = 0; i < a. size(); i++)
{
for (int j = 0; j < b. size(); j++) // Line 5
{
if (a. get(i).equals(b. get(j)))
{
return true;
}
}
}
return false;
}

Which of the following best explains the impact to the inCommon method when line 5 is replaced by for (int j = b. size() - 1; j > 0; j--) ?

a. The change has no impact on the behavior of the method.
b. After the change, the method will never check the first element in list b.
c. After the change, the method will never check the last element in list b.
d. After the change, the method will never check the first and the last elements in list b.
e. The change will cause the method to throw an IndexOutOfBounds exception.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 07:30, emilyplays474
What key should you press and hold to select and open multiple files at one time? enter alt control esc
Answers: 1
image
Computers and Technology, 23.06.2019 18:40, brooklyn4932
How does is make you feel when you're kind to others? what are some opportunities in your life to be more kind to your friends and loved ones? imagine a world where kindness has be outlawed. how would people act differently? would your day-to-day life change significantly? why or why not?
Answers: 2
image
Computers and Technology, 23.06.2019 21:00, shawnnoteman1234
Which task uses a simple parameter?
Answers: 1
image
Computers and Technology, 24.06.2019 03:00, paguy12
What is one potential problem associated with an organization purchasing new technology early in its lifecycle
Answers: 1
Do you know the correct answer?
Consider the following method, inCommon, which takes two Integer ArrayList parameters. The method re...

Questions in other subjects:

Konu
Mathematics, 09.06.2020 11:57