*
The moose likes Beginning Java and the fly likes member and attribute!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "member and attribute!!!" Watch "member and attribute!!!" New topic
Author

member and attribute!!!

Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
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.
Richard Jensen
Ranch Hand

Joined: May 14, 2003
Posts: 67
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?


Richard
N 37 33 W 122 18
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
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.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: member and attribute!!!