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.
The magnetic field of the Galaxy could gradually act on the dust particles and cause their rotational axes to line up in such a way that their short ...
But understanding what constitutes such (a miracle diet), and making sure that patients get it, isn’t as straightforward as it seems.
COMMISERATION
Directions : In the question below, two sentences with one word in each highlighted in bold. From the options, choose the one that can replace the high...
In the context of international trade, A. the concept of comparative advantage underscore B. the efficiency gains achievable when countries especializ...
Brexit resolved (A) an unfinished (B) business, which, if not remains (C) properly, could threaten (D) peac...
Identify the form of each sentence given here from among the choices given below it:
She was so poor that she could not educate her son.
SCANTY
The soldier showed an exemplary courage.
I. We’ve seen unprecedented growth when it comes to mobile internet penetration due to cheap data tariffs.
II. Agricultural and rural growt...