OOP – What is static polymorphism?

  • The decision is made at compile time.
  • Which method is to be called is decided at compile-time only.
  • Method overloading is an example of this.
  • Compile time polymorphism is method overloading, where the compiler knows which overloaded method it is going to call.
  • Method overloading is a concept where a class can have more than one method with the same name and different parameters.
  • Compiler checks the type and number of parameters passed on to the method and decides which method to call at compile time and it will give an error if there are no methods that match the method signature of the method that is called at compile time.
Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *