What is Object Oriented Programing (OOP), Class and Object

Explanation of object oriented programing, oop paradigm and difference between class and object

Category: C# Tags: C#

Object Oriented Programing(OOP)

    A programing language where everything happen in form of object, like objects of classes and structures. Object Oriented programming deals with objects where we can create many objects of a class/structure. C# is not pure oop because there is a object class present which is base class of all the classes and all the types present in c# inherits from object class but object class can not be inherited from other classes(can not make object class a child of another class).

Class: A class can be seen as a derived data type that can have primitive data types or other derived data types or itself as a datatype. Class is nothing more then binding related members and their actions in a common container means class can be represented as a container.

Object: Object is a physical entity which occupy space in memory of computer and amount of memory allocated to an object depends on it's size. We can say integer may occupy 32 bits.

Difference between class and object: Class is not a physical entity but object is, class doesn't occupy any space in RAM memory until we create object of the class. You can understand it by blue print of a building, when architect gives blue print of a building it doesn't occupy space on field, the blue print describes properties of building which will be constructed based on structure given in blueprint. But when building is constructed it occupy space on field and that is same with class and object.

    For example the doctor class can have related attributes of a doctor like doctor name, age, experience etc

public class Doctor
   public string Name;
   public int Age;
   public int Experience;
public string GetDoctorName() { return Name; } }

And we can create object:

Doctor doctor = new Doctor();
doctor.Name = "Dr. XYZ";
doctor.Age = 30;
doctor.Experience = 2;
Console.WriteLine("Doctor name is: "+doctor.GetDoctorName());

    Also we can understand a class with a data table of a database where table name represents the class name, the attributes/columns of table represent the members of a class and a row of that table represents an object of a class.
        There are most four paradigm of OOP and can be seen as foundation of OOP, click on links below to read all.

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

Like 0 People
Last modified on 11 October 2018
Nikhil Joshi

Nikhil Joshi
Ceo & Founder at Dotnetlovers
Atricles: 126
Questions: 9
Given Best Solutions: 8 *


I prefer Java on C#, and I have done many classes in VBScript & JScript, surprisinlgy powerful OOP in VBScript. Maybe a day I'll learn VB .NET.... some day
Like 1 Person on 28 March 2014
Nikhil Joshi
haha... one day ... :P
Like 3 People on 28 March 2014

You are not loggedin, please login or signup to add comments:

Existing User

Login via:

New User