下列代码在编译时会产生错误,下面哪种修改可以更正错误?( )class Test{private int m;public static void fun(){System.out.println(m);}}
A. 将private int m 改为protected int m
B. 将private int m 改为public int m
C. 将private int m 改为static int m
D. 将private int m 改为int m
以下代码的输出结果为( )public class Pass{static int j = 20;public void amethod(int x){x = x*2;j = j*2;}public static void main(String args[]){int i = 10;Pass p = new Pass();p.amethod(i);System.out.println(i+" and "+j);}}
A. 错误:方法参数与变量不匹配
B. 20 and 40
C. 10 and 40
D. 10 and 20
类A中构造方法的正确声明是( )
A. public A (int x) {...}
B. static A (int x) {...}
C. public a (int x) {...}
D. int A (int x) {...}
以下类定义中, 正确的构造方法是( )class Mc{int i;____________}
A. Mc (int k){i=k;}
B. mc (double k){i=k; }
C. void Mc (float m ){i=m }
D. Mc(long k) {i=k;}