enthuware.ocajp.i.v7.2.902
Posted: Tue Feb 12, 2013 4:39 pm
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.
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.