Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, Can you draw the memory map for this code? The code is below: public class Person { public class Driver { public static double

Hi, Can you draw the memory map for this code?

The code is below:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
public class Person { public class Driver { public static double MINIMUM SALARY - 1000.00; private String name; public static void task (Person friend, double salary) { private double salary ; double newSal = salary + 100; private StringBuffer calls; Person p _ friend; public Person (String name, double salary) { p. increaseSalary (newsal) ; this . name . name; friend. addCall ("toschool") ; this . salary = salary; friend = null; calls . new StringBuffer ("Calls: ") ; /* HERE */ public Person (String name) { this (name, MINIMUM SALARY) ; public static void main (String arga) { double pay = 4000; public Person increaseSalary (double delta) { Person laura - new Person ( "Laura", 2000) ; salary + delta; task (laura, pay) ; System. out. printin (laura) ; /* Returning reference to current object */ return this; public void addCall (String newCall) { calls . append (newCall) ; public string tostring() { return name + ", $" + salary + ", " + calls;Stack Heap Static Area MINIMUM SALARY 1000.00 Laura P task new Sal 4100 name salary 6100 salary 4000 calls friend null Calls: toschool laura main pay 4000 length 0 argspublic class Passenger { private String name; private int ticketCost; private StringBuffer luggage; private static final int LUGGAGE_COST = 20; public Passenger (String name, int ticketCost) { this . name = name ; this . ticketCost = ticketCost; luggage = new StringBuffer () ; public Passenger addLuggage (String desc) { ticketCost += LUGGAGE_COST; luggage . append (desc) ; return this; public int getTicketCost() { return ticketCost; public Passenger reduceCost (int by) { ticketCost -= by; /* HERE * / return this; public String toString () { return "Passenger [names" + name + ", ticketCosts" + ticketCost + ", luggages" + luggage + "]";public class Driver { public static void inspect (Passenger allp, int which) ( int cost = allp [which] .getTicketCost() ; allp [which] . reduceCost (cost / 2) ; System. out . println (allp [1] ) ; System. out . println (allp [2] ) ; public static void main (String args) { Passenger laura = new Passenger ("Laura", 300) ; laura . addLuggage ("guitar") ; Passenger tom = new Passenger ("Tom", 125) ; tom . addLuggage ("mac" ) . addLuggage ("PC") ; Passenger friends = new Passenger [4] ; friends [1] = laura; friends [2] = tom; inspect (friends, 1)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions