Question: I will need you to hand tracing these 2 codes for me and show the output. This code was in java language, thank you! 1.

I will need you to hand tracing these 2 codes for me and show the output. This code was in java language, thank you!

1.

I will need you to hand tracing these 2 codes for me

2.

and show the output. This code was in java language, thank you!

// Il Person.java // 11 A simple class representing a person. // public class Person { private String name; private int age; I/ // Sets up a Person object with the given name and age. Il public Person (String name, int age) { this.name = name; this.age = age; } // // Changes the name of the Person to the parameter newName. // public void changeName(String newName) { name = new Name; } I/ Il Changes the age of the Person to the parameter newAge. Il public void change Age (int newAge) { age = newAge; } // // Returns the person's name and age as a string. // public String toString() { return name + Age" + age; } } Il References2.java Illustrates references versus primitive variables // import java.util.Scanner; public class References2 { public static void main(Stringl args) { int age1, age2, age3 Scanner scan = new Scanner(System.in); System.out.println ("Enter three ages..."); age1 = scan.nextInt(); age2 = scan.nextInt(); age3 = scan.nextInt(): // Instantiate three Person objects with the ages read in Person person1 = new Person ("Rachel", age 1); Person person2 = new Person ("Elly", age2); Person person3 = new Person ("Sarah", age3); System.out.println(); System.out.println ("The original three people..."); System.out.println (person 1 +", " + person2 + ", " + person3); Reassign ages in the int variables age1 = age2 age3 = age2 // Reassign the Person objects person 1 - person2; person3 = person2; System.out.println(); System.out.println ("The changed values are..."); System.out.println("Ages (ints):" + age1 +", " + age2 +", " + age3); System.out.println (person 1 + ", " + person2 + ", " + person3); // Make some changes to the integer values and corresponding objects System.out.println(" Changing the second age to 99..."); age2 = 99; System.out.print("Ages (ints):" + age1 + ", " + age2 +", " + age 3); person2.changeAge(age2); System.out.println ("The changed values are..."); System.out.println ("Ages (ints):" + age1 + ", " + age2 +", " + age3); System.out.println (person1 + ", " + person2 + ", " + person3); System.out.println(); System.out.println("Changing the first age to 100..."); age1 = 100; person1.changeAge (age1); System.out.println ("The changed values are..."); System.out.println ("Ages (ints): " + age1 +", " + age2 +", " + age3); System.out.println (person 1 +", " + person2 + ", " + person3); }}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!