79495080

Date: 2025-03-08 21:44:16
Score: 2.5
Natty:
Report link
public class Test {
    static class Parent {
        public <T> Object foo() { System.out.println("Parent"); return null; };
    }

    static class Child extends Parent {
        @Override
        public Object foo() { System.out.println("Child"); return null; };
    }

    public static void main(String[] args) {
        Parent p = new Child();
        p.foo(); // output: Child
    }
}

the above answer is great, just wanted to add a small addendum that technically, one can remove type parameters in the overriding method. i don't have enough reputation to comment so i'm writing here

Reasons:
  • Blacklisted phrase (1): to comment
  • RegEx Blacklisted phrase (1.5): i don't have enough reputation to comment
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Chien Hao Tan