An Introduction to the Programming World

OOP World:

Most of the organizations today rely on computer and information technology to connect to the world.As the Requirement increases, the software they execute becomes more complex. This increased complexity comes at a cost of large programs with huge code bases that is difficult to understand, maintain and keep bug-free.This tedious task can be accomplished by splitting it into smaller objects.Every thing is considered as object.This is the Principle behind OOP

In the OOP world, programming quickly became more about structure and frameworks than about solutions. OOP gives you the feeling of solving a puzzle, not just slinging code. Exploring something new is always a lot of fun.

The essence of object oriented programming is solving problems by identifying the real world objects of the problem and processing required of these objects and then creating simulations of these objects, processes , and the required communication s between objects.


Create a motor bike.instead of creating bike all together we split like

1. Wheels
2. Engine
3. Body

Wheel is considered as an as an independent ‘machine’ with a distinct role or responsibility.Similarly in the case of Engine and Body.Each of these can then be developed and tested independently before being combined.Engine supplies power to the wheels.All the objects are related.

It will have methods such as Steer(), Accelerate() and Brake(). also include properties such as Color, Number of Wheels.
Here methods are list of instructions that need to be performed.

Here the motorcycle is the Class(Blue print or Virtual one)

Motorcycle manufactured by different companies will be the Object(Existing one).

An object can be from integer to a complex file system.It will have characteristics given below.
1.Local Memory
2.Capability to communicate with other objects.This is accomplished through message passing.
3.Inherit processing Ability.
4.Possibility of inheriting methods and instance variables from ancestors.

Encapsulation is all about hiding and Ensuring security
Encapsulation conceals the functional details of a class from objects that send messages to it.
On applying Brakes,vehicle may stop.The driver need not know how the brake functions. ie,Hiding the data. For hiding the data we have Access Modifiers.

Access Modifiers:

Access Modifiers (Access Specifiers) Describes as the Scope of Accessibility on an Object and its Members.

The access modifiers in .NET are

1. public

2. private

3. protected

4. internal

5. protected internal

Public means visible to everyone and everywhere.

Who all can Access:

1. Objects of the class

2. Derived classes


Private means hidden and usable only by the class itself.

Who all can Access:

1. Cannot be accessed by object

2. Cannot be accessed by derived classes

Protected members are similar to private ones in that they are accessible only by the parent Class. However, protected members also may be used by a Derived class. So members that are likely to be needed by a descendant class should be marked protected.

Who all can Access:

1. Cannot be accessed by object.
2. By derived classes

Internal are public to the entire assembly but private to any outside assemblies. Internal is useful share certain functions with other assemblies

Who all can Access:

In same assembly (public).

1. By objects of the class

2. By derived classes

In other assembly (internal)

1. Cannot be accessed by object

2. Cannot be accessed by derived classes

Protected Internal:

Finally, we have the only compound access modifier allowed in .NET. Members marked as protected internal may be accessed only by a descendant class that’s contained in the same assembly as its base class. You use protected internal in situations where you want to deny access to parts of a class’ functionality to any descendant classes found in other applications.

Who all can Access:

In same assembly (protected).

1. Cannot be accessed by object

2. Can be accessed by a derived classes

In other assembly (internal)

1. Cannot be accessed by object

2. Cannot be accessed by derived classes


showing only the details which matter to the user.
Driver should know that on applying brakes he can stop the vehicle.

Abstract Modifier:

The Abstract Modifier can be used with classes, methods, properties, indexers, and events.

Pure Virtual Function:
Any virtual function set to zero is called as pure virtaul function.It means , it has no body and it cannot be called.It must be redefined in the sub class.

1.Provide interface of an function without revealing any of its implementation.
This is a new form of information hiding or encapsulation.

Abstract Class:

Any class that includes pure virtual function is an abstract class
An Abstract Class cannot be instantiated as an object and is only provided for the purpose of deriving,This is used only to represent concepts of a type.
Sub classes can have objects.

An Abstract Class may contain abstract methods and accessors.

Points to be noted:

* abstract method declaration provides no actual implementation, there is no method body; the method declaration simply ends with a semicolon and there are no braces ({ }) following the signature.

* abstract methods should be written inside abstract class

*When implementing abstract members in a derived class the override modifier must be used

Code snippet:

public abstract void Abstractmethod();

public abstract class ParentClass
    protected int x = 20;

    public abstract  void Abstractmethod();//AbstractMethod

public class ChildClass: ParentClass
	public override void Abstractmethod()
		int ichk= x++;

override keyword:

A pointer to an object of class A can also point to the objects of classes inherited from Class A..When the pointer points to an overloaded virtual function,the function of the current type is chosen dynamically

A virtual class is overridden by the derived class.
The implementation in the subclass overrides (replaces) the implementation in the super-class by providing a method that has same name, same parameters or signature, and same return type as the method in the parent class.


Method OverRiding

public class Class1
    public virtual void Display()


public class Class2 : Class1
      public override void Display()


  Class1 objClass1= new Class2();
    protected void Page_Load(object sender, EventArgs e)

In this case, Display Function in the Class1 is invoked.

If we give the override keyword in the Display Function of Class2

Then we will get a compiler Error Like this

On giving the keyword virtual in the class1
Display function in class2 works

This is how it works


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: