Wednesday, March 30, 2011

OOPS

Class:
Class is concrete representation of an entity. It represents a group of objects, which posses similar attributes and behavior. Provides Abstraction and Encapsulations. A category name that can be given to group of objects of similar kind.


Object:
Object represents/resembles a Physical/real entity. An object is simply something you can give a name.


Object Oriented Programming:
is a Style of programming that represents a program as a system of objects and enables code-reuse.


Encapsulation:
Binding of attributes and behaviors. Hiding the implementation and exposing the functionality.


Abstraction:
Hiding the complexity. Defining communication interface for the functionality and hiding rest of the things.
In .Net destructor can not be abstract. Can define Either Finalize / Destructor. For Destructor access specifiers can not be assigned. It is Private.


Overloading:
Adding a new method with the same name in same/derived class but with different number/types of parameters. Implements Polymorphism.


Overriding:
When we need to provide different implementation than the provide by base class, We define the same method with same signatures in the derived class. Method must be Protected/Protected-Friend/Public for this purpose. (Base class routine can be called by Mybase.Method, base.Method)


Shadowing:
When the method is defined as Final/sealed in base class and not overridable and we need to provide different implementation for the same. We define method with Shadows/new.


Inheritance:
Gives you ability to provide is-a relationship. Acquires attributes and behaviors from another. When a class acquires attributes and behaviors from another class. (must not be Final or sealed class in .Net)


Abstract Class:
Instance can not be created. Optionally can have one or more abstract methods but not necessary. Can provide body to Classes.


Interface:
What a Class must do, But not how-to.
Bridge for the communication when the caller does not know to whom he is calling.
Describes externally visible behavior of element.
Only Public members which defines the means of the communication with the outer world. Can-be-Used-As Relationship.Can not contain data but can declare property. There can be no implementation. Interface can be derived from another interface.


Polymorphism:
Mean by more than one form. Ability to provide different implementation based on different no./type of parameters.
A method behaves differently based on the different input parameters. Does not depend on the Return-Type.


Pure-Polymorphism:
Make an method abstract/virtual in base class. Override it in Derived Class. Declare a variable of type base class and assign an object of derived class to it. Now call the virtual/abstract method. The actual method to be called is decided at runtime.


Early-Binding:
Calling an non-virtual method decides the method to call at compile time is known as Early-Binding.


Late-Binding:
Same as pure-polymorphism.


Identifiers/Access Specifies and scope:
Private, Protected, Friend, Protected Friend, Public
private, protected, internal, protected internal, public


What is a Delegate?
A strongly typed function pointer. A delegate object encapsulates a reference to a method. When actual function needs to be called will be decided at run-time.


Static Variable and Its Life-Time:
Public Shared VAR As Type Or public static Type VAR;
Life time is till the class is in memory.


Constructor:
Special Method Always called whenever an instance of the class is created.


Destructor/Finalize:
Called by GC just before object is being reclaimed by GC.

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete