Tuesday, 23 August 2016

OOP, CLASS AND OBJECT

What is object oriented programming ?


Object oriented programming is a technique in which we focus on using objects for designing and building our application.
Keep in your mind

Oop is not a new language. It is not a new thing which make us confuse. oops is a technique in which we make are programming so much efficient. It make our development so much easy. we make classes and objects is programming.

What is Object and Class? 

Class is a template or blueprint which contain properties, members and method. Class define a particular structure of any thing.

Class myClass
{
          private int a; // class member variable
          private int b; // class member variable
       
          public int A{get; set; }//Property for variable a
          public int B{get; set; }//Property for variable b

         public void myFunction()        // Method of class
        {
                  // your code goes here
         }
}

Object is the instance of class.We initialise the object using new keyword.
myClass obj = new myClass();
Now methods and properties can be accessed from any where using this object. Now I have created this object I can access it
obj.myFunction() // function call
obj.A = 10; // Set a property using my object;
int val = obj.A // Get a property using my object.