1、Java题库 道选择题 Java程序设计理论题库选择题(单选175题)1.欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的 ? BA、 ArrayList myList=new Object(); B、 List myList=new ArrayList(); C、 ArrayList myList=new List(); D、 List myList=new List();2.paint()方法使用哪种类型的参数? AA、 Graphics B、 Graphics2D C、 String D、 Color3.指出正确的表达式 DA、 byte=128; /b
2、yte取值到127B、 Boolean=null; C、 long l=0xfffL; D、 double=0.9239d; 4.指出下列程序运行的结果 Bpublic clA、 good and abc B、 good and gbc C、test ok and abc D、 test ok and gbc 5.运行下列程序, 会产生什么结果 C Dpublic clA、 第一行会产生编译错误 B、 第六行会产生编译错误 C、 第六行会产生运行错误 D、 程序会运行和启动 6.要从文件 file.dat文件中读出第10个字节到变量C中,下列哪个方法适合? AA、 FileInputStrea
3、m in=new FileInputStream(file.dat); in.skip(9); int c=in.read(); B、 FileInputStream in=new FileInputStream(file.dat); in.skip(10); int c=in.read(); C、 FileInputStream in=new FileInputStream(file.dat); int c=in.read(); D、 RandomAccessFile in=new RandomAccessFile(file.dat); in.skip(9); int c=in.readBy
4、te(); 7.容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小的变化而改变? BA、 CardLayout B、 FlowLayout C、 BorderLayout D、 GridLayout 8.给出下面代码: public cl 那个语句是正确的? CA、 编译时将产生错误; B、 编译时正确,运行时将产生错误; C 、输出零; D、 输出空。 9.哪个关键字可以对对象加互斥锁? BA、 transient B synchronized C serialize D static 10.下列哪些语句关于内存回收的说明是正确的? BA、 程序员必须创建一个线程来释放内存;
5、 B、 内存回收程序负责释放无用内存 C、内存回收程序允许程序员直接释放内存 D、内存回收程序可以在指定的时间释放内存对象 11.下列代码哪几行会出错: CA、 line 4 B、 line 6 C、 line 7 D、 line 812.MAX_LENGTH是int型public成员变量, 变量值保持为常量100,用简短语句定义这个变量。 DA、 public int MAX_LENGTH=100; B、 final int MAX_LENGTH=100; C、 final public int MAX_LENGTH=100; D、 public final int MAX_LENGTH=1
6、00. 13.给出下面代码:1) class Parent 2 private String name; 3 public Parent() 4 5) public class Child extends Parent 6 private String department; 7 public Child() 8 public String getValue() return name; 9 public static void main(String arg) 10 Parent p = new Parent(); 11 12 那些行将引起错误? DA、 第3行 B、 第6行 C、 第7行
7、D、 第8行14.类Teacher和Student是类Person的子类; Person p; Teacher t; Student s; /p, t and s are all non-null. if(t instanceof Person) s = (Student)t; 最后一句语句的结果是: B CA、 将构造一个Student对象; B、 表达式是合法的; C、 表达式是错误的; D、 编译时正确,但运行时错误。 15.给出下面代码段 1) public class Test 2) int m, n; 3) public Test() 4) public Test(int a) m
8、=a; 5) public static void main(String arg) 6) Test t1,t2; 7) int j,k; 8) j=0; k=0; 9) t1=new Test(); 10) t2=new Test(j,k); 11) 12) 哪行将引起一个编译时错误? DA、 line 3 B、 line 5 C、 line 6 D、 line 10 16.对于下列代码: 1) class Person 2) public void printValue(int i, int j) /. 3) public void printValue(int i)/. 4) 5) pu
9、blic class Teacher extends Person 6) public void printValue() /. 7) public void printValue(int i) /. 8) public static void main(String args) 9) Person t = new Teacher(); 10) t.printValue(10); 11) 第10行语句将调用哪行语句?? DA、 line 2 B、 line 3 C、 line 6 D、 line 717.哪个关键字可以抛出异常? CA、 transient B、 finally C、 thro
10、w D、 static 18.Main()方法的返回类型是: BA、 int B、 void C、 boolean D、 static 19.System类在哪个包中? DA、 java.util B、 java.io C、 java.awt D、 java.lang20.对于下列代码: public class Parent public int addValue( int a, int b) int s; s = a+b; return s; class Child extends Parent 下述哪些方法可以加入类Child? CA、 int addValue( int a, int
11、b )/ do something. B、 public void addValue (int a, int b )/ do something. C、 public int addValue( int a )/ do something. D、 public int addValue( int a, int b )throws MyException /do something. 21.给出下面代码: public clAA、 编译时将产生错误; B、 编译时正确,运行时将产生错误; C、 输出零; D、 输出空。 22.下面哪些选项是正确的main方法说明? BA、 public main
12、(String args) B、 public static void main(String args) C、 private static void main(String args) D、 void main() 23.给定下面的代码片段: CA、 line 1 B、 line 2 C、 line 5 D、 line 8 24.下面哪种注释方法能够支持javadoc命令: B DA、 /*.*/ B、 /*.*/ C、 / D、 /*.*/ 25.欲编写如下图的一个界面,用于显示用户指定的图像: 如果在区域A中只能放置一个AWT组件,从各组件的本来功能角度考虑,最好使用哪种组件:DA、
13、TextArea B、 Panel C、 Applet D、 Canvas 26.界面如上题所示。若Button1的功能是:点击后弹出一个用于输入的界面,获取用户想要显示的图像文件名,则该界面最好是(从编程简单和程序不易出错的角度考虑): cA、 模式(Modal)Dialog B、 非模式(None-modal)Dialog C、 FileDialog D、 Frame BA、 构造方法 B、 paint(Graphics g) C、 update(Graphics g) D、 repaint() 28.下面关于Applet的说法正确的是 BA、 Applet也需要main方法 C、 App
14、let能访问本地文件 D、 Applet程序不需要编译 29.看下面一段程序: class Aclclass); public class Bclass extends Aclclass); public static void main(String args) Aclass a=new Aclass(); Aclass a1=new Bclass(); a.go(); a1.go(); 以上程序运行结果是: B CA、 Aclass Aclass B、 Bclass Bclass C、 Aclass Bclass D、 Bclass Aclass 30.下列关于Java线程的说法那些是正确的() DA、 每一个Java线程可以看成由代
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1