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
vlada-n [284]
3 years ago
15

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:
sp2606 [1]3 years ago
6 0

Answer:

The answer is "Option b".

Explanation:

In the given code, a static method "inCommon" is declared, that accepts two array lists in its parameter, and inside the method two for loop is used, in which a conditional statement used, that checks element of array list a is equal to the element of array list b. If the condition is true it will return the value true, and if the condition is not true, it will return a false value. In this, the second loop is not used because j>0 so will never check the element of the first element.

You might be interested in
Write a program that continually prompts the user for an integer input until input is entered that is less than 0. Each input th
professor190 [17]

Answer:

Following are the program in the C++ Programming Language:

#include <iostream>//header file

using namespace std;//namespane

//set main method

int main() {  

int a[100]; //set integer type array variable

int value, i = 0; //set integer variables

cout<<"Enter less than 0 to exit:"<<endl; //message for exit

cout<<"Enter the integer numbers:"<<endl; //message to enter numbers

do{ //set do while

cin>>value; //get input from the user

a[i++] = value; //append elements in array

}while(value>=0);

i--;  

cout<<"\nArray are:"<<endl;//message for array

for(int k = 0;k<i;k++){ //set for loop

cout<<a[k]<<" "; //print array

}

return 0;

}

<u>Output</u>:

Enter less than 0 to exit:

Enter the integer numbers:

1

2

3

4

5

-1

Array are:

1 2 3 4 5

Explanation:

Here, we set the integer data type main method "main()" and inside it:

  • we set integer type array variable with index value 100.
  • we set two integer type variable "value" and "i" initialize value 0.
  • we set the do-while loop in which we get the input from the user and and append in the array and pass condition if the value is greater then equal to 0.
  • Finally, set for loop and print the elements of an array.

 

7 0
3 years ago
Play station account
Reika [66]
I have a PlayStation as well
4 0
2 years ago
Read 2 more answers
A large company has a LAN. The manager of the company wants to change it to a WAN
garik1379 [7]

Answer:

\bold{\huge{\fbox{\color{Green}{☑Verified\:Answer}}}}

Explanation:

Router. A router is a networking device typically used to interconnect LANs to form a wide area network (WAN) and as such is referred to as a WAN device. IP routers use IP addresses to determine where to forward packets. An IP address is a numeric label assigned to each connected network device.

Fям:- \small\tt{\blue{(brainly.in)}}

6 0
2 years ago
Renee uses data from the Bureau of Labor Statistics to create a graph for a feasibility report. Which of the following should sh
Lena [83]
. A source note for the data.
5 0
3 years ago
Read 2 more answers
Can you help me in this question
Amiraneli [1.4K]

Answer:

6 2 and 0

Explanation:

This algorithm doesn't work if the list is not ordered ascending.

In this example it is not, and indeed the item "1" is never found.

first cycle: first=0, last=12 so midpoint=6

second cycle: first=0, last=5 so midpoint=2

last cycle: first=0, last=1 so midpoint=0

then last is assigned -1 so the while statement is no longer true.

7 0
2 years ago
Other questions:
  • ?the single most effective security measure for digital devices is to password protect access to them.
    5·1 answer
  • What's the screen that displays results from typing text, performing calculations, or running programs?
    11·1 answer
  • Consider this data sequence: "fish bird reptile reptile bird bird bird mammal fish". let's define a singleton to be a data eleme
    5·1 answer
  • One blog may have a greater social influence than another when it has_______?
    12·2 answers
  • Which two tasks are associated with router hardening? (choose two.)?
    6·1 answer
  • This is the term for the manual process of editing strips of the film before digital editing was created. The term is still used
    9·1 answer
  • On his website, Mario has a video that visitors must click to play. He wants the video to play automatically when the page loads
    9·1 answer
  • How do you change your name in the profile section because i am trying to change my name.
    9·2 answers
  • Read each question below. Then, using the drop-down menus, decide if it represents the purpose, construction, or support aspect
    11·1 answer
  • it is good to know and use the npsd framework while solution envisioning as part of the value discovery cycle. What is NPSD?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!