Why do these two code samples produce different outputs?

后端 未结 5 987
离开以前
离开以前 2021-01-18 02:57

Sample 1:

 class Animal {
     public static void saySomething() { System.out.print(\" Gurrr!\"); 
   }
 }
 class Cow extends Animal {
    public static void         


        
5条回答
  •  失恋的感觉
    2021-01-18 03:18

    Some of the known Overriding "PITFALLS"

    • static methods cannot be overridden
    • private methods cannot be overridden

    This explains the output.

提交回复
热议问题