Bloomberg LP Interview Question
Software Engineer / DevelopersTeam: Supply Chain
Country: United States
Interview Type: In-Person
Encapsulation is one of OOP principles where objects data should not be accessible directly instead it should be accessed through functions
Inheritance is another OOP concept where one object able to use the same implementation from another class. In other words it able inherits the implementation of another class.
The inheritance can be used when an abstraction of the code points some shared functions/features among more than one objects. It promotes code reuse and polymorphism.
Need for Encapsulation
- instanceofjava December 12, 2014Any program of any programming language contains only two parts.
i.Data
ii.Logic
Out of these two highest priority would be always given to data part.
Functions /logics would e giving output based on the data.
There is no proper security for the data part in the structured programming language programs like c - program.
There was no proper separation between the data and functions of different domains because of which complexity of the programming increases and data insecurity arises
The concept of proper binding is missing in structured programming languages
What is Encapsulation?
The concept of binding the data along with its related and corresponding functions is known as Encapsulation.
Binding
The concept of restricting the availability of the data only to its related areas and related functions it is known as binding.
Because of binding we can restrict the availability of dta to the unrelated functions
So that unrelated functions cannot access the data
Class is the base for encapsulation