Consider the following statements. public class PersonalInfo { private String na
ID: 3648038 • Letter: C
Question
Consider the following statements. public class PersonalInfo { private String name; private int age; private double height; private double weight; public void set(String s, int a, double h, double w) { name = s; age = a; height = h; weight = w; } public String getName() { return name; } public int getAge() { return age; } public double getHeight() { return height; } public double getWeight { return weight; } } PersonalInfo person1 = new PersonalInfo(); PersonalInfo person1 = new PersonalInfo(); String n; int a; double h, w; Which of the following statements are valid in Java? (i) person2 = person1; (ii) n = person1.getName(); a = person1.getAge(); h = person1.getHeight(); w = person1.getWeight(); person2.set(n, a, h, w);Question 3 options: Only (i) Only (ii) Both (i) and (ii) None of theseExplanation / Answer
public class PersonalInfo { private String name; private int age; private double height; private double weight; public void set(String s, int a, double h, double w) { name = s; age = a; height = h; weight = w; } This is the proper way to write a program to make it readable. public String getName() { return name; } public int getAge() { return age; } public double getHeight() { return height; } public double getWeight { return weight; } } PersonalInfo person1 = new PersonalInfo(); PersonalInfo person1 = new PersonalInfo(); String n; int a; double h, w; Now the answer is Optoin B Only (ii)