Question: Given the following code: public class Person { private int age; private String status; public Person ( ) { this.status = young; } this. age

Given the following code:
public class Person {
private int age;
private String status;
public Person(){
this.status = "young";
}
this. age =0;
public void getolderByYears(int years){
this.age = this.age + years;
if (this.age >1){
status = "old";
}
}
}
public class Main {
public static void main(String[] args){
Person bubbles = new Person();
Person buttercup = new Person();
Person blossom = new Person();
ArrayList Person > people = new ArrayList >();
people. add (bubbles);
people. add (buttercup) ;
people. add (blossom);
int ageAmount =1;
for (Person p : people){
p. getolderByYears (ageAmount);
ageAmount = ageAmount +1 ;
}
//POINT A
//POINT B
}
}
Part 1
We hit POINT A once for each of the people (bubbles, buttercup and blossom) in the list -- each time
referenced by "p". Which of those people (on their "turn" through the loop) will have the status set to
"old"?
(a) bubbles
(b) buttercup
(c) blossom
Select all possible options that apply.
Part 2
At Point B, what is the value of ageAmount?
(a)3
(b)2
(c)4
(d)1
(e)0
(f)5
 Given the following code: public class Person { private int age;

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!