68.1k views
2 votes
Which of the following statements is false?

a. An object's attributes are specified as part of the object’s class.
b. A bank-account object would likely have a balance attribute that represents the amount of money in the account.
c. Each bank-account object knows the balance in the account it represents, but not the balances of the other accounts in the bank.
d. Attributes are specified by the class’s methods.

2 Answers

2 votes

Final answer:

Attributes are specified as part of the object’s class, not by the class’s methods.

Step-by-step explanation:

The false statement in this question is option d: Attributes are specified by the class’s methods. In object-oriented programming, attributes (also known as fields or properties) are specified as part of the object's class, not by the class's methods. Methods are used to define the behavior of an object and can access and modify the object's attributes. For example, in the case of a bank account object, the balance attribute represents the amount of money in the account, and the object's methods would include operations like deposit and withdraw that can change the balance.

User Ventolin
by
7.8k points
2 votes

Answer:

The correct answer is d. Attributes are specified by the class’s methods.

Step-by-step explanation:

Attributes are the individual characteristics that differentiate one object from another and determine its appearance, state or other qualities. Attributes are stored in variables called instance, and each particular object can have different values for these variables. Instance variables, also called data members, are declared in the class but their values are fixed and changed in the object. In addition to the instance variables there are class variables, which apply to the class and all its instances.

Attributes, also called data or member variables are portions of information that an object possesses or knows about itself. A class can have any number of attributes or have none. They are declared with an identifier and the corresponding type of data.

User Wejd DAGHFOUS
by
8.0k points