Ad Code

Responsive Advertisement

Features Of OOPs with REAL TIME EXAMPLES

Features of OOPS

 

FEATURES OF OOPS

1)What is Object?

  • Instance of the Class.
  • Object is the Real World Entity which consists of State and Behavior.
  • State - Characteristics (Data, attributes or properties).
  • Behavior – Functions (Procedure or method).

REAL TIME EXAMPLE:

    Let us take Mobile Phone as an Object.

       Mobile Phone's state and behavior as follows:

  • STATE - Mobile Brand, IP Address, Back cover, IMEI number.
  • BEHAVIOR - MMS, hearing songs, watching movies or videos, capturing images using camera.


2)What is Class?

  • Blueprint of the object.
  • Consists of Data member and member variable.
  • Data Member- Shows the state of object.
  • Member Function- Functions of object.

REAL TIME EXAMPLE:

       Mobile Phone's Data member and Member function as follows:

  • DATA MEMBER(State)- IP Address, Mobile Brand, IMEI number.
  • MEMBER FUNCTION(Behaviour)-Making a Call, hearing songs, watching videos Photo clicking.

EXAMPLE:

 class Mobile{

int IMEI = 863150304512345;

int IP = 192161516;

int mobile_num=""9876543210;

String Mobile_Brand = "Oppo";

void call(int from, int to)

{

Function body;

}

void songs(String song)

{

Function body;

}

 

}

  • Any change in data member affects the member function.


3)What is Inheritance?

  • Process of deriving properties or method from one class(Super Class) to another class(Sub Class).
  • Super class (Parent class) - the class from which the properties are derived.
  • Sub class (Child class) - the class where the properties are derived to.

REAL TIME EXAMPLE:

        FATHER-SON relationship.

       Superclass - Father.

       Subclass - Son.

       Method or Properties - Father's asset, Father's characteristics.

Types of Inheritance:

  1. Single Inheritance
  2. Multiple Inheritance
  3. Multilevel Inheritance
  4. Hierarchical Inheritance
  5. Hybrid Inheritance

 Read More: Inheritance And Types of Inheritance

 4)What is Polymorphism?

  • Poly - Many, Morph - Shapes
  • Process by which code, method or object behaves differently under different

Circumstances.

REAL TIME EXAMPLE:

        A person can play many roles in his\her life.

Lets take women as an example,

           She plays the role of

                 ★Daughter for her parents, 

                 ★Student in her school,  

                 ★Mother for her children etc..

Types of Polymorphisms:

  1. Compile Time Polymorphism
  2. Run Time Polymorphism


5)What is Encapsulation:

         Encapsulation can be defined by data hiding and Data binding.

DATA HIDING:

             Data hiding is the process of hiding unwanted information or details.

REAL TIME EXAMPLE:

             In Bluetooth sharing, A's private data cannot be accessed  by B's mobile except the files shared by  A to B.


DATA BINDING:

              Process of binding\wrapping  the data members and member functions together as a unit class.

REAL TIME EXAMPLE:

         Capsule which contains variety of medicines wrapped inside it.

   In simple words, Encapsulation can be defined as the Process of binding data members and member functions together to do a specific job without revealing unnecessary details or information.


6)What is Abstraction?

  • Method of hiding unnecessary details showing the necessary ones.
  • It shows the detail hiding the inner functionality or internal implementation.

REAL TIME EXAMPLE:

   Making a call from one phone to another in which we don't know the internal process of converting digital signals to analog signal or vice versa, we just dial the number and make a call.

Types of Abstraction:

  1. Data abstraction - Hides the detail about the data.
  2. Control Abstraction - Hides the implementation 

 

Post a Comment

0 Comments

Close Menu