java题库—175道选择题

上传人:第*** 文档编号:34040804 上传时间:2018-02-20 格式:DOC 页数:24 大小:132.50KB
返回 下载 相关 举报
java题库—175道选择题_第1页
第1页 / 共24页
java题库—175道选择题_第2页
第2页 / 共24页
java题库—175道选择题_第3页
第3页 / 共24页
java题库—175道选择题_第4页
第4页 / 共24页
java题库—175道选择题_第5页
第5页 / 共24页
点击查看更多>>
资源描述

《java题库—175道选择题》由会员分享,可在线阅读,更多相关《java题库—175道选择题(24页珍藏版)》请在金锄头文库上搜索。

1、5-1Java 程序设计理论题库选择题(单选 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; /byte 取

2、值到 127B、 Boolean=null; C、 long l=0xfffL; D、 double=0.9239d; 4.指出下列程序运行的结果 Bpublic class Example String str=new String(good); charch=a,b,c; public static void main(String args) Example ex=new Example(); ex.change(ex.str,ex.ch); System.out.print(ex.str+ and ); Sytem.out.print(ex.ch); public void chang

3、e(String str,char ch) str=test ok; ch0=g; A、 good and abc B、 good and gbc C、test ok and abc D、 test ok and gbc 5.运行下列程序, 会产生什么结果 C Dpublic class X extends Thread implements Runable public void run() System.out.println(this is run(); public static void main(String args) Thread t=new Thread(new X(); 5

4、-2t.start(); A、 第一行会产生编译错误 B、 第六行会产生编译错误 C、 第六行会产生运行错误 D、 程序会运行和启动 6.要从文件 file.dat文件中读出第 10个字节到变量 C中,下列哪个方法适合? AA、 FileInputStream 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=n

5、ew FileInputStream(file.dat); int c=in.read(); D、 RandomAccessFile in=new RandomAccessFile(file.dat); in.skip(9); int c=in.readByte(); 7.容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小的变化而改变? BA、 CardLayout B、 FlowLayout C、 BorderLayout D、 GridLayout 8.给出下面代码: public class Person static int arr = new int10;public

6、 static void main(String a) System.out.println(arr1); 那个语句是正确的? CA、 编译时将产生错误; B、 编译时正确,运行时将产生错误; C 、输出零; D、 输出空。 9.哪个关键字可以对对象加互斥锁? BA、 transient B synchronized C serialize D static 10.下列哪些语句关于内存回收的说明是正确的? BA、 程序员必须创建一个线程来释放内存; B、 内存回收程序负责释放无用内存 C、内存回收程序允许程序员直接释放内存 D、内存回收程序可以在指定的时间释放内存对象 11.下列代码哪几行会出

7、错: C1) public void modify() 2) int I, j, k; 3) I = 100; 5-34) while ( I 0 ) 5) j = I * 2; 6) System.out.println ( The value of j is + j ); 7) k = k + 1; 8) I-; 9) 10 A、 line 4 B、 line 6 C、 line 7 D、 line 812.MAX_LENGTH是 int型 public成员变量, 变量值保持为常量 100,用简短语句定义这个变量。 DA、 public int MAX_LENGTH=100; B、 fin

8、al int MAX_LENGTH=100; C、 final public int MAX_LENGTH=100; D、 public final int MAX_LENGTH=100. 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 stat

9、ic void main(String arg) 10 Parent p = new Parent(); 11 12 那些行将引起错误? DA、 第 3行 B、 第 6行 C、 第 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、 表达式是错误的; 5-4

10、D、 编译时正确,但运行时错误。 15.给出下面代码段 1) public class Test 2) int m, n; 3) public Test() 4) public Test(int a) m=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.对于下列代码:

11、1) class Person 2) public void printValue(int i, int j) /. 3) public void printValue(int i)/. 4) 5) public 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) 第

12、10行语句将调用哪行语句?? DA、 line 2 B、 line 3 C、 line 6 D、 line 717.哪个关键字可以抛出异常? CA、 transient B、 finally C、 throw D、 static 18.Main()方法的返回类型是: BA、 int B、 void 5-5C、 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, i

13、nt b) int s; s = a+b; return s; class Child extends Parent 下述哪些方法可以加入类 Child? CA、 int addValue( int a, int 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.

14、21.给出下面代码: public class test static int a = new a10; public static void main(String args) System.out.println(a10); 那个选项是正确的? AA、 编译时将产生错误; B、 编译时正确,运行时将产生错误; C、 输出零; D、 输出空。 22.下面哪些选项是正确的 main方法说明? BA、 public main(String args) B、 public static void main(String args) C、 private static void main(Strin

15、g args) D、 void main() 23.给定下面的代码片段: C1) String str = null; 2) if (str != null) & (str.length() 10) 3) System.out.println(more than 10); 4) 5-65) else if (str != null) & (str.length() 2)5 D、 (23) 40. 下面哪个是对字符串 String的正确定义 ( A )A、String s1=null; B、String s2=null ;C、String s3=(String) abc ; D、String s4=(String) uface;41. 下面哪条语句不能定义一个 float型的变量( B )A、float f1= -343 ; B、float f2=3.14 ;C、float f3=0x12345 ; D、float f4=2.8F ; 42. 下面哪条语句定义了 5个元素的数组( A )A、int a=22,23,24,25,12;B、int a =new in

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号