☕ Java
Beginner
What is method overriding in Java?
Answer
Method overriding is when a subclass provides its own implementation of a method already defined in its superclass, with the same method signature (name, parameter types, and return type). The overriding method is selected at runtime based on the actual object type — this is runtime (dynamic) polymorphism. The @Override annotation is not mandatory but strongly recommended as it causes a compile error if the method does not actually override anything. Rules: you cannot override static, final, or private methods. The overriding method cannot have a more restrictive access modifier.