Thursday, October 13, 2011

Key features of OOPs

Encapsulation (Data Hiding)

Encapsulation is process of keeping data and methods together inside objects.

- How to access the class members.

- Who can access the class members

Who can access:

Access Modifiers

Description

Public

No restrictions on accessing public members.

Private

members can be accessed within that class

Protected

members can be accessed within that class and its parent classes. (Private for other classes and public for inherited classes in any assembly)

Internal

members can be accessed within that assembly

internal protected

members can be accessed by that class and its parent class but within that assembly.

How can access:

Modifiers

Description

Const

value of the member cannot be modified

read only

Declare a field that can only be assigned values as part of the declaration or in a constructor in the same class.

Sealed

Specify that a class cannot be inherited.

Static

Access the members using class no need to create object to access that members

Override

Provide a new implementation of a virtual member inherited from a base class.

Virtual

Declare a method or an accessor whose implementation can be changed by an overriding member in a derived class.

Abstract

Can have implmentation of the methods in its child class

No comments:

Post a Comment