Polymorphism : Polymorphism refers to the ability of OOPs programming languages to differentiate between entities with the same name efficiently. This is done by Java with the help of the signature and declaration of these entities. For Example: // Java program to demonstrate Polymorphism // This class will contain // 3 methods with same name, // yet the program will // compile & run successfully public class Sum { // Overloaded sum(). // This sum takes two int parameters public int sum(int x, int y) { return (x + y); } // Overloaded sum(). // This sum takes three int parameters public int sum(int x, int y, int z) { return (x + y + z); } // Overloaded sum(). // This sum takes two double parameters public double sum(double x, double y) { return (x + y); } // Driver code public static void main(String args[]) { Sum s = new Sum(); System.out.println(s.sum(10, 20)); System.out.println(s.sum(10, 20, 30)); System.out....
The best way to learn Java programming is by practicing examples. The page contains examples on basic concepts of Java. You are advised to take the references from these examples and try them on your own.