* IBM to offer mobile security as a service IBM will start delivering mobile security-as-a-service (MaaS) through its own cloud infrastructure in India, a move that is expected to better address in-country data requirements... IBM Spectrum Computing: IBM has enlarged its portfolio of software-defined infrastructure solutions with cognitive features for workload management.  * LiFi internet technology has been introduced, the new type of wireless internet connection that gives 100 times faster than traditional WiFi -- Invented by Professor Harald Haas from the University of Edinburgh. * Sci. Rachid Yazami has developed a smart chip that charges smartphones in less than 10 minutes. BenQ has launched BlueCore projector - Consumer electronics major BenQ has launched its first BlueCore laser light source projector. For those unaware, devices with BlueCore laser technology have a high contrast output of 80000:1 with an extended lamp life and efficiency. *** 
  Jan 3 2015 10:38PM     Mohammad Shaik
  0 Comments    1993 Views  
Here Mohammad Shaik provided a short tutorial with example, about Features of Object Oriented Programming (OOP) features.
Object Oriented Programming(OOP)
  1. Object oriented programming (OOP) is a programming model where programs are organized around object and data rather than action and logic.
  2. OOP allows decomposition of a problem into a number of entities called Object and then builds data and function around these objects.
  3. The program is divided into a number of small units called Object. The data and function are build around these objects.
  4. The data of the objects can be accessed only by the functions associated with that object.
  5. The functions of one object can access the functions of other object.
OOP has the following important features:
  • Class
  • Object
  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism
  • It can be compiled on a variety of computer platforms.
  • Part of .Net Framework.
In OOP languages, it is a must to create a class for representing data.
Class is a blueprint of an object that contains variables for storing data and functions to performing operations on these data.
Class will not occupy any memory space and hence it is only a logical representation of data.
To create a class, you simply use the keyword "class" followed by the class name:
Following is the list of few important features:

class Student


Objects are the basic run-time entities in an object oriented system. They may represent a person, a place or any item that the program has to handle.
"Object is a Software bundle of related variable and methods. "
“Object is an instance of a class.”
* Class will not occupy any memory space. Hence to work with the data represented by the class, you must create a variable for the class, which is called as an object.
* When an object is created by using the keyword new, then memory will be allocated for the class in heap memory area, which is called as an instance and its starting address will be stored in the object in stack memory area.
* When an object is created without the keyword new, then memory will not be allocated in heap, i.e., instance will not be created and object in the stack contains the value null.
* When an object contains null, then it is not possible to access the members of the class using that object.

class Student


Syntax to create an object of class Employee:

Student objStudent = new Student();

All the programming languages supporting object oriented programming will be supporting these three main concepts:
  1. Encapsulation
  2. Inheritance
  3. Polymorphism
Abstraction is "To represent the essential feature without representing the background details."
Abstraction lets you focus on what the object does instead of how it does it.
Abstraction provides you a generalized view of your classes or object by providing relevant information.
Abstraction is the process of hiding the working style of an object, and showing the information of an object in an understandable manner.
Suppose you have an object Mobile Phone.
Suppose you have 3 mobile phones as follows:
  • Nokia Lumia 530 (Features:- Calling, SMS)
  • Sony Xperia Z1 (Features:- Calling, SMS, FM Radio, MP3, Camera)
  • Black Berry (Features:-Calling, SMS, FM Radio, MP3, Camera, Video Recording, Reading E-mails)
Abstract information (Necessary and Common Information) for the object "Mobile Phone" is to make a call to any number and can send SMS." so that, for mobile phone object you will have an abstract class like the following:

    abstract class MobilePhone
        public void Calling();
        public void SendSMS();

    public class NokiaLumia : MobilePhone


    public class SonyXperiaZ1: MobilePhone
        public void FMRadio();
        public void MP3();
        public void Camera();

    public class BlackBerry : MobilePhone
        public void FMRadio();
        public void MP3();
        public void Camera();
        public void Recording();
        public void ReadAndSendEmails();

Abstraction means putting all the variables and methods in a class which is necessary.
For example: Abstract class and abstract method.
Abstraction is the common thing.
Wrapping up data member and method together into a single unit (i.e. Class) is called Encapsulation.
Encapsulation is like enclosing in a capsule. That is enclosing the related operations and data related to an object into that object.
Encapsulation is like your bag in which you can keep your pen, book, etc. It means this is the property of encapsulating members and functions.
class Bag

Encapsulation means hiding the internal details of an object, i.e., how an object does something.
Encapsulation prevents clients from seeing its inside view, where the behaviour of the abstraction is implemented.
Encapsulation is a technique used to protect the information in an object from the other object.
Hide the data for security such as making the variables as private, and expose the property to access the private data which would be public.
So, when you access the property, you can validate the data and set it.

class Demo
   private int _mark;

   public int Mark
     get { return _mark; }
     set { if (_mark > 0) _mark = valueelse _mark = 0; }

When a class acquire the property of another class, it is known as inheritance.
Inheritance is the process of object reusability.
For example: A child acquires the property of parents.

public class ParentClass
        public ParentClass()
            Console.WriteLine("Parent Constructor.");

        public void print()
            Console.WriteLine("I'm a Parent Class.");

    public class ChildClass : ParentClass
        public ChildClass()
            Console.WriteLine("Child Constructor.");

        public static void Main()
            ChildClass child = new ChildClass();


Parent Constructor.
Child Constructor.
I'm a Parent Class.
Polymorphism means one name many forms.
One function behaves in different forms.
In other words, "Many forms of a single object is called Polymorphism."
Real World Example of Polymorphism
Example 1:
A Teacher behaves with his student.
A Teacher behaves with his/her seniors.
Here teacher is an object but attitude is different in different situations.
Example 2:
Person behaves like a SON in the house, at the same time that person behaves like an EMPLOYEE in office.
Example 3:
Your mobile phone, one name but many forms:
  • As phone
  • As camera
  • As mp3 player
  • As radio
Difference between abstraction and encapsulation is as given in the table below:
Abstraction Encapsulation
1. Abstraction solves the problem in the design level. 1. Encapsulation solves the problem in the implementation level.
2. Abstraction is used for hiding the unwanted data and giving relevant data. 2. Encapsulation means hiding the code and data into a single unit to protect the data from outside world.
3. Abstraction lets you focus on what the object does instead of how it does it. 3. Encapsulation means hiding the internal details or mechanics of how an object does something.
4. Abstraction- Outer layout, used in terms of design.
For example: Outer Look of a Mobile Phone, like it has a display screen and keypad buttons to dial a number.
4. Encapsulation - Inner layout, used in terms of implementation.
For example: Inner Implementation detail of a Mobile Phone, how keypad button and Display Screen are connect with each other using circuits.
I hope this page will helps to learn features of Object Oriented Programming in C#. Thanks.

Recent Posts
Create Amazon ElasticCache Using Memcached in CSharp
Oct 29 2018 12:09PM Posted By Amose
Get Google Map Lat Lng (Geo Point) By Pincode in C#
Oct 28 2018 12:09PM Posted By Pranav
Google URL Shortener in C#
Oct 20 2018 12:09PM Posted By Sanjay
Bind Gridview from CSV file in Asp.Net C#
Oct 5 2018 12:09PM Posted By Michael
Call WebService method from jQuery in every 1 minute
Sep 26 2018 12:09PM Posted By John
Gridview custom CSS in ASP.Net
Sep 14 2018 12:09PM Posted By Micheal Ryan
Read excel file and bind to Gridview in C#
Sep 10 2018 12:09PM Posted By Micheal
Follow us on Facebook
Follow us on Google +
Recent post in your Email inbox.
Enter your email address: