Question:Which statement is true about the given code?public class Test78 {
public static void main(String[] args) throws Exception {
new JBean().setHeight(1).setWidth(2).setDepth(3).setDensity(9);
}
}
class JBean {
private int height, width, depth, density;
public JBean setHeight (int h) { this.height = h; return this; }
public JBean setWidth (int w) { this.width = w; return this; }
public JBean setDepth (int d) { this.depth = d; return this; }
public JBean setDensity (int d) { this.density = d; return this; }
}
A The code does not compile, because two setters have a formal parameter with the same name.
B The setters of the JBean class are JavaBean-compliant.
C The code compiles, but throws a NullPointerException at run-time.
D The code compiles and runs.