Polymorphism Explanaion needed

Hi everyone

I am relatively new to Java OOP. Tomorrow I have a test about specifically polymorphism and overloading. Since I missed a bunch of classes I don’t exactly know what that means and where it’s usable.

I hope anyone can save me :slight_smile:

When applied to object-oriented programming languages like Java, it describes a language’s ability to process objects of various types and classes through a single, uniform interface.

That should explain polymorphism. As for overloading… Java methods may be overloaded in the same class. For example, you can have 2 different greeting methods, each with different parameters:

public static void greeting(){

public static void greeting(String name){
  System.out.println("Hello, "+name+"!");

Each of these methods holds the same name, but either a different parameter list. Therefore, either can be called (with the same name), to generate a different result:

public static void main(String[]args){
  greeting(); //Prints: Hello!
  greeting("Brin"); //Prints: Hello,Brin!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.