当然可以。static 与 覆盖没有必然的联系。只是是否在new一个class时有区别

解决方案 »

  1.   

    静态方法是不能被覆盖的!
    在SUN的SL-275中明确写道:
    you CANNOT override a STATIC method but you can hide it!
      

  2.   

    pensincun(天高任彭翔)  看下面一段代码
    class Person { static String name,department; public static   void printValue(){System.out.println("name is "+name); System.out.println("department is "+department); } } 
    class teacher extends Person {
    static int salary; public static  void printValue(){ 
    System.out.println("salary is "+salary); 
    }
    public static void main(String args[]){
    teacher t=new teacher();
    t.printValue();
    }
    }printValue()算不算被覆盖?
      

  3.   

    这段代码中printValue()不是覆盖。
    静态方法不参与类对象而调用方法的覆盖机制。
    其在编译时就被打包,所以运行时调用那个方
    法由句柄类型决定,而不是由它包含的对象类
    型来确定。
      

  4.   

    为什么这段程序的输出结果是
    salary is 0
    而不是
    name is null
    department is null
    salary is 0 呢
      

  5.   

    静态方法能够被覆盖,只不过该类的所有实例在调用该方法时,引用同一个句柄,如果一个
    方法被声明为final,则成为最终方法,不能为覆盖了。
      

  6.   

    静态方法不能被override,只能被hide
      

  7.   

    //to:misslyy(礼拜二)下面的程序段才能输出你所想要的结果!
    class Person { static String name,department; public void printValue(){     //这里必须去掉static修饰符System.out.println("name is "+name); System.out.println("department is "+department); } } 
    class Teacher extends Person {
    static int salary; public void printValue(){     //这里也必须去掉static修饰符
    super.printValue();
    System.out.println("salary is "+salary); 
    }
    public static void main(String args[]){
    Teacher t=new Teacher();
    t.printValue();
    }
    }
    //实现了真正的方法覆盖!
      

  8.   

    //静态方法不可以覆盖
    class Person {  static String name,department;  public static  void printValue(){ System.out.println("name is "+name);  System.out.println("department is "+department);  } } 
    class teacher extends Person {
    static int salary;  public static  void printValue(){ 
    System.out.println("salary is "+salary); 
    }
    public static void main(String args[]){
    Person t=new teacher();//
    t.printValue();
    }
    }
    输出
    name is null
    department is null
      

  9.   

    静态方法不能override,能overload
      

  10.   

    不可以。出错信息如下:
    Error #: 455 : static method aMethod() in class DadClass cannot be overridden by method aMethod() in class SonClass at line 21, column 8
      

  11.   

    override 和 hide 有什么区别?
      

  12.   

    oveerride 是运行时动态绑定, static 方法是编译器绑定。A extends BA a = new A();
    B b = a;
    b.method();   
    // if override, here will invoke method in A, if method is static , B.method will be invoked.