Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public class Person { private int age; private String name; public Person(int age, String name) { this.age = age; this.name = name; } public void
public class Person { private int age; private String name; public Person(int age, String name) { this.age = age; this.name = name; } public void haveBirthday() { age++; } } public static void main(String[] args) { Person p1 = new Person(30, "Shaun"); Person p2 = new Person (27, "Amanda"); Person p3 = p2; aMethod(p1, p2); } public static void aMethod (Person a, Person b) { b.haveBirthday(); a = new Person(46, "Alice"); } Consider the Person class as developed in the pre-recorded lecture videos (a simplified version is included above for reference). What is the value of each Person's age instance variable right after the code above executes? p1's age: A p2's age: A p3's age
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started