第一章 单元测试

1、单选题:
编译和运行以下代码的结果为: public class MyMain{ public static void main(String argv){ System.out.println("Hello cruel world"); }}
选项:
A:编译错误
B:编译无错,但运行时指示找不到main方法
C:运行输出 'Hello cruel world'
D:编译无错,但运行时指示没有定义构造方法
答案: 【编译无错,但运行时指示找不到main方法

2、单选题:
以下哪个是Java应用程序入口的main方法头?
选项:
A:public static int main(char args[])
B:public static void main(String a[])
C:public static void MAIN(String args[])
D:public static void main(String argv)
答案: 【public static void main(String a[])

3、单选题:
编译Java源程序文件将产生相应的字节码文件,字节码文件的扩展名为?
选项:
A:java
B:html
C:class
D:exe
答案: 【class

4、多选题:
main方法是JavaApplication程序执行的入口点,关于main方法的方法头合法的有?
选项:
A:public static void main()
B:public static void main(String[ ] args)
C:public static int main(String[ ] arg)
D:public static void main(String arg[ ])
答案: 【public static void main(String[ ] args);
public static void main(String arg[ ])

5、判断题:
每个源程序文件中只能定义一个类。
选项:
A:错
B:对
答案: 【

第二章 单元测试

1、单选题:
在Java中,十进制数16的十六进制表示格式是?
选项:
A:0xA
B:0x10
C:0x16
D:016
答案: 【0x10

2、单选题:
要产生[10,100]之间的随机整数使用哪个表达式?
选项:
A:(int)(Math.random()*100)
B:10+(int)(Math.random()*91)
C:10+(int)Math.random()*91
D:10+(int)Math.random()*90
答案: 【10+(int)(Math.random()*91)

3、单选题:
下列符号中不能作为Java标识符的是?
选项:
A:45six
B:_pore
C:$str1
D:abc
答案: 【45six

4、单选题:
下面各项中定义变量及赋值不正确的是?
选项:
A:char c = 65;
B:float f = 45.0;
C:double d = 45.0;
D:int i = 32;
答案: 【float f = 45.0;

5、单选题:
执行以下代码段后,x,a,和b的值为?intx,a=6,b=7;x=a+++b++;
选项:
A:x= 13, a=7, b=8
B:x= 15, a=6, b=7
C:x= 15, a=7, b=8
D:x= 13, a=6, b=7
答案: 【x= 13, a=7, b=8

6、单选题:
下列哪个不是Java的保留字?
选项:
A:cin
B:extends
C:float
D:class
答案: 【cin

7、多选题:
哪些赋值是合法的?
选项:
A:float f = -412;
B:long test = 012;
C:double d = 0x12345678;
D:int other = (int)true;
答案: 【float f = -412;;
long test = 012; ;
double d = 0x12345678;

8、多选题:
下列代码中,将引入编译错误的行是1 public class Exercise{2 public static void main(String args[]){3 float f = 0.0 ;4 f = f + 1.0 ;5 }6 }
选项:
A:第6行
B:第2行
C:第3行
D:第4行
答案: 【第3行;
第4行

9、多选题:
下列哪些是合法标识符?
选项:
A:TwoUsers
B:*point
C:$persons
D:this
答案: 【TwoUsers;
$persons

10、多选题:
下列哪些是java中有效的整数表示形式?
选项:
A:22
B:22H
C:022
D:0x22
答案: 【22;
022;
0x22

发表评论

电子邮件地址不会被公开。 必填项已用*标注