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.
Which of the following statements is/are correct about Unified District Information System for Education+ (UDISE+)?
I. UDISE+ is one of the large...
A famous book ‘We the People’ is being penned down by which of the following writers?
Consumer behavior can be explained with which of the following?
I. Cardinal utility analysis
II. Ordinal utility analysis
At what elevation above sea level will the world's highest fighter airfield at Nyoma in Ladakh, constructed by BRO India, be located?
Which portal has been launched by the Government of India for its complete fauna checklist?
In which country the Prime Minister Shri Narendra Modi has received the 'World Peace Award'?Â
India’s first indigenous thrombectomy device, launched in May 2025, is used for treating which condition?
Consider the following statements about Twin Engine Deck Based Fighter (TEDBF):
1. It is a multirole combat aircraft currently under developmen...
Who was honored with the prestigious K.P.P. Nambiar Award by the IEEE Kerala Section?
Which state government recently signed an MoU with the National Forensic Science University (NFSU), Gandhinagar, to establish a center of excellence in ...