Mar 07: Object References
Learning Objectives
After today's class, you should be able to:
- Draw a memory diagram that includes arrays, objects, and methods.
- Use a memory diagram to indicate when two variables are aliased.
- Predict the final output of a program based on a memory diagram.
Reminders¶
- Finish the Week 7 reading
- Submit HW 5 on Gradescope
- Activity 9 – optional practice
Lesson Outline¶
Review [5 min]
Diagram [20 min]
Car
class from Lab 3- Draw example below
Activity [25 min]
Example Code¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
A 1989 Dodge that is going 5.0 mph
A 2024 Tesla that is going 5.0 mph
A 1989 Dodge that is going 10.0 mph
Winner at index 0
A 1989 Dodge that is going 10.0 mph