Question

12.[9 points] The following question consists of 3 java files (TestPerson java Person javaa Name java). When TestPerson.java is compiled, write down write down the exact output of the class TestPerson ( public static void main(Stringl] args) f Person a new Person(new Name (Superman)) Person b new Person(new Name(Ninja)); Person c new Person(new Name(Thor)); Person d new Person(new Name(Batman)); Person e new Person(new Name(Hulk)); Person f = new Person(new Name(Poson Ivy)); Person g new Person (new Name(Professore)); Person h new Person(new Name( Cat woman)); Person i new Person(new Name(Captian America)); a.setx(b); a.sety(c); b. setx(d); public class Person t c.setY(e); d. setx(f); e.sety(g) protected Nane name; protected Person mother; protected Person father private static final String twoBlanks private static String tab public Person(Name name) g.sety(h); e.setX(i); this . name name ; System.out.println(a); public Name name() ( return name; public void setY(Person mother) t this.mother mother; ublic class Name f protected String first; public Name (String first) ( public void setx(Person father) ( this.first first; this.father father; ublic String getFirst) f public String tostring)t String s new String(name); sn if (mother !=null) { return first; ublic void set First (String first) { | tab += twoBlanks; s + tab + x: + mother; tab - tab.substring(2); this.first first; blic String toString() tring s new string(); f (first!- null) s firsti return s.trim(); (father!-null) t tab + twoBlanks; s tab y:father; tab tab.substring(2); return s; Predict the output of the following code :
0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Predict the output of the following code : 12.[9 points] The following question consists of 3...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Java. What is the output of this code? Ace.java public class Ace { private double a;...

    Java. What is the output of this code? Ace.java public class Ace { private double a; public Ace ( double x) {       a = x; } public void multiply (double f) {       a *= x;         } public String toString () {       return String.format ("%.3f", x); AceDem.java public class AceDemo { public static void main(String args[]) {    Ace card = new Ace (2.133); card.multiply (.5); System.out.println (card); } }

  • CSCI-2467 Lab 11 – Refactor LinkedList Application to use Generics Background The code consists of three...

    CSCI-2467 Lab 11 – Refactor LinkedList Application to use Generics Background The code consists of three files that implement and use a simple linked list. The code was written in early Java-style using the Object class in order to allow the linked list to be a list of objects of any type. While the code works, it is not type-safe. Refactor the code to use Java Generics. You will need to change the Main class to create a linked list...

  • Can the folllowing be done in Java, can code for all classes and code for the...

    Can the folllowing be done in Java, can code for all classes and code for the interface be shown please. Modify the GeometricObject class to implement the Comparable interface and define a static max method in the GeometriObject class for finding the larger of two GeometricObject objects. Write a test program that uses the max method to find the larger of two circles, the larger of two rectangles. The GeometricObject class is provided below: public abstract class GeometricObject { private...

  • I need the following code to keep the current output but also include somthing similar to...

    I need the following code to keep the current output but also include somthing similar to this but with the correct details from the code. Truck Details: Skoda 100 Nathan Roy 150.5 3200 Details of Vehicle 1: Honda, 5 cd, owned by Peter England Details of Vehicle 2: Skoda, 100 cd, owned by Nathan Roy, 150.5 lbs load, 3200 tow --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- class Person {     private String name;        public Person()     {        name="None";     }       ...

  • I need help with my java code i am having a hard time compiling it //...

    I need help with my java code i am having a hard time compiling it // Cristian Benitez import java.awt.Color; import java.awt.Graphics; import java.util.ArrayList; import javax.swing.JPanel; Face class public class FaceDraw{ int width; int height; int x; int y; String smileStatus; //default constructor public FaceDraw(){ } // Getters and Setters for width,height,x,y public int getWidth(){ return width; } public void setWidth(int width){ this.width=width; } public int getHeight(){ return height; } public void setHeight(int height){ this.height=height; } public int getX(){ return...

  • Please fill in the remaining code necessary and follow the instructions below this is an abstract...

    Please fill in the remaining code necessary and follow the instructions below this is an abstract class; it represents an department in the company. This class cannot be instantiated (objects created), but it serves as the parent for other classes. Department – This class represents a department within the company. 1. Provide the implementation (the body) for the following methods: public int getDepartmentID()) public String getDepartmentName()) public Manager getManager()) 2. Fix the implementation for the following method– substitute “blah” with...

  • 12. Predict the output generated at the marked println lines in the following program. The program...

    12. Predict the output generated at the marked println lines in the following program. The program makes use of the class Employee that is also given. Please enter your answers in the space provided below the code. public class Employee { private String name; private double salary; public Employee(String name, double salary) { this.name = name; this.salary = salary; } public String getName() { return name; } public double getSalary() { return salary; } public void raiseSalary(double percent) { double...

  • JAVA help Create a class Individual, which has: Instance variables for name and phone number of...

    JAVA help Create a class Individual, which has: Instance variables for name and phone number of individual. Add required constructors, accessor, mutator, toString() , and equals method. Use array to implement a simple phone book , by making an array of objects that stores the name and corresponding phone number. The program should allow searching in phone book for a record based on name, and displaying the record if the record is found. An appropriate message should be displayed if...

  • The method m() of class B overrides the m() method of class A, true or false?...

    The method m() of class B overrides the m() method of class A, true or false? class A int i; public void maint i) { this.is } } class B extends A{ public void m(Strings) { 1 Select one: True False For the following code, which statement is correct? public class Test { public static void main(String[] args) { Object al = new AC: Object a2 = new Object(); System.out.println(al); System.out.println(a): } } class A intx @Override public String toString()...

  • Java: Return an array of booleans in a directed graph. Please complete the TODO section in...

    Java: Return an array of booleans in a directed graph. Please complete the TODO section in the mark(int s) function import algs13.Bag; import java.util.HashSet; // See instructions below public class MyDigraph { static class Node { private String key; private Bag<Node> adj; public Node (String key) { this.key = key; this.adj = new Bag<> (); } public String toString () { return key; } public void addEdgeTo (Node n) { adj.add (n); } public Bag<Node> adj () { return adj;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT