Question
Which OOP principle allows for restricting access to
certain parts of an object while exposing only necessary parts for interaction?Solution
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.
A social audit:
Social media deliberately seek to ensure that the message does not end with an individual receiver. Social media seek to reach __________.
Observing people and asking them questions are two ways to obtain:
Which of the following is NOT a common reason for new-product failures?
When deciding how the products Pepsi One will differ from Diet Pepsi, Pepsi must develop an effective:
The demand for which the product is not available or is not developed till now, is known as _______ demand.
Which type of store gives shoppers the greatest variety of merchandise?
Companies like Hewlett-Packard and Frito-Lay routinely monitor blogs to gain insight into
A supplier gains power when the product is:
Services performed by plastic surgeons or lawyers are primarily evaluated on _____ properties.