Modifiers - Default Value - Default Values for Attributes/Properties
3 important questions on Modifiers - Default Value - Default Values for Attributes/Properties
It is also possible to assign a default value to a property.
In Fig. 6.11, we modify the hasAdultPrivleges Boolean flag to have a default value of False.
What does it mean?
Give an example of why it might be useful to use the default value?
If the field is False, we would then call the isAdult() operation.
If the Member is an adult, then we flip the flag, so that the next time the Member tries to borrow an adult book, we will see that the Member already has permission.
The birthday field is marked private. The value is available ..... Where?
Therefore, the isAdult() operation can read the birthdate field.
The question on the page originate from the summary of the following study material:
- A unique study and practice tool
- Never study anything twice again
- Get the grades you hope for
- 100% sure, 100% understanding