
Encapsulation
is the mechanism that binds together code and the data if manipulates,
and keeps both safe from outside interference and misuse. One way to
think about encapsulation is as a protective wrapper that prevents the
code and data from being arbitrarily accessed by other code defined
outside the wrapper. Access to the code and data inside the wrapper is
tightly controlled through a well-defined
interface. Conclusion: The wrapping up of data and methods into a single
unit (called class) is known as
encapsulation.

Inheritance is the process by which object of one class acquires the
properties of another class. Inheritance supports the concept of
hierarchical classification. For example, the atlas is a part of class
bicycle, which is again a part of the class cycle. As illustrated in the
principal behind this sort of division is that each derived class
shares common
characteristics with the class from which it is derived. In OOP, the
concept of inheritance provides the idea of reusability. This means that
we can add additional features to an existing class without modifying
it. This is possible deriving a new class from the existing one. The new
class will have the combined features of both the classes. Thus the
real appeal and power of the inheritance mechanism is that allows the
programmer to reuse a class that is almost, but not exactly, what he
wants, and to tailor the class is such a way that is does not introduce
any undesirable side effects into the rest of the class. The drive class
is knows as 'subclass'.

Polymorphism
is a feature that allows one interface to be used for a general class
of actions. The specific action is determined by the exact nature of the
solution. Polymorphism means the ability to take more than one form.
For example, consider the operation of addition. For two numbers, the
operation will generate the sum. If the operands are three numbers, then
the operation would produce the product of them. That a single function
name can be used to handle different number and different arguments.
This is something similar to a particular word having several different
meanings depending on the context. Polymorphism plays an important role
in allowing objects having different internal structures to share the
same external interface. This means that a general class of operations
may be accessed in the same manner even though specific actions
associated with each operation may differ. Polymorphism is extensively
used in implementing inheritance.
No comments:
Post a Comment