A)
->combining data and eligible code that acts upon that data into one unit is known as encapsulation.
->in an application, programmatically, by defining a class we combine variables and methods as a unit. Therefore, we say class is the basis to implement encapsulation. But memory is not allocated unless we create an instance of the class. I.e. object. Actual storage of data happens in the object. Methods act upon the object to process data stored in the object.
We say that object implements encapsulation. However, object can’t be created without class.
->theoretical object oriented feature called encapsulation is programmatically is achieved through class and object.
Additional:
Encapsulation is combining data and its eligible code in a unit.
Encapsulation is object oriented feature but class is not.
To achieve object oriented feature encapsulation achieve with class. Class is basis for organizing data and methods. So class is the basis to implement the encapsulation. Object is real implementation.-> -->A class is a user defined data type.
->a class is similar to a structure in c as far as organizing one entity’s related data into one unit is concerned.
->a class contains properties/variables and eligible methods that acts upon the data stored in those variables. Therefore, we say class is the basis of encapsulation.
->a class is a specification for the structure and behavior of the object.
->A class is a template/plan/proposal for the object.
->An object is an instance of a class.
->Physical realization of a class is nothing but an object.
->an object is a data storage area. Where one real world entity’s data is stored in secured manner.
->in an object oriented application, a fundamental unit of data storage is nothing but an object.
->An object has variables and associated methods.
->instance variable of a class contributed to the structure/size of the object but not the methods.
Even though methods belong to the object, they don’t contribute to the size of the object.
An object has 3 things.
1) Identity
2) State
3) Behavior
->object implements the encapsulation, class is basis of the object.
Identity: name of the object with which, it is uniquely identified known as identity. In java, reference acts as the name of the object and hence reference is object’s identity.
State:
Instance of the class are nothing but properties of the object. Properties and current values they hold put together is nothing but state of the object. I.e. data stored in an object is known as state of the object. State in nothing but date. Not variable.
Behavior:
A method of the object is known as it behavior. An object’s state can be manipulated only by its behavior. This is the complete essence of object orientation. External behavior can influence the object behavior to change the object state. The functional part of the object is nothing but behavior.
Comments
Post a Comment