Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Publishing With Filemaker Pro On The Web

Authors: Maria Langer

1st Edition

0201696657, 978-0201696653

More Books

Students also viewed these Databases questions