Polymorphism in Java
Polymorphism is a characteristic which permit one interface to be used for a common class of actions. The specific action is determined through the exact nature of the situation. Let consider a stack (that is a last-in, first-out list). You may have a program which needs three types of stacks. Single stack is used for integer values, single for floating-point values, and one for characters. The algorithm which implements each stack is the similar, even by the data being stored differs. Within a non-object-oriented language, you would be needed to create three different sets of stack routines, along with each set using various names. Moreover, because of polymorphism, within Java you could specify a common set of stack routines which all share the similar names.
More commonly, the concept of polymorphism is frequently expressed through the phrase "one interface, multiple methods." That means that it is probable to design a generic interface to a group of associated activities. This helps decrease complexity through permitting the similar interface to be used to specify a common class of action. That is the compiler's job to select the specific action (which is method) as it applies to every condition. You, the programmer, do not require to make this selection manually. You require only remember and utilize the common interface.
Extending the dog analogy, a dog's sense of smell is polymorphic. It will bark and run after it if the dog smells a cat. If the dog smells its food, it will salivate and run to its bowl. The similar sense if smell is at work in both conditions. The difference is what is being smelled, that is, the type of data being operated upon through the dog's nose! This similar common concept can be implemented within Java as it applies to methods inside a Java Program.