subject

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.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:30
Jasper and samantha are in a robotics competition. the guidelines state that the robots should be able to move a 10-gram weight at least 2 meters and turn in a circle. jasper and samantha have already built the robot. which step of the design process should they follow next to decide whether their robot meets the minimum criteria for the competition?
Answers: 1
question
Computers and Technology, 23.06.2019 10:50
Your friend kayla is starting her own business and asks you whether she should set it up as a p2p network or as a client-server network. list three questions you might ask to kayla decide which network to use and how her answers to those questions would affect your recommendation.
Answers: 2
question
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
question
Computers and Technology, 24.06.2019 03:00
What is one potential problem associated with an organization purchasing new technology early in its lifecycle
Answers: 1
You know the right answer?
Consider the following method, inCommon, which takes two Integer ArrayList parameters. The method re...
Questions
question
Mathematics, 14.10.2020 01:01
question
Mathematics, 14.10.2020 01:01
question
Biology, 14.10.2020 01:01
Questions on the website: 13722367