enthuware.ocajp.i.v7.2.902

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
alex
Posts: 42
Joined: Tue Feb 12, 2013 4:35 pm
Contact:

enthuware.ocajp.i.v7.2.902

Post 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.

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: enthuware.ocajp.i.v7.2.902

Post 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.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests