题目内容

下列哪个叙述是正确的?

A. 源文件可以有2条包语句(package)。
B. 源文件不可以有多条import语句。
C. 如果源文件有package语句,该语句也可以是源文件的第2条语句。
D. 类中的类方法(static方法)只能操作类变量(static变量),不可以操作实例变量。

查看答案
更多问题

挑错题:下列ABCD注释标注的哪行代码有错误?public class People {int m = 10,n; //An = 200; //Bvoid f(){if(m == n)n =+ m; //Celsen = n - m; //D}}

A
B
C
D

挑错题:下列ABCD注释标注的哪行代码有错误?class E {int x;public void f(int n) {int m; //Aint t = x+n; //Bint y = x+m; //Cm = 10;y = x+m; //D}}

A
B
C
D

挑错题:下列ABCD注释标注的哪行代码有错误?class Tom {int x;static int y;void showXY(){System.out.printf("%d,%d\n",x,y);}static void showY() {System.out.printf("%d\n",y);}}public class E {public static void main(String aqgs[]){Tom.y = 100; //ATom cat = new Tom();cat.x = 100;cat.y = 200; //BTom.x = 300; //Ccat.showXY();Tom.showY(); //D}}

A
B
C
D

阅读程序题(给出【代码】注释标注的代码的输出结果)class Fish {int weight = 1;}class Lake {Fish fish;void setFish(Fish s){fish = s;}void foodFish(int m) {fish.weight=fish.weight+m;}Fish getFish(){fish.weight -= 10;return fish;}}public class E {public static void main(String args[]) {Fish redFish = new Fish();Lake lake = new Lake();lake.setFish(redFish);lake.foodFish(120);int w = lake.fish.weight;Fish fishOK = lake.getFish();System.out.printf("%d:%d:%d",w,lake.fish.weight,fishOK.weight); //【代码】}}

答案查题题库