1. Compile and run the program to get the output. Explain the output. class Address String...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Compile and run the program to get the output. Explain the output. class Address String city, state; public Address(String city, String state) { this.state = state; } class Patient { String name; Address address; public Patient(String name, Address address) { this.address address; } void display(){ System.out.println("Name: " +name); System.out.println("Address: "+address.city } public class ExampleAggregation { public static void main(String[] args) { this.city= city; System.out.println("PATIENT INFORMATION"); ptl.display(); pt2.display(); this.name = name; Address addr1 = new Address("Batu Pahat","Johor"); Address addr2 = new Address("Shah Alam","Selangor"); Patient pt1 = new Patient("Yaya",addrl); Patient pt2 = new Patient("Ying",addr2); +","+address.state+" "); 1. Compile and run the program to get the output. Explain the output. class Address String city, state; public Address(String city, String state) { this.state = state; } class Patient { String name; Address address; public Patient(String name, Address address) { this.address address; } void display(){ System.out.println("Name: " +name); System.out.println("Address: "+address.city } public class ExampleAggregation { public static void main(String[] args) { this.city= city; System.out.println("PATIENT INFORMATION"); ptl.display(); pt2.display(); this.name = name; Address addr1 = new Address("Batu Pahat","Johor"); Address addr2 = new Address("Shah Alam","Selangor"); Patient pt1 = new Patient("Yaya",addrl); Patient pt2 = new Patient("Ying",addr2); +","+address.state+" ");
Expert Answer:
Answer rating: 100% (QA)
The provided code is an example of aggregation in Java where one class is used within another class ... View the full answer
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
WHAT IS THE FUNDAMENTAL METAPHOR OF THE UNIX OPERATING SYSTEM? EXPLAIN
-
re Regular Languages and Finite Automata (a) Let L be the set of all strings over the alphabet {a, b} that end in a and do not contain the substring bb. Describe a deterministic finite automaton...
-
Carey Company is borrowing $200,000 for one year at 12 percent from Second Intrastate Bank. The bank requires a 20 percent compensating balance. What is the effective rate of interest? What would the...
-
A 155-g aluminum cylinder is removed from a liquid nitrogen bath, where it has been cooled to -196 C. The cylinder is immediately placed in an insulated cup containing 80.0 g of water at 15.0 C. What...
-
Using the FRED economic database ( https://fred.stlouisfed.org/ ), graph the Effective Federal Funds rate from 2007 to the present. Now click Edit Graph and then Add Line. Add the Unemployment rate....
-
Crush Autosmashers can purchase a new electromagnet for moving cars at a cost of \($20,000.\) At the end of its useful life, the electromagnet will be worth \($1,000.\) If Crushs MARR is 12...
-
Paige Company has completed all of its operating budgets. The sales budget for the year shows 50,000 units and total sales of $2,000,000. The total unit cost of making one unit of sales is $22....
-
The Williamson Corporation wants to help its employees save for retirement by allowing them to defer part of their compensation on a pretax basis that the company would match. The best option for...
-
Mr. M has been employed as an engineer by A Ltd., a company incorporated in Hong Kong. During the year ended 31 March 2019, Mr. M had the following income and expenditure. A monthly salary of...
-
Show that the function is a solution to y(x) = = Ce + Czex d y dy 2y = 0 dx dx for any choice of the constants C1 and C2. Then, determine C1 and C2 so that the initial conditions y(0) = 2 and dxx (0)...
-
What exactly is cybersecurity? Is it a function or task? Is it a strategy? Is it about crime? Is it about national security?
-
A new director joins your organization, and you know that this director's division will be highly impacted by your project. What should you do next? A O Email the new director introducing yourself...
-
Obligations for the performance of an application, contractually, are often called a service level agreement (SLA). True False
-
Question 1: Smartphones are computer systems and contain O a mouse O a thumb wheel nonvolatile storage, ports, and a CPU battery backup
-
Factors such as a firm's objectives, procedures, and systems are examples of business buyer behavior. a. Cultural a. b. Technological c. Organizational d. Political e. Interpersonal influences on...
-
D, E, and F are partners in a CPA firm sharing profits and losses in a ratio of 2:2:3, respectively. Immediately prior to liquidation, the following balance sheet was prepared: Assets Liabilities and...
-
The Strahler Stream Order System ranks streams based on the number of tributaries that have merged. It is a top-down system where rivers of the first order are the headwaters (aka outermost...
-
Write an application that prints the following two dimensional matrix. Use for loops to minimize the number of output statements. 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 55555
-
Demonstrate that large integers like 1234567890 are equivalent to their counterparts with the underscore separators, namely 1_234_567_890: a) 1234567890 == 1_234_567_890 b) Print each of these values...
-
Drivers often want to know the miles per gallon their cars get so they can estimate gasoline costs. Develop an app that allows the user to input the number of miles driven and the number of gallons...
-
What were Aristotles two main classifications of motion?
-
One kg weighs 10 N on Earth. Would it weigh more or less on the Moon?
-
Which has the greater density1 kg of water or 10 kg of water?
Study smarter with the SolutionInn App