Start learning 50% faster. Sign in now
Encapsulation is a fundamental principle of OOP that involves bundling data (attributes) and methods (functions) that operate on the data into a single unit or class. It also restricts direct access to some components of the object, typically by declaring them private or protected. Access is then controlled through public methods known as getters and setters. Encapsulation ensures security and prevents unauthorized or accidental modification of data. For instance, in a class BankAccount , the balance attribute might be private, and only specific methods like deposit() or withdraw() are accessible to modify it. This safeguards the integrity of the data and prevents incorrect usage. Why Other Options Are Wrong Option A : "Polymorphism" Polymorphism deals with methods behaving differently for different object types, not with restricting access. Option C : "Inheritance" Inheritance allows a child class to use the properties and methods of a parent class but does not involve controlling access to data. Option D : "Abstraction" Abstraction hides complexity by exposing only essential features. However, encapsulation is specifically about access control at the data and method level. Option E : "Message Passing" Message passing refers to the communication between objects in OOP but does not control access to internal object components.
Which of the following village is declared India’s first 24*7 solar powered village?
Consider the following statements with respect to the amendments in the limits of e-mandates by the Reserve Bank of India-
I.The Reserve Bank of ...
What was the average cost of a data breach in India in 2024, according to IBM's report?
IMF World Economic Outlook report projected Indian economy to grow at____% in 2023?
Who wrote the book “Anand math”?
What is the purpose of expanding the 'WhatsApp Se Wyapaar' programme by CAIT and Meta?
Consider the following statements:
1. 'Due process of Law' provides for judicial scrutiny against arbitrary action of executive only.
2. T...
How much of India’s total gold reserve is now held domestically, as per RBI’s recent data?
The new type of loans launched by Maharashtra State Co-operative bank for the prisoners to provide a loan amount upto Rs _______ naming it ‘Khavti...
India and __________ took part in 'Konkan Shakti 2021'.