
You are given the following class and the client class. Examine the code and provide the output of the client class. Explain the intention of the code and comment if the code output matches the intended use of the code. Explain any mismatch between intention and actual code output. Find the problem in this code and explain what you would do to solve the problem.
The Person class is shown in the UML class diagram as follows.
System.out.println("Name: System.out.println("Age: System.out.println("Weight: " + weight + " kg");
" + name);
" + age + " years");
Person |
- name: String |
+ setName(String newname): void |
{
first = firstPerson;
second = secondPerson; }
public Person getFirst() { return first; } public Person getSecond() { return second;}
/**
The writeOutput() in Person as follow.
{
System.out.println(“Name: “ + name);
} */
public void writeOutput() {System.out.println("First person of the twin:"); first.writeOutput();
System.out.println("\nSecond person of the twin:"); second.writeOutput();
} }
/** A client program to use the class Twin */ public class TwinDemo { public static void main(String[] args) {Person goodPerson = new Person("Michael"); Person sibling = new Person("John");
Twin t1 = new Twin(goodPerson, sibling);
} }

Step by stepSolved in 4 steps with 1 images

- When the friend tool is used, this is broken. Talk about the many ways that the "your friend" function can be used.arrow_forwardConvert the following UML diagram into the Java code. Write constructor, mutator and accessor methods for the given class. Create an instance of Account class in a main method using a Demo class. Note: The structure of the class can be compiled and tested without having bodies for the methods. Just be sure to put in dummy return values for methods that have a return type other than void. Student Student Number Average Mark Is Eligible To Enroll Get Seminars Takenarrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





