题目内容

下列代码编译或运行的结果是:public class Cell{public String getCellInfo(int x, int y){return x+","+y;}public String getCellInfo(int[] vals){return "vals";}public static void main(String[] args){Cell c=new Cell();System.out.println(c.getCellInfo(4, 5));}}

A. public String getCellInfo(int[]vals){行,编译出错
B. System.out.println(c.getCellInfo(4,5));行,抛出运行时异常
C. 输出:4,5
D. 输出:vals

查看答案
更多问题

关于下列代码说法正确的是:public class Cell{public void drop(){}public String drop(){return "下落一行";}public double drop(int x){return "下落x行";}}

A. 无编译错误
B. 代码public String drop(){行,出现编译错误
C. 代码public double drop(int x){行,出现编译错误
D. 代码return "下落一行";行处出现编译错误

有一个类Cell,以下为其构造方法的声明,其中正确的是:

A. public Cell(int x){…}
B. static Cell(int x){…}
C. public cell(int x){…}
D. void Cell(int x){...}

如果有类Cell,请说出下列代码中,创建对象个数:publicclassCellGame{publicstaticvoidmain(String[]args){Cellc1=newCell();c1=newCell();Cellc2=newCell();}}

A. 1
B. 2
C. 3
D. 4

如果有类Cell,请说出下列代码中,创建对象个数:public class CellGame{public static void main(String[] args){Cell cell = null;for(int i=0;i<20;i++){cell = new Cell();}}}

A. 10
B. 20
C. 15
D. 25

答案查题题库