Principles of OOPS

OOPS contains 8 principles. They are:

  1. Class
  2. Object
  3. Data Abstraction
  4. Data Encapsulation
  5. Inheritance
  6. Polymorphism
  7. Dynamic Binding
  8. Message Passing

1. Class: 

Class is a way of binding the Data Members and Methods in a single unit.

  • Syntax to define a User-defined Data type: Class

class<class-name>

{

            Variable / Data member declaration

            Method definition

}

e.g.: class Student

{

}

 

2. Object:

Real world entities are called objects.

  • Object creation:

Syntax:

                  <ClassName> objName = new <ClassName()>;

e.g.:     Student s = new Student ();

 

3. Data Abstraction:

It is a mechanism of retrieving the required/essential information by hiding background details.

 

4. Data encapsulation:

Data Encapsulation is a process of wrapping up of data in a single unit.

 

5. Inheritance:

It’s a process of acquiring the features (data members and member methods) of one class into another class.

TYPES OF INHERITANCE:

a) Single Inheritance: In this, There is exist one base class and one derived class.

b) Multilevel Inheritance:  In this, there exists one Base Class, one derived class and n # Intermediate Base Classes.

c) Multiple Inheritance: In this, there exists n # base classes and one derived class. Java doesn’t support multiple Inheritances to the classes directly but it supports indirectly through the Interface.

d) Hierarchical Inheritance:  In this, there exists one base class and n # derived class.

e) Hybrid Inheritance:  It is a combination of two valid Inheritances.

 

6. Polymorphism: 

It is a mechanism to represent one form in many forms.

  • We can have two types of Polymorphism:
    • Static or Compile Time Polymorphism.
    • Dynamic or Run Time Polymorphism.

7. Dynamic binding: 

Dynamic Binding is a way of binding the appropriate versions of derived classes which are inherited from same base class with Base class object.

8. Message Passing:

Message passing is a process of exchanging the data between multiple objects either locally or globally.

 

Leave a Reply