一、选择题(每小题2分,共60分)
得 分 阅 卷 1.Java语言是1995年由( )公司发布的。 A. Sun
B. Microsoft C. Borland
D. Fox Software
2.下列声明和赋值语句错误的是( )
A. double w=3.1415; B. String strl=\C. float z=6.74567; D. boolean truth=true;
3. paint()方法使用哪种类型的参数? A. Graphics B. Graphics2D C. String
D. Color
4. 欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的?( )
A.ArrayList myList=new Object(); B.List myList=new ArrayList(); C. ArrayList myList=new List(); D. List myList=new List();
5. 指出下列程序运行的结果 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);
System.out.print(ex.str+\System.out.print(ex.ch);
}
public void change(String str,char ch[]){ } }
A.good and abc B.good and gbc C.test ok and abc
D.test ok and gbc
6. 运行下列程序, 会产生什么结果
str=\ch[0]='g';
1)public class X extends Thread implements Runable{ 2) public void run(){ 3) System.out.println(\4) }
5)
public static void main(String args[]){
6) Thread t=new Thread(new X()); 7) t.start();
8) } 9)}
A.第一行会产生编译错误 B.第六行会产生编译错误 C.第六行会产生运行错误
D.程序会运行和启动
7. 编译、运行下列Java代码后的结果是( )。 public class Test{
public static void main(String args []){ int age; age=age+1;
System.out.println(\
} }
A.编译成功,运行后没有输出
B.编译成功,运行后输出:The age is 1 C.编译成功,但运行时产生错误 D.编译失败
8. 下列程序片断的执行,说法正确的是( ) 1)public class Test{
2) public static void main(String args[]){ 3) byte b=100; 4) int i=b; 5) int a=2000; 6) b=a;
7) System.out.println(b); 8) }
9)}
A. b的值为100 B. b的值为2000 C. 第4行出错 D. 第6行出错
9. 已知i为整型变量,关于一元运算++i和i++,下列说法正确的是( ) A. 在任何情况下变量i的值都增1 B. 在任何情况下运行程序结果都一样 C. 在任何情况下运行程序结果都不一样 D. ++i运算将出错
10.下列方法method()执行,返回值为( ) int method(){
int num=10; if (num>20)
return num; num=0; } A. 10 B. 20 C. 30
D. 编译出错
11.下面程序定义了一个类,关于该类说法正确的是( ) abstract class abstractClass{ ? }
A. 该类能调用new abstractClass(),方法实例化为一个对象。 B. 该类不能被继承。
C. 该类的方法都不能被重载。 D. 以上说法都不对。
12.与Applet生命周期有关的主要方法是( ) A.init() B.start() C.stop() D.以上都是
13.使用”java MultiCatch”命令运行下列程序,说法正确的是( ) 1)public class MultiCatch{
2) public static void main(String args[]){ 3) try{
4) int a=args.length; 5) int b=42/a; 6) int c[]={1}; 7) c[42]=99;
8) System.out.println(\9) }
10) catch(ArithmeticException e){
11) System.out.println(\除0异常:\12) }
13) catch(ArrayIndexOutOfBoundsException e){
14) System.out.println(\数组超越边界异常:\15) } 16) } 17)}
A. 程序将输出第11行的异常信息 B. 程序第7行出错 C. 程序将输出\
D. 程序将输出第11和14行的异常信息
14.框架(Frame)的缺省布局管理器是( ) A.流程布局(FlowLayout) B.卡式布局(CardLayout) C.边界布局(BorderLayout) D.网格布局(GridLayout)
15.线程调用了sleep()方法后,该线程将进入( )状态。 A.可运行状态 B.运行状态 C.阻塞状态 D.死亡状态
16.JDBC中要显式地关闭数据库连接使用的方法是( ) A.Connection.close(); B.RecordSet.close();
C.Connection.stop(); D.Connection.release(); 17. 以下说法正确的是:( ) A.java.lang包被隐式包含到所有程序中。
B.Java的import关键字用来通知编译器当前正在编写一个数据输入类。 C.\表示使用一个java.awt包中名称为\的类。 D.java.net包中包含了java.awt包
18.下面对类的声明哪个是正确的?( ) A. public class Fred{
public int x = 0;
public Fred (int x){ this.x = x; } }
B. public class Fred {
public int x = 0; public fred (int x){ this.x = x;
} }
C)public class Fred extends MyBaseClass, MyOtherBaseClass { public int x = 0;
public Fred (int xval){ x = xval; }
}
D)protected class Fred{ private int x = 0; private Fred (int xval){ x = xval; } }
19. 下面程序中类ClassDemo中定义了一个静态变量sum,程序的输出结果是(class ClassDemo { public static int sum=1; public ClassDemo(){
sum=sum+5;
)。
}
}
class ClassDemoTest{ public static void main(String args[]) { ClassDemo demo1=new ClassDemo(); ClassDemo demo2=new ClassDemo();
System.out.println(demo1.sum);
}
} A. 0
B. 6
C. 11 20. 以下语句不能通过编译的是( )。 A. int[] a={1,2,3,4}; B. int b[];
C. int c[]=new int[3];
D. int d=new int[];
21. 阅读下面程序,程序的运行结果下面说法正确的是( class Super{
public int i=0;
public Super(String text){
i=1; } }
public class Sub extends Super{ public Sub(String text){
super(text); i=2; }
public static void main(String arg[]){
Sub sub=new Sub(\System.out.println(sub.i); }
}
A. 编译失败
B.编译成功并且程序输出0 C. 编译成功并且程序输出1 D.编译成功并且程序输出2
22. 在编译下列代码时,什么情况可能会发生?( public class MyClass{ public static void main(String arguments[]){ amethod(arguments); }
public void amethod(String[] arguments){ System.out.println(arguments);
System.out.println(arguments[1]); } }
A.出错,不能从静态上下文中引用非静态方法amethod()
D. 2
) )
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库Java理论试卷 (1)在线全文阅读。
相关推荐: