Start learning 50% faster. Sign in now
Encapsulation is a core principle of object-oriented programming that the developer is applying here to protect the bank account’s internal state, specifically its balance. By restricting direct access to the balance variable, the developer ensures that this data can only be modified through predefined methods such as deposit() and getBalance(). These methods act as controlled access points, which not only prevent unauthorized modifications but also allow for validation checks to maintain the integrity of the data. Encapsulation combines data (variables) and methods (functions) within a class, creating a well-defined boundary that prevents external classes from directly accessing or altering the internal state. This approach improves security and data integrity, making the code easier to maintain and less prone to errors. The other options are incorrect for the following reasons: • Option 1 (Abstraction) focuses on simplifying complex systems by hiding unnecessary details and providing a clean interface, but it does not inherently control access to an object's internal state. • Option 3 (Inheritance) allows a new class to inherit properties and behaviors from an existing class, which helps with code reuse but does not inherently involve data hiding or restricting access to internal states. • Option 4 (Polymorphism) enables objects of different classes to be treated as instances of a common superclass, allowing flexible and dynamic code. However, it does not relate to the control or protection of internal data. • Option 5 (Aggregation) represents a "has-a" relationship between objects, where one class contains instances of another class as part of its state. It describes object relationships rather than protecting or hiding internal data within an object.
What is the effective tariff rate on the commodity, when no imported inputs are used?
Which of the following steps can be taken to reduce current account deficit in India?
1. Setting the import quota limits
2. reducing expor...
In a given year, the nominal GDP of a country was $2,500 billion and the real GDP was $2,000 billion. What is the GDP deflator for that year?
How many women were provided free-of-cost gas connections under the PM Ujjwala Yojana, as noted in the Economic Survey 2023-24?
If interest payments are subtracted from gross fiscal deficit, the remainder will be
Which recent policy initiative aims to make India a $5 trillion economy by 2025?
Which of the following statements is NOT CORRECT in the context of an Open Economy IS-LM Model under Floating Exchange Rate (with fixed price) and Perfe...
The impossible trinity is a concept in international economics which states that it is impossible to have all three of the following at the same time
If the regression coefficients of x on y and y on x are -1/4 and -1/9 respectively, then what is the correlation coefficient between x and y?