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
Naily [24]
4 years ago
7

The following problem illustrates the way memory aliasing can cause unexpected program behavior. Consider the following function

to swap two values
void swap(int xp, int yp)
If this procedure is called with xp equal to yp (i.e. both xp and yp point to the same integer) what effect will it have compared to the situation where xp and yp point to different integers?
a. The value will ahways be the original value in the integer pointed to by xp.
b. It is not possible for xp and yp to have the same value
c. The value will always be zero.
d. The value will always be the original value in the integer pointed to by yp.
e. It will be the same - doesn't matter
Computers and Technology
1 answer:
laila [671]4 years ago
5 0

Answer:

A

Explanation:

The value will be the original stored in the int variables. This is because the method swap(int xp, int yp) accepts xp and yp parameters by value (They are passed by value and not by reference). Consider the implementation below:

public class Agbas {

   public static void main(String[] args) {

   int xp = 2;

   int yp = xp;

   swap(xp,yp); //will swap and print the same values

       System.out.println(xp+", "+yp); // prints the original in values 2,2

 int xp = 2;

   int yp = 5;

   swap(xp,yp); // will swap and print 5,2

       System.out.println(xp+", "+yp); // prints the original in values 2,5

   }

   public static void swap(int xp, int yp){

       int temp = xp;

       xp = yp;

       yp = temp;

       System.out.println(xp+", "+yp);

   }

}

You might be interested in
What factor determines a boat's required equipment??
Eddi Din [679]

Length of the boat is the factor that determines a boat's required equipment.

<span>Safety required equipment are the most important on the boat or vessel, and an operator of the boat must make sure that a boat has safety equipment. According to the length of the boat equipment are required, if the boat is large in length, it contains more equipment than the boat which is small in length.</span>

6 0
3 years ago
Witch is a game story device
natulia [17]
A PS4 because there the most popular game out right now
5 0
4 years ago
Which tab is used to edit objects on the Slide Master and layouts?
andreev551 [17]
When your trying to master the slide layouts you must go to the Slide Layout tab.
4 0
3 years ago
The command prompt is currently in the Old_Data folder. Which two commands can you use to create a new folder called Archive?
Ksivusya [100]

Answer:

mkdir Archive

Explanation:

Assuming that you want to create the new folder within the Old_Data folder then you would only need one command which is the mkdir command. This will create the folder inside the current location which in this case is the Old_Data folder. Like so...

mkdir Archive

Otherwise, you would first need to navigate to the folder that you want to create the new folder. You do this using the "cd /" to navigate to previouse directory and then to the one you want.

7 0
3 years ago
High level language is___________
lara31 [8.8K]

Answer:

B. Machine dependent and machine oriented pls mark me branilest

8 0
3 years ago
Other questions:
  • Which command on the page layout ribbon enables a user to mark where a new page will begin on the printed copy?
    6·1 answer
  • Makes it possible to distribute both power and data using ethernet cabling. select one:
    12·1 answer
  • Which clauses in the Software Engineering Code of Ethics are upheld by a whistleblower (check all that apply). "Respect confiden
    15·1 answer
  • (5 points) Create a user-defined data structure (i.e., struct) called Point that represents a two-dimensional Cartesian coordina
    5·1 answer
  • WILL GIVE BRAINLIEST
    15·1 answer
  • Viruses and worms can affect a system by:
    11·2 answers
  • Difference between second and third generation of computer<br>​
    14·1 answer
  • Write a function endpoints that takes a list of numbers (eg. [5, 10, 15, 20, 25]) and returns a new list of only the first and l
    15·1 answer
  • (I'm confused, might as well ask for help)
    8·2 answers
  • For which three everyday activities do people most typically use computers?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!