Question

Consider the following code segment. Person firstPerson = new Person(“Avery”, 10); Person secondPerson = new Person(“Brandon”,...

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?

Homework Answers

Answer #1

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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
R work (must be done in R) Copy and paste your R code and output into...
R work (must be done in R) Copy and paste your R code and output into a word document, along with your written answers to the questions. Follow these instructions to import the necessary dataset:  Before opening the dataset needed for this problem, you’ll need to call the “car” package. Run the following line of code: > library(car)  Now you can import the “ States” dataset and use it to answer the question below. Name the data frame...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue = red + 2 * 5 red++; blue = blue + red; cout << blue; 4 points    QUESTION 2 Is the following statement true or false? The Boolean expression in the following if statement will be true for all values of x in the range from 10 to 20 (including the endpoints) and false for all other values: int x; if (x >=...
Consider the following code snippet: Employee programmer = new Employee(10254, "exempt"); String str = programmer.toString(); Assume...
Consider the following code snippet: Employee programmer = new Employee(10254, "exempt"); String str = programmer.toString(); Assume that the Employee class has not implemented its own toString() method. What value will the variable str contain when this code is executed? Group of answer choices the variable will become a null reference the code will not compile because Employee has not implemented toString() the default from Object, which is the class name of the object and its hash code the string representations...
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's...
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's algorithm to ensure mutual exclusion in the respective critical sections of the two processes, and thereby eliminate the race condition. In order to implement Peterson's Algorithm, the two processes should share a boolean array calledflagwith two components and an integer variable called turn, all initialized suitably. We will create and access these shared variables using UNIX system calls relating to shared memory – shmget,...
Use the business developed below. Explain the 10 assumptions that you used in developing this business....
Use the business developed below. Explain the 10 assumptions that you used in developing this business. Overview- We are going to start a bakery business as I have my interest in bakery. This is going to be start-up business plan. The name of our Bakery would be “Bake It or Make It”. It would be managed by me along with my team of new bakers around the city. Opening a bakery at initial stage would involve a lot of investment...
Use the business developed below. Explain the 10 assumptions that you used in developing this business.(...
Use the business developed below. Explain the 10 assumptions that you used in developing this business.( please explain ) Overview- We are going to start a bakery business as I have my interest in bakery. This is going to be start-up business plan. The name of our Bakery would be “Bake It or Make It”. It would be managed by me along with my team of new bakers around the city. Opening a bakery at initial stage would involve a...
Plagiarism Certification Tests for Undergraduate College Students and Advanced High School Students These tests are intended...
Plagiarism Certification Tests for Undergraduate College Students and Advanced High School Students These tests are intended for undergraduate students in college or those under 18 years of age. Read these directions carefully! The below test includes 10 questions, randomly selected from a large inventory. Most questions will be different each time you take the test, You must answer at least 9 out of 10 questions correctly to receive your Certificate. You have 40 minutes to complete each test, and you...
1. Explain and give examples of the 5 existing business model patterns. 2. Can the business...
1. Explain and give examples of the 5 existing business model patterns. 2. Can the business below use that business model pattern? Explain. Overview- We are going to start a bakery business as I have my interest in bakery. This is going to be start-up business plan. The name of our Bakery would be “Bake It or Make It”. It would be managed by me along with my team of new bakers around the city. Opening a bakery at initial...
Analyze the market segmentation, which is explained in the market segmentation for business design below. Overview-...
Analyze the market segmentation, which is explained in the market segmentation for business design below. Overview- We are going to start a bakery business as I have my interest in bakery. This is going to be start-up business plan. The name of our Bakery would be “Bake It or Make It”. It would be managed by me along with my team of new bakers around the city. Opening a bakery at initial stage would involve a lot of investment and...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT