java考试练习题

发布时间 : 星期日 文章java考试练习题更新完毕开始阅读

B、int[][] arr = new int[3][]

C、int[][] arr = new int[][4]

D、int[][] arr = {{1,2},{3,4,5},{6}}

20、下列关于注释的使用,错误的是?()

A、int c = 10; //定义变量c

B、/* int c = 5; int x =6; */

C、/** 这是类的入口方法*/

D、/* /*int c = 10;*/ int x=5; */

21、下列关于静态方法的描述中,错误的是()。

A、静态方法属于类的共享成员

B、静态方法是通过\类名.方法名\的方式来调用

C、静态方法只能被类调用,不能被对象调用

D、静态方法中可以访问静态变量

22、阅读下列的程序

class Person{

static{

System.out.println(name);

}

private static String name = \

}

class Demo{

public static void main(String[] args){

Person p = null;

}

}

下列关于程序运行结果的描述中,正确的是()

A、无结果输出

B、输出null

C、输出hello

D、编译失败

23、请阅读下面的程序片段

int x = 1, y = 1;

if (x++ == 2 & ++y == 2) {

x = 7;

}

System.out.println(\程序的运行结果是() A、x=1,y=1 B、x=7,y=1 C、x=7,y=2 D、x=2,y=2 24、下列程序运行结果是() public class Demo { public static void main(String[] args) { Object obj=new Father(){ public void show(){ System.out.println(\} }; obj.show(); }

}

class Father{

public void show(){

System.out.println(\

}

}

A、hello father

B、helloworld

C、无结果

D、程序编译报错

25、100属于下列哪种类型的常量()

A、布尔类型

B、字符类型

C、整数类型

D、浮点类型

26、下列关于浮点型数据的定义,哪一个不能通过编译()

A、double a=12.45;

联系合同范文客服:xxxxx#qq.com(#替换为@)