Question: class Patient { String name; int height; void updateHeight(int newHeight) { height = newHeight; } // constructor (says how to initialize a new Patient) Patient(String
class Patient {
String name;
int height;
void updateHeight(int newHeight) {
height = newHeight;
}
// constructor (says how to initialize a new Patient)
Patient(String n, int h) {
name = n;
height = h;
}
}
class Doctor {
void checkup(Patient p) {
Patient p2 = new Patient(p.name, p.height+10);
p = p2;
}
public static void main(String[] args) {
Doctor d = new Doctor();
Patient georgia = new Patient("Georgia", 71);
d.checkup(georgia);
System.out.println(georgia.height);
}
}
What does the program print to the console?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
