Browsing tag: polymorphism

High level Abstraction

Polymorphism in Java


“polymorphism” means ‘a state of having many shapes’ or ‘the capacity to take on different forms’.   In Java, Polymorphism is an ability to access objects of related classes through a single, uniform interface. Two types of polymorphism in Java,   Compile time polymorphism (static binding)   Run-time polymorphism (dynamic binding). Method overloading is an example

instanceof operation in java

instanceof – Know Object Type in Java


In Java, instanceof operator is used to check the type of an object at run-time.   instanceof operator is important in case of down-casting object at run-time. instanceof operator return boolean value, if an object reference is of specified type then it return true otherwise false. Simple rule is “instanceof” would return true for all the

Method overloading vs method overriding

Overloading and Overriding In Java


Method Overloading : Methods  have business logic that manipulates data(instances variable).   Methods would have method name, input arguments, return type and method body.   Sometimes we require to write two methods which are logically same but differ by input argument list.   Let us take class “Calculator”. public int add(int a, int b){ return a+ b; } public