Java Test Three

来源:互联网 发布:运营a淘宝需要多少钱 编辑:程序博客网 时间:2024/06/01 10:40

 

一、 是非题5题(每题3分)
1、 Java是一种计算机语言,更是一种计算机技术。 ( )
2、 Java支持多继承。 ( )
3、 接口是特殊的抽象类。 ( )
4、Java数据库连接用的是ODBC。 ( )
5、封装的原则是用公有的方法访问私有的数据 ( )
二、 填空题(每空2分)
6、Java可以跨平台的原因是( )
7、方法签名(或者特征)是指方法名和( )、( )、( )
8、Java事件处理包括建立事件源、( )和( )
9、JavaBeans的属性分为简单属性、( )、( )、( )。
10、Jsp指令的作用是( )
三、 程序题(每题5分,有单选和多选)
11、下面属于Java 关键字的是
A、 NULL B、IF C、do D、go to 
12. 哪一个输出-4.0
A、 System.out.println(Math.floor(-4.7));
B、 System.out.println(Math.round(-4.7));
C、 System.out.println(Math.ceil (-4.7));
D、 System.out.println(Math.min(-4.7));
13、下例正确的句子是
A)float 3.14;
B)byte i=225;
C)log k=33;
D)int p[][];

14、给出:
public class foo{
public static void main (String[]args){
String s;
System.out.println(“s=”+s);
}
}
what is the result?
A、The code compiles and “s=” is printed
B 、The code complies and “s=null” is printed
C 、The code does not compile because string s is not initialized
D 、The code does not compile because string s can not be referenced
E 、The code compiles, but a NullPointException is thrown when tostring is called

15、给出:
8.int index=1;
9.int []foo=new int[3];
10.int bar=foo[index];
11.int baz=bar+index;
What is the result?
A、baz has the value of 0
B、baz has the value of 1
C、baz has the value of 2
D、an exception is thrown
E、 the code will not compile

16.下例操作的结果是什么?
System.out prinln(4|3);
1)6
2)0
3)1
4)7

17、哪一个不能被增加到容器?
A、 a Panel
B、 an Applet
C、a Component
D、a top Container
E、a MenuItem

18、给出:
class Test {
int i;
String s;
public void method(){
int i=10;
system.out.println(i);
public Test(){
system.out.println(s);
}
}
What is the result?

19、public class ko3_6{
static{
System.out.println(“Hello”);
}
}

What is the result?
20、public class ko5_8{
public static void main(String args[]) {
int x=1,sum=0;
while(x<=10){
sum+=x;
x++;
}
System.out.println("sum="+sum);
}
}

What is the result?

21、 public class ko6_9
{
public static void main(String args[]) 
{
int sum=0;
int ko[][]={{1,2,3},{4,5,6},{7,8,9}};
for(int n=0;n<3;n++)
for(int m=0;m<3;m++)
sum+=ko[n][m];
System.out.println("sum="+sum);
}
}

What is the result?

22、public class ko8_1
{
public static void main(String args[])
{
try

int x[]=new int[-5];
System.out.println("此行将无法被执行!");
}
catch(NegativeArraySizeException e)
{
System.out.println("exception: " + e.getMessage());
}
}
}

What is the result?
23、 public class ko10_1 extends Thread

int n;
ko10_1()
{
Thread td=new Thread(this);
td.start();
}
public void run()
{
for (n=0;n<6;n++)
{
try
{
System.out.print(n);
Thread.sleep(500);
}
catch(InterruptedException e)
{
System.out.println("Exception");
}
}
}
public static void main(String args[])
{
new ko10_1();
}
}
What is the result?