[go: up one dir, main page]

0% found this document useful (0 votes)
11 views3 pages

Class As The Basis of All Computation

Uploaded by

hejekdbdghsnwnb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Class As The Basis of All Computation

Uploaded by

hejekdbdghsnwnb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

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

Object can be both physical or logical entity

But class is always a logical entity

Characteristics of an object –

Identity – that differentiates one object from the other

State – data or attributes that define the current characteristics of an object

Behaviour – functions, actions or operations that an object can perform

An object stores its state in member variables of the class and exposes its behaviour through the

member methods of the class.

The concept of data hiding states that the information obtained should be hidden from the rest of

the system

* any changes made to one object has no effect on the other

* it makes the system more reliable and data secure

Encapsulation provides-

* Data Hiding * Easy trouble shooting

* Reliability

* Reusability
All variables declared inside a class are called member variables or data members of that class

1. Local Variables –

Declared inside the body of a method of a class

Can be accessed only within the method in which they are declared

2. Instance Variables –

Declared without using the keyword ‘static’

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)

(can be accessed directly in a non-static method)

* 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

values are specific to each instance

3. Static Variables –

Class Variables

Declared using the keyword ‘static’

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

class (though, specific to methods)

* 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)

Instantiation – process of creating objects of a class is called instantiation

Abstraction –

Process of representing only the essential components and hiding all other background details

Reduces the complexity of program and improves the security of a program

Encapsulation –

Process of binding up data and associated functions into a single unit

Provides data hiding and prevents unauthorized access to data items

You might also like