Swapping People
The files SwapDriver.java,
TestSwap.java, and Person.java
contains a program that illustrates parameter passing.
SwapDriver.java is the driver - it
creates two Person objects and calls a static method swapPeople which is defined
in TestSwap.java.
Do the following:
- Trace the execution of the program
using diagrams similar to those in Figure 6.5 of the text (which is a trace
of the program in Listings 6.15 - 6.17). Also show what is printed by the
program.
- Compile and run the program to
see if your trace was correct.
- Modify the swapPeople method so
that it does what the documentation says it does, that is, the two Person
objects passed in as actual parameters are actually changed -- person1 will
be person2, and person2 will be person1.