Page 1 of 1

enthuware.ocajp.i.v7.2.902

Posted: Tue Feb 12, 2013 4:39 pm
by alex
class Triangle{
public int base;
public int height;
public double area = 0;

public Triangle(int base, int height){
this.base = base; this.height = height;
updateArea();
}
public void updateArea(){
double a = base*height/2;
area = a;
}
public void setBase(int b){ base = b; updateArea(); }
public void setHeight(int h){ height = h; updateArea(); }
}
Which variables are not accessible at class level?

Correct answer is: b, h, a.

It is ok, but..
I don`t understand from explanation how the base, height and area members could be acessible at class level. They are not static fileds, so they are not accessible at class level as well.
I guess there is a poor explanation for this question.
Please check.

Re: enthuware.ocajp.i.v7.2.902

Posted: Tue Feb 12, 2013 5:21 pm
by admin
You are right. The problem statement does not convey the intent of the question correctly. It has now been changed to: "Which variables are not accessible from every where within given class code?"

thank you for your feedback!
Paul.