Lakhyadeep Sen’s Post

Polymorphism is another important concept in object oriented programming. The word polymorphism comes from two words - poly meaning many, and morph meaning forms. In programming it refers to the ability of a method to behave differently depending on how it is used. One common form of polymorphism in Java is method overloading. Things that became clear : • method overloading happens when multiple methods share the same name • the methods must differ in their parameter list • Java decides which method to execute based on the arguments passed • this is known as compile-time polymorphism • it allows the same operation to work with different types or number of inputs A simple example shows how this works : class Calculator { void add(int a, int b) { System.out.println(a + b); } void add(int a, int b, int c) { System.out.println(a + b + c); } } Both methods have the same name but different parameters, so Java treats them as separate methods. This approach helps make programs more flexible while keeping method names consistent. #java #oop #programming #learning #dsajourney

To view or add a comment, sign in

Explore content categories