Answer (Choose 1 answer)
}
Exit 35
What is the output of the following code?
class Person {
protected int age;
protected void setAge(int val) {
age = val;
}
protected int getAge() {
return age;
}
}
class Professor extends Person {
Professor(String val) { specialization = val;
} String specialization;
String getSpecialization() {
return specialization;
}
public class Main {
public static void main(String args[]) { Professor p1 = new Professor("Binh");
Professor p2 = new Professor("Huong");
p1.setAge(40);
System.out.println(p2.getSpecialization() + ":" + p1.age);
System.out.println(p1.getSpecialization() + ":" + p2.age);