ImageVerifierCode 换一换
格式:DOCX , 页数:73 ,大小:35.64KB ,
资源ID:30676938      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/30676938.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(java考试习题及答案.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

java考试习题及答案.docx

1、java考试习题及答案 Java 程序设计习题 及历年考试题单项选择题(80) 1. 接口中的成员变量被隐含地声明为 (A)public static final (B)public final (C)public static (D)public abstract 2. 处理按钮点击事件的类需要实现哪个接口 (A)FocusListener (B)ActionListener (C)WindowListener (D)ItemListener 3. 已知: class A public final void m() System.out.println(“A.m”); public clas

2、s B extends A public void m() System.out.println(“B.m”); super.m(); public static void main(String args) new B().m(); 那么结果为? (A)A.m (B)B.m (C)B.m A.m (D)编译错误 4. 抛出异常,使用关键字 (A)try (B)throw (C)finally (D)catch 5. 已知: class Base public Base(String s) System.out.print(“B”); public class Derived extends

3、Base public Derived (String s) System.out.print(“D”); public static void main(String args) new Derived (“C”); 那么结果为? (A)BD (B)DB (C)C (D)编译错误 6. Java 中char类型的数据长度为 (A)8位 (B)16位 (C)32位 (D)64位 7. Java 编译输出文件的后缀是 (A).exe (B).java (C).class (D).obj 8. 已知: class C public static void main(String args) boo

4、lean a = true; boolean b = false; boolean c = true; if(a & b) | (b & c) & c) System.out.print(“A”); If(a = false) | (a & c) ) | (a | b) System.out.print(“B”); (A)A (B)B (C)AB (D)编译错误 9. 下面哪个表达式是错误的 (A)int i = 100; (B)float f = 100.0; (C)Object o = “Hello world”; (D)char c = u1234; 10. 引用类型的数据字段的缺省值为

5、 (A)0.0 (B)0 (C)null (D)false 11. 下面哪个表达式可以获取字符串 s 的最后一个字符 (A)s.length() (B)ss.length() - 1 (C)s.charAt(s.length() - 1) (D)charAt(s, length(s) 12. 数据字段的作用域是 (A)所在的语句块 (B)所在的类 (C)所在的方法 (D)所在的构造函数 13. 如果类中的成员只能被子类或同一包中的类访问,那么声明该成员时应使用下面哪个修饰符 (A)private (B)package (C)protected (D)public 14. import语句的作用

6、是 (A)导入包中成员 (B)创建包 (C)既可导入包成员,也可创建包 (D)访问控制 15. 已知: class C public static void main(String args) int a = 1; int b = 2; System.out.print( “7” + 5 + 4); System.out.print(m() + a + 3); System.out.println(a + b + m(); public static String m() return “6”; (A) 79613126 (B) 79614336 (C) 75461336 (D) 754613

7、126 16. 接口中的成员方法被隐含地声明为 (A)public static final (B)protected abstact (C)private (D)public abstract 17. 关于包的描述错误的是 (A)包可以将相关的类和接口组织在一起,便于识别和管理 (B)包中的类可以访问同一包的其它类的私有成员 (C)不同包中的相同命名,不会产生冲突 (D)用public 修饰的顶级类和接口对包外代码可见 18. 下面代码的输出是 class C public static void main(String args) int x = 1; System.out.print(x

8、 1) & (x+ 1); System.out.print( “); System.out.print(x 1) & (x+ 1); (A)false true (B)true false (C)false false (D)true true 19. float f = new float10,则f0的值为 (A)0.0 (B)0.0f (C)null (D)false 20. 下面哪个类不能直接读取磁盘文件 (A)FileReader (B)RandomAccessFile (C)FilterReader (D)FileInputStream 21. 如果类中的成员只能被同一包中的类访问

9、,那么声明该成员时应使用下面哪个修饰符 (A)protected (B)package (C)public (D)不使用访问修饰符 22. 表达式new StringTokenizer( “Welcome to java”).countTokens()的值是 (A)1 (B)3 (C)13 (D)15 23. JPanel 的缺省布局管理器是 (A)BorderLayout (B)FlowLayout (C)GridLayout (D)SpringLayout 24. JFrame 的缺省布局管理器是 (A)BorderLayout (B)FlowLayout (C)GridLayout (D

10、)BoxLayout 25. 已知: public class C public int m(int x) int r = 1; r += x; if (x 5) & (x 10) r += 2 * x; else (x = 4) r += 3 * x; else r += 4 * x; r += 5 * x; return r; public static void main(String args) C o = new C(); System.out.println(“m(11) = “ + o.m(11); (A)m(11) = 45 (B)m(11) = 56 (C)m(11) = 8

11、9 (D)m(11) = 111 26. 已知: 目录结构 dira |-A.class |-dirb |-B.class 和源代码 import dira.*; class C A a; B b; 那么要使源代码通过编译,需要在源代码中添加 (A)package dira; (B)package dirb; (C)package dira.dirb; (D)package dirb.dira; 27. 如果 java.awt.Container c 的布局为BorderLayout,则 c.add(new Jbutton()的默认位置参数是 (A)BorderLayout.EAST (B)B

12、orderLayout.WEST (C)BorderLayout.CENTER (D)编译错误 28. 已知: class C public static void main(String args) String s = “welcome to java”; System.out.println(s.substring(11); 的输出为 (A)java (B)welcome to (C)ome to java (D)welcome to java 29. 已知: class C int i = 1; int j = 2; public void swap() int temp = i; i

13、 = j; j = temp; public static void main(String args) C c = new C(); c.swap(); System.out.println(c.i + “,” + c.j); 的输出为 (A)1,1 (B)1,2 (C)2,1 (D)2,2 30. 已知: class B int i; B(int i) this.i = i; class C extends B public static void main(String args) C c = new C(1); System.out.println(c.i); 的输出为 (A)0 (B

14、)1 (C)编译错误 (D)运行时错误 31. 已知: class C int x; String y; public C() this( “1”); System.out.print(“one “); public C(String y) this(1, “2”); System.out.print(“two “); public C(int x, String y) this.x = x; this.y = y; System.out.print(“three “); public static void main(String args) C c = new C(); System.ou

15、t.println(c.x + “ + c.y); 则输出为 (A)1 2 one two three (B)1 2 three two one (C)one two three 1 2 (D)three two one 1 2 32. 已知: class C public static void main(String args) int x = 5; C c = new C(); c.m(x); System.out.print(x); public void m(int x) System.out.print(x+); 则输出为 (A)55 (B)56 (C)65 (D)66 33. 已

16、知: interface I class A implements I class B extends A class C extends B public static void main(String args) B b = new B(); _ 在横线处添加哪条语句运行时会产生异常 (A)A a = b; (B)I i = b; (C)C c = (C)b; (D)B d = (B)(A)b; 34. 已知: class C public static void main(String args) String s = “null”; if(s = null) System.out.pr

17、int( “a”); else if(s.length() = 0) System.out.print( “b”); else System.out.print( “c”); 的输出为 (A)a (B)b (C)c (D)null 35. 已知: class C public static void main(String args) BufferedReader br = null; try br = new BufferedReader(new FileReader( “in.txt”); String temp = null; while(temp = br._) != null) Sy

18、stem.out.println(temp); catch(Exception e) finally if(br != null) br.close(); 要想打印出 in.txt 的全部内容,需要在横线处填写 (A)read() (B)next() (C)readLine() (D)nextLine() 36. 已知: class Student String code, name; int age; public boolean equals(Object o) if(!o instance of Student) return false; Student s = (Student)o;

19、 return o.code = code & o.age = age; public int hashCode() _ 横线处应填写 (A)return code.hashCode(); (B)return code.hashCode() + age * 11; (C)return code.hashCode() + name.hashCode() + age * 11; (D)return super.hashCode(); 37. 已知: class C public static void main(String args) parse( “number”); public stati

20、c void parse(String s) try int i = Integer.parseInt(s); catch(NumberFormatException e) i = 0; finally System.out.println(i); 则输出为 (A)0 (B)编译错误 (C)运行时抛出ParseException (D)运行时抛出NumberFormatException 38. 已知: public interface I void m(); 下面哪个定义是合法的 (A)public interface J extends I (B)public interface J im

21、plements I (C)public interface J inherits I (D)public interface J instanceof I 39. 已知: abstract class Shape private int x, y; void setLocation(int x, int y) this.x = x; this.y = y; abstract void draw(); class Circle extends Shape void draw() class Test public static void main(String args) _ 下面哪段代码在横

22、线处是合法的 (A)Shape s = new Shape(); s.setLocation(1,1); s.draw(); (B)Circle c = new Shape(); s.setLocation(1,1); s.draw(); (C)Shape s = new Circle() s.setLocation(1,1); s.draw(); (D)Shape s = new Circle() s.Shape.setLocation(1,1); s.Shape.draw(); 40. Java 的屏幕坐标系的(0,0)在屏幕的 (A)中心 (B)左上角 (C)左下角 (D)右下角 41.

23、 已知: class C public static void main(String args) int i = 10; System.out.println(i 8 ? 1.0 : 1); (A)1 (B)1.0 (C)8 (D)10 42. 已知: class C public static void main(String args) int i = 1; boolean b = false; if(b & +i = 2) System.out.print( “first “ + i); else System.out.print( “second “ + i); (A)first 1

24、 (B)first 2 (C)second 1 (D)second 2 43. 已知: class C public static void main(String args) String s = “Welcome to “; concat(s); System.out.print(s); public static void concat(String s) s += “Java”; 则输出为 (A)Welcome to (B)Welcome to Java (C)编译错误 (D)运行时异常 44. javax.swing.Timer将按一定频率产生什么事件 (A)ActionEvent

25、(B)TimerEvent (C)ItemEvent (D)InputEvent 45. 下面哪种布局方式只影响控件的高度,而不影响宽度 (A)BorderLayout 的WEST 和EAST (B)BorderLayout 的NORTH 和SOUTH (C)GridLayout (D)FlowLayout 46. 已知: class C public static void main(String args) try System.out.print(10 + 10 / 0); catch(NullPointerException e1) System.out.print( “a”); ca

26、tch(RuntimeException e2) System.out.print( “b”); finally System.out.print( “c”); (A)a (B)ac (C)bc (D)abc 47. 已知: class C public static String s = “c”; public static void main(String args) C c = new C(); B b = new B(); System.out.print(C.s); System.out.print(B.s); System.out.print(c.s); System.out.print(b.s); System.out.print(C)b).s); class B extends C public static String s = “b”; 则输出为 (A)ccccc (B)cbcbb (C)cbccc (D)cbcbc 48. 已知: publ

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1