What is polymorphism in Java?
Why Interviewers Ask This
This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex Java topics. It also reveals how well you can explain technical ideas to non-experts.
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.
Pro Tip
Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Java codebase.