发布时间 : 星期六 文章java期末考试题更新完毕开始阅读a0ac9b05250c844769eae009581b6bd97e19bcf1
class Holder{
public int held;
public void bump(Holder theHolder){
theHolder.held - -;
}
}
7、阅读以下程序,请写出输出结果 。(true)
public class EqualsMethod {
public static void main(String[] args) {
Integer n1 = new Integer(47);
Integer n2 = new Integer(47);
}
}
1、Java application中的主类需包含main方法,main方法的返回类型是什么?(A、int B、float C、double D、void
2、有以下方法的定义,请选择该方法的返回类型( D )。
ReturnType method(byte x, double y)
D )
{
return (short)x/y*2; } A、byte
B、short
C、int
D、double
3、在编写Java Applet程序时,若需要对发生的事件作出响应和处理,一般需要在程序
的开头写上( D )语句。
A、import java.awt.* ; B、import java.applet.* ; C、import java.io.* ;
D、import java.awt.event.* ;
4、容器Panel和Applet缺省使用的布局编辑策略是( A )
A、BorderLayout B、FlowLayout C、GridLayout D、CardLayout 5、以下哪个不是Java的关键字?( A )
A、TRUE B、const C、super D、void
6、有程序如下,关于程序的描述哪个是正确的?( A )
public class Person{
i.static int a[] = new int[10];
ii.public static void main(String a[])
iii.arr[1]); }
}
A、编译将产生错误 B、编译时正确,但运行时将产生错误
C、正确,输出0 D、正确,输出?null
7、以下关于构造函数的描述错误的是( A )。
A、构造函数的返回类型只能是void型。
B、构造函数是类的一种特殊函数,它的方法名必须与类名相同。 C、构造函数的主要作用是完成对类的对象的初始化工作。 D、一般在创建新对象时,系统会自动调用构造函数。
8、有语句String s=”hello world”; ,以下操作哪个是不合法的?( )
A、int i=s.length(); String t=s+”!”;
B、s>>>=3; C、String ts=s.trim(); D、
9、有程序片段如下,以下哪个表示式的结果为true?( A )
Float s=new Float(0.1f); Float t=new Float(0.1f); Double u=new Double(0.1); A、s==t
B、s.equals(t) C、u.equals(s)
D、t.equals(u)
10、欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的 ?
(B)
A、ArrayList myList=new Object() B、List myList=new ArrayList() C、ArrayList myList=new List() D、List myList=new List();
11、paint()方法使用哪种类型的参数? (A)
A、Graphics B、Graphics2D C、String D、Color 12、指出正确的表达式 (C)
A、 byte=128; B、Boolean=null; C、 long l=0xfffL; D、 double=0.9239d; 13、指出下列程序运行的结果 (B)
public class Example{
String str=new String(\ char[]ch={'a','b','c'};
public static void main(String args[]){ Example ex=new Example(); ex.change(ex.str,ex.ch); }
public void change(String str,char ch[]){ str=\ ch[0]='g'; } }
A、 good and abc B、good and gbc C、 test ok and abc D、test ok and gbc 14、运行下列程序, 会产生什么结果 (A)
public class X extends Thread implements Runable{