Use this space to put some text. Update this text in HTML

468x60 banner ad

Advertise with Us

Powered by Blogger.

Thursday 11 February 2016

What is Object Oriented Programming Concept in asp.net?


There are four features of Object Oriented Programming:-

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

Abstraction 
To reduce and remove the complexity of programming language we use abstraction.
Each real world entity has behavior and functionality. Behavior should be hidden and functionality should be exposing. 

Example-


1.      Do you know the inner details of the Monitor of your PC? What happen when you switch ON Monitor? Does this matter to you what is happening inside the Monitor? No Right, Important thing for you is weather Monitor is ON or NOT. 


2.      When you change the gear of your vehicle are you really concern about the inner details of your vehicle engine? No but what matter to you is that Gear must get changed that’s it.



Encapsulation


1. We can combine both behavior and functionality both together with the wrapper of class. This means that a class which has data member as well as method is called encapsulation. 
      2. Dividing each of its classes into two distinct parts: the interface and the implementation.
      3. Class is the best example of encapsulation.

 By using the get and set methods (Accessors and Mutators) 



    public class Account

    {


        private string accoutName;
        // get methods

        public string GetAccount()
        {
            return accoutName;
        }

        // Set method

        public void SetAccount(string name)
        {
            accoutName = name;
        }
    }

    static void Main()
    {
        string name = "SAVING_ACCOUNT";
        Account account = new Account();

        account.SetAccount(name);

        name = string.Empty;

        name = account.GetAccount();
    }

 
 

No comments :

Post a Comment

Ask a Question?