hi, i ran into the following codes and have some confusion.
Based on the above code, could you please help explain me the questions: what is one member of the above program? what is one attribute of the above program? what's difference between member and attribute in OO? thanks.
I'm not sure I understand your question. Data Member == Attribute, Function Member == Method. So, the x variable in your class definition is a data member(attribute). Now, in the setter you pass in a parameter x. So to access the data member you need to qualify it with this. Otherwise the parameter x hides the data member. Is that what you were asking about?
what is one member of the above program? what is one attribute of the above program? (Ignoring compiler errors...) Well, it's not really a program as the class doesn't have a proper main method. The code describes what a Test object is. According to this code, a Test object has four members (one of which is a method) and three attributes (all ints). what's difference between member and attribute in OO? In Java, when one refers to an attribute, they are usually referring to a part of an object that defines the object's state (i.e. an instance variable). A static variable might be referred to as an attribute of the class in which it's defined. Lots of things are members. Non-static methods and variables (declared outside of any method, constructor, or initialization block) are members of instances of the class in which they are defined. Static methods and variables are members of the class. Constructors are not members. So, an attribute is a member, and a member might be an attribute or a method.