-->

22 December 2019

C# Oop's Concept

  Asp.Net CS By Example       22 December 2019

MSV

  OOPs (Object Oriented Programming Language ):
     It is used to decompose a problem into a number of entities called objects and then builds data and functions around these entities.
=> Object oriented programming is technique where we can define the object.
=> It divided the program into an object.
=> It follows the bottom up approach
=> Data is hidden and can not be accessed by external function.
=> New data and function can be easily added whenever necessary.

Opps follows the some concepts.
1) classes
2) Objects
3) Data Abstraction
4) Data Encapsulation
5) Inheritance
6) Polymorphism


1) Objects:
  • It is basic run time entities.
  • It is also a instance of class.
  • With object we can access the member function & data member of class


  • 2) classes
  • Class is the template for object. It is the logical unit.
  • A class contains the different data types of data member and member function in single unit.
  • 3 access specifier are used in the class.

    3) Data Abstraction
  • Data Abstraction means showing essential feature and hiding non - essential feature from user.
  • For Eg. Yahoo Mail... When you provide the user name and password and click on submit button..It will show Compose,Inbox,Outbox,Sentmails...so and so when you click on compose it will open...but user doesn't know what are the actions performed internally....It just Opens....that is essential; User doesn't know internal actions ...that is non-essential things...
  • For Eg. Tv Remote.. Remote is a interface between user and tv..right. which has buttons like 0 to 10 ,on /of etc but we dont know circuits inside remote...User does not need to know..Just he is using essential thing that is remote.

    4) Data Encapsulation
  • Encapsulation means which binds the data and methods in single unit (class).
  • For Example: A car is having multiple parts..like steering,wheels,engine...etc..which binds together to form a single object that is car. So, Here multiple parts of cars encapsulates itself together to form a single object that is Car. In real time we are using Encapsulation for security purpose... Encapsulation = Abstraction + Data Hiding.

    5) Inheritance
  • Inheritance is process by which object of one class acquire the propertices of object of another class.
  • For Eg.
                                                            
    class Address 
    { 
    	String name; 
    	Srting House_no; 
    	String Street_name; 
    } 
    
    class LatestAddress extends Address 
    { 
    	String City; 
    	String State; 
    	String Country; 
    } 
    
    public class EmpAddress 
    { 
    	public static void Main()
    	{ 
    		LatestAddress la = new LatestAddress(); 
    															
    	} 
    }
                                                            
  • In the above Example class LatestAddress getting all features from the Address class. In the LatestAddress class we have total 6 properties..3 are inherited from Address class and 3 properties are incorporated. So In the class Vishal we are declaring the object of class LatestAddress and then assign new variables using the properties of the previous base classes... So this is a nice example of inheritance..

    6) Polymorphism
  • Polymorphism means ability to take more than one form that an operation can exhibit different behavior at different instance depend upon the data passed in the operation.
  • For Eg. 1>We behave differently in front of elders, and friends. A single person is behaving differently at different time. 2> Consider the stadium of common wealth games. Single stadium but it perform multiple task like swimming, lawn tennis etc.
  • logoblog

    Thanks for reading C# Oop's Concept

    Previous
    « Prev Post

    No comments:

    Post a Comment

    Please do not enter any spam link in the comment box.