Object and Class in python

Previous
Next

Object Oriented Programming features are:

  1. Encapsulation
  2. Inheritance
  3. Polymorphism
  4. Abstraction

Note the followings:

  • These features neither belong to Python nor to any other programming language.
  • OOP features are Global.
  • Any programming language can implement the functionality of OOP.
  • The 2 concepts used in OOP implementation are
    • Object
    • Class

Object: A real world entity consists

  1. Identity : Used to access the object uniquely.
  2. Variables : Stores information of object.
  3. Methods : To process the data of object.

class:

  • “class” is a keyword.
  • “class” is the complete representation of object.
  • Without class, we cannot define object in object oriented programming.
  • Class is also called Plan or Model or Blue print of object.
  • Based on single model(class), we can define any number of objects(similar type).

Procedure oriented programming:

  • C is procedure oriented programming language.
  • We define programs in procedure oriented programming.
  • One program can access the information of another program directly.
  • The following diagram explains the communication in C application.

Object oriented programming:

  • C++, Java, Python and many languages are object oriented.
  • We define objects in object oriented application.
  • Object information is secured.
  • One object(program) cannot access the information of another object directly.
  • We classify the object information(data) using access modifiers concept.
  • The following diagram explains the communication between 2 objects.

The way of writing program:

  • In procedure oriented approach, we define the program elements directly such as variables and functions.
  • In object oriented approach, every element must belong to class.
  • Class represents object.
  • We separate the information of each object using class.
Previous
Next

Add Comment

Courses Enquiry Form