☕ Java
Beginner
What is polymorphism in Java?
Answer
Polymorphism means "many forms" — it allows one interface to be used for a general class of actions. In Java, there are two types. Compile-time polymorphism (method overloading): the correct method is chosen at compile time based on the argument types. Runtime polymorphism (method overriding): the correct method implementation is chosen at runtime based on the actual object type, not the reference type. Example: Animal a = new Dog(); a.sound(); — even though the reference type is Animal, Dog.sound() is called at runtime. This is enabled by dynamic method dispatch.