Consider the following code segment.
Person firstPerson = new Person(“Avery”, 10); Person secondPerson = new Person(“Brandon”, 15); Person thirdPerson = firstPerson; firstPerson.haveBirthday(); secondPerson.setName(“Bethany”); thirdPerson.haveBirthday(); thirdPerson.setName(“Autie”); firstPerson.printMe(); secondPerson.printMe(); thirdPerson.printMe();
a. Draw the memory simulation for the code segment. Include all the changes along the way (i.e. crossing out references, variable value changes, etc.) to show all steps.
b. What is the output of the code segment?
Since you have not provided the code definition of Person class, I cannot possibly predict the outcome of haveBirthday(). Hence, I am ignoring it until I get the required information.
b)
The output of the code segment is:
Autie, 10
Bethany, 15
Autie, 10
Get Answers For Free
Most questions answered within 1 hours.