Skip to main content

CIS 163

References

Spring 2021

Objectives:

Problems

You may work in teams of two.

If you haven't yet, clone the CIS 163 sample code repository: https://github.com/kurmasz-SampleCode/CIS163-SampleCode (the SSH URL is git@github.com:kurmasz-SampleCode/CIS163-SampleCode.git).

Load the ReferenceExamples directory into your favorite IDE and make sure you can run the main method in ReferenceReadingExamples.java.

Answer the following questions. It is important to trace through the code before you run it. (I can't stop you from just running the code and writing down the answer; but, if you do, it will come back to haunt you on the exams.)

  1. Predict the output of running case 1 in ReferenceReadingExamples..
  2. Set exampleToRun = 1 in main and run the code. Were you correct? If not, (A) talk to me and make sure you understand why the code behaves the way it does and (B) explain the misconceptions that led to your incorrect answer.
  3. Predict the output of running case 2.
  4. Set exampleToRun = 2, run the code, and explain your misconceptions if your initial answer was incorrect.
  5. Explain how the values of x and y get flipped between the lines init and in.
  6. Why are the changes made by method1 not visible from main?
  7. Predict the output of running case 3.
  8. Set exampleToRun = 3, run the code, and explain your misconceptions if your initial answer was incorrect.
  9. Predict the output of running case 4.
  10. Set exampleToRun = 4, run the code, and explain your misconceptions if your initial answer was incorrect.
  11. Why are the changes made by method4 in case 4 "lost" and not visible in main? You answer should contrast the behavior of method3 in case 3 with the behavior of method4 in case 4.
  12. Predict the output of running case 5.
  13. Set exampleToRun = 5, run the code, and explain your misconceptions if your initial answer was incorrect.
  14. Why are the changes made by method5 in case 5 "lost" and not visible in main?
  15. Predict the output of running case 6.
  16. Set exampleToRun = 6, run the code, and explain your misconceptions if your initial answer was incorrect.
  17. This time, only the change to ptx's' x value is visible in main. The change to the y value is "lost". Why?
  18. Predict the output of running case 7.
  19. Set exampleToRun = 7, run the code, and explain your misconceptions if your initial answer was incorrect.
  20. Inside method7, why does modifying x also modify y?
  21. After running method7, why is only the change to pty visible in the main method? (Why is the change to ptx "lost"?)
  22. Optional: Predict the output of cases 8 - 11.

Submission

Simply email me a document with your answers. If you worked with a partner, be sure both names are on your submission.

Updated Monday, 10 May 2021, 7:32 PM

W3c Validation