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.
举一反三
- An instance member() A: is also called a static member B: is always a variable C: is never a method D: belongs to a single instance, not to the class as a whole E: always represents an operatio
- An instance member() A: is also called a static member B: is always a variable C: is never a method D: belongs to a single instance, not to the class as a whole E: always represents an operation
- 定义一个同包中的类可以访问的、无参、无返回值的静态方法method,以下哪个方法可以() A: voidmethod() B: public static method() C: protected static voidmethod() D: private static void method( )
- 在下列方法定义中,方法头不正确的是( )。 A: public int method( ){...} B: public static int method(double y){...} C: void method(double d){...} D: public static method(double a){...}
- 为A类的一个有一int形式参数a无返回值的方法method书写方法头,使得使用类名就可以调用它,该方法头的形式为( )。 A: static void method( ) B: public void method(int a ) C: static void method( int a) D: public static method(int a )
内容
- 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); } }