Static methods and their overriding

前端 未结 5 1728
挽巷
挽巷 2020-12-03 06:36

Java doesn\'t allow overriding of static methods but,

class stat13
{
    static void show()
    {
        System.out.println(\"Static in base\");
    }
    p         


        
5条回答
  •  -上瘾入骨i
    2020-12-03 06:42

    Overriding happens at the object level. for ex obj1.overridedmenthod(). and there is no concept of overriding a class level method ie... static method ex : Class.overridedmethod().

    and this concept of overriding a static method is named as method hiding.

    try out a simple example .

提交回复
热议问题