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.
enthuware.ocajp.i.v7.2.902
Moderators: Site Manager, fjwalraven
-
- Posts: 42
- Joined: Tue Feb 12, 2013 4:35 pm
- Contact:
Online
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: enthuware.ocajp.i.v7.2.902
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.
thank you for your feedback!
Paul.
Who is online
Users browsing this forum: No registered users and 2 guests