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.
‘M’ is 60% more efficient than ‘N’. ‘N’ started the work alone and worked for 20 days and after that ‘N’ is replaced by ‘M’. If the ...
Two pipes A and B can fill a tank in 24 min., and 32 min, respectively. If both the pipes are opened simultaneously, after how much time B should be clo...
A and B together can complete a piece of work in 40 days while B and C together can complete the same work in 36 days. All of three togeth...
The team of A B and C was supposed to complete a piece of work. Working alone, A could have completed the same work in 190 hours. B could have completed...
If 3 men with 4 boys can earn Rs. 2940 in 7 days and 5 men with 9 boys earn Rs. 4620 in 6 days. In how many days will 5 men with 3 boys earn Rs. 11...
If one child has half the work efficiency of an adult, determine the duration required for 8 children to construct a wall, which is 60% as large as the ...
Two workers A and B were put to some work. If A worked alone, he would have taken 8 hours more than when both A and B had worked together. If B worked a...
A man can complete a task in 20 days, a woman can finish it in 30 days, and a boy can do the same task in 60 days. To complete the task in just 3 days, ...
A and B can complete a task in 63 days and 42 days, respectively. If C is 40% more efficient than the combined efficiency of A and B, how much time will...
‘A’ and ‘B’ together can complete a work in 12 days, while ‘B’ and ‘C’ together can complete the work in...