10年JAVA模拟试题A_第1页
10年JAVA模拟试题A_第2页
10年JAVA模拟试题A_第3页
10年JAVA模拟试题A_第4页
10年JAVA模拟试题A_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、10年JAVA模拟试题A一、单项选择题( 分)135每小题1分,3650每小题2分,共651. Java虚拟机(JVM )在运行JAVA代码时,不会进行的操作是A )加载代码B)校验代码C)编译代码 D )执行代码2. JAVA程序的并发机制是A) 多线程 B)多接口C)多平台D)多态性3. 在方法内部使用,代表对当前对象自身引用的关键字是A) super B)ThisD)SuperD)this4. 对鼠标点击按钮操作进行事件处理的接口是A) MouseListenerB) WindowsListenerC) ActionListenerD) KeyListener5. AWT中用来表示颜色的

2、类是A) FontB) Color6. Java中属于跳转语句的是A) tryB) catch7. 下面说法哪个是正确的()A ) Applet可以访问本地文件C) socket类在 javaang 中C)PanelD)DialogC) finallyD ) breakB)对static方法的调用需要类实例D ) 127.0.0.1地址代表本机&下列哪个方法可用于创建一个可运行的类 ()A ) public class X implements Runable public void run()B ) public class X implements Thread public void r

3、un()C) public class X implements Thread public int run()D ) public class X implements Runable protected void run()9. Java编程所必须的默认引用包为()D)以上都不是A ) java.sys包B) javaang 包C) java.new 包10. Java Applet源程序文件的扩展名为()。A ) .javaB) .class C) .html D) .exe11. 设a = 3,则表达式(-a)a的值是()。A ) 16B ) 8C ) 24D) 1212. 在Java

4、 Applet程序用户自定义的Applet子类中,一般需要重载父类的()方法来完成主类实例的初始化工作。A ) start( )B) stop( ) C) init( ) D) paint()13. 创建一个标识有“关闭”按钮的语句是()。A ) TextField b = new TextField( “关闭”);B ) Label b = new Label( “关闭”);C) Checkbox b = new Checkbox关闭”);D) Button b = new Button( “关闭”);14. 在编写异常处理的Java程序中,每个catch语句块都应该与()语句块对应,使得用

5、该语句块来启动 Java的异常处理机制。A) ifelse B) switch C) tryD) throw15. 在Java中,属于整数类型变量的是()A) single B) double C) byte D) char16. Applet类的直接父类是()A) Component类B) Container 类 C) Frame 类D) Panel 类仃.Frame的默认的布局管理器是下列哪一个()A ) FlowLayout B) BorderLayout C) GridLayout D ) CardLayout18.在下列事件处理机制中哪个不是机制中的角色()A)事件 B)事件源 C)

6、事件接口D事件处理者佃.下列语句片段int a=10,b=4,c=20,d=6;System.out.println(a+*b+c*-d);的结果为()A ) 144D)不能执行20. 下列语句片段:int a=-67,b=116,c=78;int d=a | b&c;B ) 281000011 011110011111001001100C) 14011101001001110System.out.println(d)的结果为()A) 70B) 6721. Java中访问限定符不包括()A ) public B) privateC) 78D ) 56D) final22. 如果希望所有的控件在

7、界面上均匀排列,应使用下列那种布局管理器?A)BoxLayout B)GridLayout C)BorderLayout D)FlowLouLayout23.A )C)24.JAVA程序经常用到 递归” 让别人反复调用自己” 自己反复调用自己”Which is Java keyword?A ) mathB ) staticC)C) default递归”的基本思想是()B)自己反复调用别人” D)以上说法都不对FALSE D ) TRUE25. What is the range of a char?3131A ) -32 768 32 767B ) -128 127 C) -2 2 -1D)

8、u0000 uFFFF26. Java变量中,以下不属于复合类型的数据类型是()A)类B)字符型 C)数组型 D)接口27. 当方法遇到异常又不知如何处理时,下列哪种说法是正确的()A)捕获异常B)抛出异常C)声明异常D)嵌套异常28. 在Java中,不属于整数类型变量的是()A ) doubleB) longC) intD) byte29. 在异常处理中,如释放资源、关闭文件、关闭数据库等由()来完成。A ) try 子句B ) catch子句 C) finally 子句D ) throw子句30. Which of the following are valid declarations?

9、A) char c= B) char c= cafeC) char c= 0xfgD) char c=xef31. Which of the following is true of anonymous innerclass?A) Anonymous inner class can be declared as private,protected or public.B) Anonymous inner class can implement multiple interfaces.C) if not extended or implemented, an anonymous innercla

10、ss can become immediate subclass of the outer class or implement an interface.D) if not extended or implemented, an anonymous inner class can become immediate subclass of outer class or implement mutiple interfaces.32. Which statement is true about an inner class?A) It must be anonymousB) It can t i

11、mplement an interfaceC) It is only accessible in the enclosing classD) It can access any final variables in any enclosing scope.33. Which is the main() method return of a application?A) String B) byte C) char D) void34. Which is corrected argument of main() method of application?A) String args B) St

12、ring args C) Char args D) StringBuffer args35. Given the following declarationString s = Example;Which are legal code?A ) s = 3;B) s3 = x;C) int i = s.length; D) String t =For + s;36. What is written to the standard output given the following statement: System.out.println(4&7);100Select the right an

13、swer: 111A ) 4 B ) 5C) 6 D) 737. What is written to the standard output given the following statement: System.out.println(7|9);Select the right answer:A ) 0 B ) 7C) 9 D) 1538. Consider the following code: Integer s = new Integer(9); Integer t = new Integer(9); Long u = new Long(9);Which test would r

14、eturn true?A) (s.equals(new Integer(9)B ) (s.equals(9)C) (s=u)D) (s=t)39. What should you use to position a Button within an application frame so that the width of the Button is affected by the Frame size but the height is not affected.A) FlowLayoutB)GridLayoutC) Center area of a BorderLayoutD) Nort

15、h or South of aBorderLayout40. If this source code is contained in a file called SmallProg.java, what command should be used to compile it using the JDK?public class SmallProg public static void main(String args) System.out.println(Good luck!); A) java SmallProgB)javac SmallProgC) java SmallProg.jav

16、aD) javacSmallProg.java41. Which statement about listener is true?A) Most component unallow multiple listeners to be added.B ) If multiple listener be add to a single component, the event only affected one listener.C) Component don t allow multiple listeners to be add.D) The listener mechanism allow

17、s you to call an addXxxxListener method as many times as is needed, specifying as many different listeners as your design require.42. What will be the result when you run the following code?class Aclassvoid go()System.out.println(Aclass);public class Bclass extends Aclassvoid goSystem.out.println(Bc

18、lass);public static void main(String args)Aclass a=new Aclass();Aclass a1=new Bclass();a.go();a1.go();The output is:A ) AclassB ) BclassC) AclassD) BclassAclassBclassBclassAclass43. 已知有下列类的说明,则下列哪个语句是正确的?public class Test private float f = 1.0f;int m = 12;static int n=1;public static void main(Strin

19、g arg)Test t = new Test();A) t.f ;B) this.n ; C ) Test.m ; D) Test.f ;44. 给定下面的代码片段:1) String str = null;2) if (str != null) & (strength() 10) 3) System.out.println(more than 10);4) 5) else if (str != null) & (str.length() 5) 6) System.out.println(less than 5);7) 8) else System.out.println(end); 哪一行

20、会导致错误?A)line 1B) line 2C)line 5D)line 845. 对于下列代码:public class Parent public int addValue( int a, int b) int s;s = a+b; return s;class Child extends Parent 下述哪个方法可以加入Child类中实现多态?A) int addValue( int a, int b )/ do something.B) public void addValue (int a, int b )/ do something.C) public int addValue

21、( int a )/ do something.D) public int addValue( int a, int b ) /do something.46. 下列语句序列执行后,k的值是()。int i=10, j=18, k=30;switch( j - i )case 8 : k+;case 9 : k+=2;case 10: k+=3;default : k/=j;A) 31B) 32C) 2D) 3347. Given the following class definition:class Aprotected int i;A(int i)this.i=i;which of th

22、e following would be a valid inner class for this class?A) class B B) class B extends A C) class B extends AD) class BB()System.out.println(“ i= ” + i); class A 48. Give the following java class:public class Examplestatic int x=new int15;public static void main(String args)System.out.println(x5);Whi

23、ch statement is corrected?A) When compile, some error will occur. B ) When run, some error will occur.C) Output is zero.D) Output is null.49. What will be the result of attempting to compile and run the following code? abstract class MineBaseabstract void amethod();static int i;public class Mine ext

24、ends MineBasepublic static void main(String args)int ar = new int5;for(i=0; iar.length; i+)System.out.println(ari);A ) a sequence of 5 0 s will be printedB ) Error: ar is used beforeit is initializedC) Error Mine must be declared abstract D ) IndexOutOfBoundes Error50. class Line public static class

25、 Point class Triangle II insert code hereWhich code, inserted at line 15, creates an instance of the Point class defined in Line?A. Point p = new Point();B. Line.Point p = new Line.Point();C. The Point class cannot be instatiated at line 15.D. Line 1 = new Line() ; 1.Point p = new 1.Point();二、写出下列程序

26、完成的功能(每小题5分,共20分)1、public class Sumpublic static void main( String args )int sum = 0 ;for ( int i = 1 ; i = 100 ; i + + )sum += i ;System.out.println(“ sum= +sum );2、import java.io.* ;public class Reversepublic static void main(String args )int i , n =10 ;int a = new int10;for ( i = 0 ; i = 0 ; i-)S

27、ystem.out.print(ai+);System.out.println();3、import java.awt.*;public class AppOutpublic static void main(String args)new FrameOut();class FrameOut extends FrameLabel prompt;FrameOut()super(西南交通大学); prompt=new Label(西南交通大学欢迎您); setLayout(new FlowLayout(); add(prompt);setSize(300,200); show();4、import

28、 java.io.*;public class abcpublic static void main(String args) SubClass sb = new SubClass();System.out.println(sb.max();class SuperClass int a = 10 , b = 20 ; class SubClass extends SuperClass int max( ) return (ab)?a:b); 三、写出下面程序的运行结果(每小题5分,共15分)1、import java.io.*;public class abcpublic static voi

29、d main(String args) String s1 = Hello!;String s2 = new String(I am fine!); System.out.println(s1+ +s2); 2、import java.io.* ;public class abcpublic static void main(String args) int i , s = 0 ;int a = 1,2,3,4,5,6,7,8,9,10 ;for ( i = 0 ; i a.length ; i + )if ( ai%2 = 0 ) s += ai; System.out.println(s=

30、+s);3、Give following programe:class EXpublic static void main(String args)outer: for(int i=0; i3; i+ ) inner: for(int j=0; j=1) break outer;System.out.println(j + and + i); What will be output?第二、三题参考答案:二、 写出下列类完成的功能。(每小题5分,共20分 )1、求1至100之间的整数的和,并在屏幕上显示岀来。2、从标准输入(即键盘)读入10个整数存入整型数组 a中,然后逆序输岀这10个整数。3、

31、创建一个标题为“西南交通大学”的窗框,窗框中显示有“西南交通大学欢迎您”字样的标签。4、求两个数的最大值。三、写出下面程序的运行结果 (每小题5分,共15分)1、Hello! I am fine!2、s=303、0 and 0When you are old and grey and full of sleep,And no ddi ng by the fire, take down this book,And slowly read, and dream of the soft lookYour eyes had once, and of their shadows deep;How many loved your mome nts of glad grace,And loved your beauty with love false or true,But one man loved the pilgrim soul in you.And loved the sorrows of your cha nging face;And bending dow n beside the glow ing bars,Murmur, a little sad

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论