Class As The Basis of All Computation
Class As The Basis of All Computation
In OOP, data and functions operating on that data are wrapped in a single unit called object
Thus, an object encapsulates both data and functions operating on that particular data
An object is unique identifiable entity which has some characteristics and behaviour
A class is a set of objects which share some common characteristics and behaviour
Characteristics of an object –
An object stores its state in member variables of the class and exposes its behaviour through the
The concept of data hiding states that the information obtained should be hidden from the rest of
the system
Encapsulation provides-
* Reliability
* Reusability
All variables declared inside a class are called member variables or data members of that class
1. Local Variables –
Can be accessed only within the method in which they are declared
2. Instance Variables –
Declared inside the body of a class but outside the body of all the methods, constructors or blocks of
that class
* Can be accessed only by using an object/instance created of the class (in a static method only)
* Each object will have its own copy of an instance variable, hence; there can be multiple values
* Changes made to an instance variable using one instance is not reflected in other instances as the
3. Static Variables –
Class Variables
Declared inside the body of a class but outside the body of all the methods, constructors or blocks of
that class
* Can be accessed by using the class name, an object or even directly without either of the two
* There can be only one copy of a static variable in a class, irrespective of number of objects in the
* Changes made to a static variable using one instance is reflected in other instances too as there
can be only one copy of a static variable per class (value is common to all instances)
Abstraction –
Process of representing only the essential components and hiding all other background details
Encapsulation –