Oops Concepts

Oops concepts with Real-world examples


OOPS:

          Object-oriented programming is a programming paradiagm based on the concept of "Objects", which can contain data, in the form of fileds, and code, in the form of procedures.
       

Oops Concepts:

  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism          

Abstraction:

     Data Abstraction is the property by virtue of which only the essential details are displayed to the user.The trivial or the non-essentials units are not displayed to the user.
Eg: 
  • A car is viewed as a car rather than its individual components.
  • Another Example is when you use the remote control of your TV, you do not  bother about how pressing a key in the remote changes the channel on the TV. You just know that pressing the + volume button will increase the volume.

Encapsulation:

    Encapsulation is Information Hiding. Encapsulation is also one way of hiding implementation. For Eg: 
  • Car is an abstraction _ you don't know internal working of the car but within car there are subsystems  like steering, brake, clutch etc which are encapsulated.
  • Another Example Capsule - inside capsule all the medicines are encapsulated together inside the capsule. 


Inheritance:

      Inheritance is a mechanism in which one class acquires the property of another class.That means where derived class inherits the properties of pre-existing(base) class.Where Child class is known as the Derived class and Parent class is known as the Base class.
  • Reusability of the code

    Polymorphism:

          Polymorphism refer's to the programming languages ability to process objects differently depending on their data types or class.In other words polymorphism as the ability of a message to be displayed in more than one form.
    Eg: A person at the same time can have different characteristics. Like a man at the same time is a father, a husband, an employee. So the same person posses different behaviour in different situations. This is called polymorphism. Polymorphism is mainly divided into two types,
    • Compile time Polymorphism
    • Run time Polymorphism


         

    Comments

    Popular Posts