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
IrinaVladis [17]
3 years ago
5

Consider the following method, inCommon, which takes two Integer ArrayList parameters. The method returns true if the same integ

er 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.
Computers and Technology
1 answer:
snow_tiger [21]3 years ago
3 0

Answer:

b. After the change, the method will never check the first element in list b.

Explanation:

After changing the code on line 5 with the one in the question the method will never check the first element in list b. This is because by changing the code you are telling the method to run for every element in list b starting from the last element and moving backward. Since the second argument is j > 0, once j is equal to 0 it will not run the method since it would give a False on the argument and therefore, will never run the method for the element in position 0 (first element in the list)

You might be interested in
‘Bottom of the pyramid’ innovation refers to ancient Egyptian approaches to new product development – true or false?
ruslelena [56]
<span>False. The bottom of the pyramid innovation or 'BoP' innovation refers to people who lives at the bottom of the society generally are hard to adept to new technologies and innovations. However, in recent years, 'BoP' innovation has been proven to have a huge market</span>
5 0
4 years ago
Really helpful, I want to get together tomorrow ,Later I will follow and make it the best answer
blagie [28]

Answer:

c

Explanation:

8 0
3 years ago
Who is willam afton from five nights at freddy
diamong [38]

Answer:

the man behind the murder

8 0
3 years ago
Read 2 more answers
What is the advantage of maintaining a list of keywords while creating a design blueprint?
elixir [45]

Creating a list of keywords and using them throughout your site helps move pages up the ranks of search engines like Bing or Google. They also attract website visitors. Technically, maintaining a list of keywords while creating a webpage is important in search engine optimization.






8 0
4 years ago
Read 2 more answers
What does CTR stand for?
ipn [44]

click through rate is the answer


6 0
3 years ago
Read 2 more answers
Other questions:
  • Are we too dependent on technology if yes then can you please explain?
    12·2 answers
  • You should use _____ software for writing a letter.
    10·1 answer
  • How do i start makeing a Character in the Unreal Game Engine
    14·2 answers
  • While inserting images, the Picture command is usually used to insert photos from a digital camera, and the Clip Art command is
    7·1 answer
  • The term Electronic Privacy Information Center (EPIC) refers to a form of the digital subscriber line technology, which enables
    6·1 answer
  • What was the major sign that lead Professor Shiller to predict the crash of the housing market​
    6·1 answer
  • So can u please follow my new ig acc i just started it yesterday its called stunnerspamz
    5·2 answers
  • Write a Java application that uses the Math class to determine the answers for each of the following: a. The square root of 37 b
    10·1 answer
  • The sameNumber method checks to see if the number of words in the phrase, numwords, is the same number of words contained in the
    5·1 answer
  • Which of the following statements are TRUE about formatting images in HTML.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!