1. Encapsulation provide the object with the ability to hide their internal characteristic and behavior.
In java each object provides some methods, which can be access by another object and change its internal data.
In java there are four access modifier and each modifier impose the different access rights to other classes either in same package or in different package.
2. Abstraction refers to the act of representing essential features without include the background details or explanation
The abstraction technique used to separates the implementation details of the class from its behavior. It focuses on outside view of an object.
3. Inheritense provide the objects with ability to acquire the property of an other class, called parent class or base class.
Inheritense provides re-usability of code and can used to add additional features to an existing class without modifying it.
4. Polymorphism is the capability of an action or method to do different thing based on object that it is acting upon.
Means the ability of a single variable of a given type to be used to reference objects of different types, and automatically call the method that is specific to the type of object the variable references.
There are two type of polymorphism in java
1. Compile time polymorphism ( method overloading ).
2. Run-time polymorphism ( method overriding ).
1. Compile time polymorphism ( method overloading ).
2. Run-time polymorphism ( method overriding ).
- Method Overloading
Two or more method with same name but different argument in same class.
Two or more method with same name but different argument in same class.
-Method Overriding
Subclass declared the method that has the same argument as a method declared in super class.
Subclass declared the method that has the same argument as a method declared in super class.
Dynamic method dispatch -
In this process, Overridden method is called through reference variable of super class.
The determination of the method to be called is based on the object being referred by the reference variable.
In this process, Overridden method is called through reference variable of super class.
The determination of the method to be called is based on the object being referred by the reference variable.
Comments
Post a Comment