Question
Which of the following best illustrates Encapsulation
in Object-Oriented Programming?Solution
Encapsulation is a key OOP principle that involves combining data (fields) and methods (functions) into a single unit (class) and controlling access to them using access modifiers like private, protected, and public. For instance, a BankAccount class might hide its balance field (using private access) and expose methods like deposit() and withdraw() to manipulate it. Encapsulation ensures data integrity and security , preventing unauthorized access or modifications. Why Other Options Are Incorrect : 2. Allowing multiple objects to interact through message passing : This describes Message Passing , which focuses on communication between objects. 3. Hiding complex implementation details from the user : This is Abstraction , not Encapsulation. 4. Enabling a class to inherit properties and methods from another class : This refers to Inheritance , unrelated to Encapsulation. 5. Defining a one-to-many relationship between objects : This aligns with Aggregation or Composition , not Encapsulation.
Which mining company is going to invest Rs 800 crore to set up a battery aluminium foil 25000 tonne plant in Odisha which will be be commissioned by J...
The research wing of Uttarakhand forest department inaugrated the biggest aromatic garden of India in ________ district.
Which countries received the PROBA-3 satellite signals after its separation?
Consider the following statements regarding Swachh Vayu Sarvekshan-2023-
I.According to the Swachh Vayu Sarvekshan-2023 (or Clean Air Survey), co...
How many branches does Saraswat Co-operative Bank have in India?
Which department received the Skoch SILVER Award 2023 for e-Governance?
Who became the world's first female amputee to summit Mount Vinson, the highest peak of Antarctica?
Which city in Maharashtra will have a 75-feet tall 'Statue of Knowledge' dedicated to Dr B. R. Ambedkar, and how much money has been sanctioned for the ...
In which year was the Swadesh Darshan Scheme launched by the Indian government?
What are the new weight categories for men's boxing as adopted by the Boxing Federation of India?