• 2022-05-29
    Which of the following is false? ( )
    A: A static method must be used to access private static instance variables.
    B: A static method can be accessed even when no objects of its class have been instantiated.
    C: A static method has no this reference.
    D: A static method can call instance methods directly.
  • D

    内容

    • 0

      请说出下列程序错在哪里?给出具体原因。 public class Test { public static void method(int x) { } public static int method(int y) { return y; } }

    • 1

      ‏下面( )代码正确的声明了一个类方法(静态方法)。‍ A: public int method(int i) B: protected method(int i) C: public static method(String s) D: protected static void method(Integer i)

    • 2

      abstract的method可以同时是static。

    • 3

      Which one of the following statements is right? A: If a local variable has static storage duration, its lifetime will be extended. B: If a global variable has static storage duration, its scope will be expanded. C: A variable will have an unpredictable value before initialization; no matter it has static storage duration or automatic storage duration. D: The storage type descriptors which formal parameter can use are exactly the same as that used by the local variables.

    • 4

      public class test { public static void main(String args[]) { int m=0; for ( int k=0;k<2;k++) method(m++); System.out.println(m); } public static void method(int m) { System.out.print(m); } }