Cards (3)

  • What is an Attribute? #1
    • In object-oriented programming (OOP), an attribute refers to a data member or a property associated with an object or a class 
    • They define the state of an object and can have different values for different instances of the same class 
    • Attributes can be of various data types, such as integers, strings, Booleans, or even other objects 
    • Attributes can have different access rights 
  • Attribute #2
    • The example below shows a Car class object with an attribute called manufacturer 
    • It has a private access meaning that it can be accessed only by instances of the Car class 
    • The data that this attribute will hold must be of the String data type 
    • The image below gives a visual representation of an object of this class being instantiated with a data value of “Ford” :
  • Attributes #3
    • In most cases each class has many different attributes 
    • Below is an example of an object of class "person":