C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




A very good and simple article on OOPS concept


Posted Date: 24 Apr 2008    Resource Type: Articles    Category: .NET Framework

Posted By: HereToLearn.Net !!       Member Level: Gold
Rating:     Points: 10



2. OOP: Object oriented programming language is the language which deals with the objects and classes.
a. Properties or features of OOP:
i. Encapsulation: Encapsulation is wrapping of data into a single unit. In this the data is bound together inside a class which is hidden from outside world.

Eg: class X
{
Int i=5;
Int j;
}

ii. Inheritance: It is the process of creating a new class from the existing one. This new class is the child class which inherits all the characteristics of the parent class.

Eg: class X
{
public int a;
Public int b;
}
Class Y:X
{
Public int a;
Public int b;
}
Static void main()
{
Y o=new Y();
o.a=6;
}

iii. Polymorphism: This is a process in which methods with same name performs different tasks.
This can be implemented in three ways:
a) Overloading : In this different methods with same method name performs different tasks based on different type of parameters.

Eg: class X
{
Public int add(int a, int b)
{
Return a+b;
}
Public int add(int a, int b, int c)
{
Return a*b*c;
}
}
Static void main()
{
X o=new X();
Int i=o.add(2,3);------------o/p=5
Int j=o.add(4,5,6);----------o/p=120
}

b) Overriding: In this different methods with same signature performs differently in parent class and child class. Here the parent function in the child class is completely replaced by other function. When a class is overridden then we can declare an object of child class as parent type.

Eg: class X
{
Virtual Public void print()
{
Console.writeline("parent");
}
}
Class Y:X
{
Override public void print()
{
Console.writeline("child");
}
}
Static void main()
{
X o=new X();
o.print();---------------o/p=parent
Y x=new Y();
x.print();---------------o/p=child
X z=new Y();
z.print();----------------o/p=child
}

c) Method hiding(shadowing): Is a process where the parent function is hidden in the child class using the keyword "new".

Eg:
class X
{
Public void print()
{
Console.writeline("parent");
}
}
Class Y:X
{
New public void print()
{
Console.writeline("child");
}
}
Static void main()
{
X o=new X();
o.print();---------------o/p=parent
Y x=new Y();
x.print();---------------o/p=child
X z=new Y();
z.print();----------------o/p=parent
}






Responses

Author: http://venkattechnicalblog.blogspot.com/    26 Apr 2008Member Level: Diamond   Points : 0
Please format your contents.

Regards,
Venkatesan Prabu . J


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Difference between value type and reference type
Previous Resource: Multiple Inserts By Passing Data in XML Format
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

silicone halloween mask

Contact Us    Privacy Policy    Terms Of Use