Question
Consider a BankAccount class with a balance field. To
properly encapsulate balance, it should be declared as:Solution
Declaring balance as private ensures that it can only be accessed and modified by methods within the BankAccount class itself. This prevents external code from directly manipulating the balance, which could lead to inconsistencies or security issues. Public getter/setter methods would then be provided for controlled access.
Cinnabar is an ore of which metal?
Which gas is the chief component of Bio-gas?
Which of the following is used in alcoholic drinks?
Whose experiments supports Abiotic synthesis?
Which of the following pollutants is the major contributor to photochemical smog?
Which of the following fatty acids does NOT form soap?
Which of the following is the richest source of phosphorus?
"Schist" is the example of which type of rock?
Which element is known as the 'King of Chemicals.
_____________ has the maximum attraction force between the molecules.