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
Paul [167]
2 years ago
6

Assume the method doSomething has been defined as follows: public static void doSomething (int[] values, int p1, int p2) { int t

emp = values[p1]; values[p1] = values[p2]; values[p2] = temp; } What does the method do? Group of answer choices
a.It inserts a new value into the array values.
b.It swaps the integer values stored in positions p1 and p2 of the array values.
c.It copies the integer array values to a new array.
d.It moves each element of the array values to a higher index position.
Computers and Technology
1 answer:
Dmitriy789 [7]2 years ago
8 0

Answer:

The answer to this question is option "b".

Explanation:

In the method definition, we perform swapping. To perform swapping we define a variable "temp" that swap values of variable p1 and p2 and store in array that is "values". and other options are not correct that can be defined as:

  • In option a, It does not insert any new value in array because we do not pass any value in function.
  • In option c, The function does not copy and assign a value in a new array because in this function we not assign any new array.  
  • In option d, It is incorrect because it can not move an element into high index position.
You might be interested in
Who made the first electronic device?
emmasim [6.3K]
Joseph Henry in about 1835. He is American and he made something called a relay.
6 0
2 years ago
Which part of the processing unit does the logic operations?<br> A. ALC<br> B. CU
ycow [4]

isn't it ALU I got told it was ALU

4 0
3 years ago
Which type of RAM is used exclusively in laptops?<br> a) SODIMM<br> b) DDR3<br> c) DDR<br> d) DDR4
Black_prince [1.1K]

Answer:

DDR3

Explanation:

6 0
3 years ago
Two cars A and B leave an intersection at the same time. Car A travels west at an average speed of x miles per hour and car B tr
drek231 [11]

Answer:

Here is the C++ program:

#include <iostream>  // to use input output functions

#include <cmath>  // to use math functions like sqrt()

#include <iomanip>  //to use setprecision method

using namespace std;   //to access objects like cin cout

int main ()  {  //start of main function

  double speedA;  //double type variable to store average speed of car A

  double speedB;  //double type variable to store average speed of car B

  int hour;  //int type variable to hold hour part of elapsed time

  int minutes;  //int type variable to hold minutes part of elapsed time

  double shortDistance;  // double type variable to store the result of shortest distance between car A and B

  double distanceA;  //stores the distance of carA

  double distanceB;  //stores the distance of carB

  double mins,hours;   //used to convert the elapsed time

cout << "Enter average speed of car A: " << endl;  //prompt user to enter the average speed of car A

cin >> speedA;   //reads the input value of average speed of car A from user

cout << "Enter average speed of car B: " << endl ;  //prompt user to enter the average speed of car B

cin >> speedB;   //reads the input value of average speed of car A from user

cout << "Enter elapsed time (in hours and minutes, separated by a space): " << endl;  //prompts user to enter elapsed time

cin>> hour >> minutes;    //reads elapsed time in hours and minutes

  mins = hour * 60;  //computes the minutes using value of hour

  hours = (minutes+mins)/60;     //computes hours using minutes and mins

distanceA = speedA * (hours);  // computes distance of car A

distanceB = speedB * (hours);   //computes distance of car B

   shortDistance =sqrt((distanceA * distanceA) + (distanceB * distanceB));   //computes shortest distance using formula √[(distanceA)² + (distanceB)²)]

cout << "The (shortest) distance between the cars is: "<<fixed<<setprecision(2)<<shortDistance;

//display the resultant value of shortDistance up to 2 decimal places

Explanation:

I will explain the program with an examples:

Let us suppose that the average speeds of cars are:

speedA = 70

speedB = 55

Elapsed time in hours and minutes:

hour = 2

minutes = 30

After taking these input values the program control moves to the statement:

mins = hour * 60;  

This becomes

mins = 2 * 60

mins = 120

Next

hours = (minutes+mins)/60;

hours = (30 + 120) / 60

         = 150/60

hours = 2.5

Now the next two statements compute distance of the cars:

distanceA = speedA * (hours);  

this becomes

distanceA = 70 * (2.5)

distanceA = 175

distanceB = speedB * (hours);

distanceB = 55 * (2.5)

distanceB = 137.5

Next the shortest distance between car A and car B is computed:

shortDistance = sqrt((distanceA * distanceA) + (distanceB * distanceB));

shortDistance = sqrt((175 * 175) + (137.5 * 137.5))

                        = sqrt(30625 + 18906.25)

                        = sqrt(49531.25)

                        =  222.556173

shortDistance =  222.56

 

Hence the output is:

The (shortest) distance between the cars is: 222.56        

3 0
3 years ago
What value(s) can be input into this code for the value of number that will cause the code in the loop to execute? Scanner keybo
Marianna [84]

Answer:

There is no value of the number variable, for which the loop can be true in any iteration.

Explanation:

  • The above loop states the condition that the value should be less than 100 and greater than 500. It is because the loop holds the and condition which gives the true if both conditions will be true.
  • The first condition of the while loop states that the value of the number variable is less than the 100.
  • The second condition of the while loop state that the value of the number variable is greater than the 500.
  • The and condition of the while loop will true if both conditions will true.
  • But there is no number which is less than 100 and greater than 500.
  • So no number can satisfy the while condition to be true.

5 0
3 years ago
Other questions:
  • In a mission critical environment, performing maintenance operations on a host FIRST requires which of the following?
    6·1 answer
  • Plz answer me will mark as brainliest ​
    7·2 answers
  • When numbers are changed in cells that are involved in formula is the formulas are automatically
    14·1 answer
  • Why would a brokered CD pay more than a regular CD?
    13·1 answer
  • Is a process in which an attacker attempts to acquire information about your network and system by social means, such as talking
    9·1 answer
  • What is the value of i printed? j = i = 1 i += j + j * 5 print("What is i?", i)
    11·1 answer
  • A utility program that makes a copy of all files or selected files that are in the libraries is called ______
    6·1 answer
  • How to be fluent in computer
    10·2 answers
  • An installation is:<br> please help asap
    11·1 answer
  • ¿Cuál es la función que cumplía los sofistas y Porque eran tan importantes?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!