




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
10年JAVA模拟试题A一、单项选择题(135每小题1分,3650每小题2分,共65分)1. Java虚拟机(JVM)在运行JAVA代码时,不会进行的操作是A)加载代码 B)校验代码 C)编译代码 D)执行代码2. JAVA程序的并发机制是A)多线程 B)多接口 C)多平台 D)多态性3. 在方法内部使用,代表对当前对象自身引用的关键字是A)super B)This D)Super D)this4. 对鼠标点击按钮操作进行事件处理的接口是A)MouseListener B)WindowsListener C)ActionListener D)KeyListener5. AWT中用来表示颜色的类是A)Font B)Color C)Panel D)Dialog6. Java中属于跳转语句的是A)try B)catch C)finally D)break7. 下面说法哪个是正确的( ) A)Applet可以访问本地文件 B)对static方法的调用需要类实例 C)socket类在java.lang中D)127.0.0.1地址代表本机8. 下列哪个方法可用于创建一个可运行的类( ) A)public class X implements Runable public void run(). B)public class X implements Thread public void run(). C)public class X implements Thread public int run(). D)public class X implements Runable protected void run().9. Java编程所必须的默认引用包为( ) A)java.sys包 B)java.lang包 C)java.new包 D)以上都不是 10. Java Applet源程序文件的扩展名为( )。A).java B).class C).html D).exe11. 设a = 3,则表达式(-a) = 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 answer: 111A)4B)5C)6D)7 37. What is written to the standard output given the following statement:System.out.println(7|9);Select the right answer:A)0B)7C)9D)1538. Consider the following code:Integer s = new Integer(9);Integer t = new Integer(9);Long u = new Long(9);Which test would return 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)FlowLayout B)GridLayoutC)Center area of a BorderLayout D)North or South of a BorderLayout40. 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 SmallProg B)javac SmallProgC)java SmallProg.java D)javac SmallProg.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 dont allow multiple listeners to be add.D)The listener mechanism allows 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(Bclass);public static void main(String args)Aclass a=new Aclass();Aclass a1=new Bclass();a.go();a1.go();The output is: A)Aclass B)Bclass C)Aclass D)BclassAclass Bclass Bclass Aclass43. 已知有下列类的说明,则下列哪个语句是正确的?public class Test private float f = 1.0f;int m = 12;static int n=1;public static void main(String 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) & (str.length() 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); 哪一行会导致错误? A)line 1 B)line 2 C)line 5 D)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( 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)31 B)32 C)2 D)3347. Given the following class definition:class Aprotected int i;A(int i)this.i=i;which of the following would be a valid inner class for this class?A)class B B)class B extends A C)class B extends A D)class B B()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);Which 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 MineBase abstract void amethod(); static int i;public class Mine extends MineBase public static void main(String args) int ar = new int5; for(i=0; iar.length; i+) System.out.println(ari); A)a sequence of 5 0s will be printed B)Error: ar is used before it is initializedC)Error Mine must be declared abstract D)IndexOutOfBoundes Error50. class Line public static class Point class Triangle / 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();二、写出下列程序完成的功能(每小题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- ) System.out.print(ai+ ); System.out.println( ); 3、import java.awt.*;public class AppOut public static void main(String args) new FrameOut(); class FrameOut extends Frame Label prompt; FrameOut() super(西南交通大学); prompt=new Label(西南交通大学欢迎您); setLayout(new FlowLayout(); add(prompt); setSize(300,200); show( ); 4、import java.io.*;public class abc public 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 abc public static void main(String args) String s1 = Hello!; String s2 = new String(I a
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 20xx年装修施工合同2篇
- 雕塑设计与制作公司员工保密合同
- 安全方面培训目的课件
- 电梯工程分包方案模板(3篇)
- 球磨机系统安全培训课件
- 安全文明施工培训
- 环保水处理岗位知识培训课件
- 防洪工程安全方案(3篇)
- 地下防水的工程方案(3篇)
- 初中语文古诗词教学策略分析
- 2025-2026学年人教版PEP英语二年级上册教学计划(三篇)
- 2025年秋季学期教科版二年级上册科学教学计划(三篇)
- 买家赎楼签协议签合同
- (2025年标准)整容医师聘用协议书
- 煤矿机电考试试题及答案
- 借名购车协议贷款协议书
- 2025至2030年中国虹膜识别市场深度调查分析及投资前景研究预测报告
- 《3-6岁幼儿学习与发展指南》试题及答案
- 2025年新职工院感防控及传染病防治知识培训试题及答案
- 2025年公安局招聘警务辅助人员考试笔试试题(含答案)
- 2024版风力发电站智能运维与远程监控合同3篇
评论
0/150
提交评论