JAVA双语教学考试试卷及答案B.docx_第1页
JAVA双语教学考试试卷及答案B.docx_第2页
JAVA双语教学考试试卷及答案B.docx_第3页
JAVA双语教学考试试卷及答案B.docx_第4页
JAVA双语教学考试试卷及答案B.docx_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

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

文档简介

班 级 学 号 姓 名 密封装订线 密封装订线 密封装订线B卷注意事项:请将各题答案按编号顺序填写到答题卷上,答在试卷上无效。一、 单选题(本题共40小题,每小题1分,共40分)1. What is the return-type of the methods that implement the MouseListener interface?A. booleanB. BooleanC. voidD. Point2. Select valid identifier of Java:A. %passwdB. 3d_gameC. $chargeD. this3. Which declares an abstract method in an abstract Java class?A. public abstract method();B. public abstract void method();C. public void abstract Method(;D. public abstract void method() 4. 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.5. Which method you define as the starting point of new thread in a class from which new the thread can be excution?A. public void start()B. public void run() C. public void int()D. public static void main(String args) 6. Which statement is correctly declare a variable a which is suitable for refering to an array of 50 string empty object?A. String aB. String aC. char aD. String a50 7. Which cannot be added to a Container?A. a MenuB. a ComponentC. a ContainerD. an Applet8. Which is the main() methods return of a application?A. StringB. byteC. charD. void9. Which is corrected argument of main() method of application?A. String argsB. String arC. Char argsD. StringBuffer arg10. Float s=new Float(0.9F);Float t=new Float(0.9F);Double u=new Double(0.9);Which expressions result is true?A. s=tB. s.equals(t)C. s=uD. t.equals(u)11. Which are not Java keyword?A. gotoB. nullC. FALSED. const12. Run a corrected class: java cs AClass a b c Which statement is true?A. args0=”-cs”;B. args1=”a b c”;C. args0=”java”;D. args0=”a”; 13. Short answer:The decimal value of i is 12, the octal i value is: A. 14B. 014C. 0x14D. 01214. Short answer:The decimal value of i is 7, the hexadecimal i value is:A.7B. 07C. 0x7D. x0715. Which is the range of char?A. -2727-1B. 0216-1C. 0216D. 02816. Which statement is true about an inner class?A. It must be anonymousB. It can not implement an interfaceC. It is only accessible in the enclosing classD. It can access any final variables in any enclosing scope.17. What is written to the standard output given the following statement:System.out.println(4|7);Select the right answer:A.4B.5C.6D.7 18. A class design requires that a particular member variable must be accessible for direct access by any subclasses of this class. but otherwise not by classes which are not members of the same package. What should be done to achieve this?A. The variable should be marked publicB. The variable should be marked privateC. The variable should be marked protectedD. The variable should have no special access modifier19. main方法是Java Application程序执行的入口点,关于main方法的方法头以下哪项是合法的( )? A)public static void main( ) B)public static void main( String args ) C)public static int main(String arg ) D)public void main(String arg )20. 下面哪种注释方法能够支持javadoc命令: A)/*.*/ B) /*.*/ C)/ D)/*.*/21. Java Application源程序的主类是指包含有( )方法的类。 A)main方法 B)toString方法 C)init方法 D)actionPerfromed方法22. Java的字符类型采用的是Unicode编码方案,每个Unicode码占用( )个比特位。 A)8 B)16 C)32 D)6423. 设 a = 8,则表达式 a 2 的值是( )。 A)1 B)2 C)3 D)4 24. 若需要定义一个类域或类方法,应使用哪种修饰符?( ) A)static B)package C)private D)public25. 若在某一个类定义中定义有如下的方法: abstract void performDial( ); 该方法属于()。 A)本地方法 B)最终方法 C)解态方法 D)抽象方法26. 下列关于静态初始化块的叙述中,哪一个是正确的?() A)静态初始化块是在构造函数之前加上static修饰符。 B)静态初始化块是对类自身进行初始化。 C)静态初始化块在同一个类中只能有一个。 D)静态初始化块是在其所属的类加载内存时由系统自动调用执行。27. 不使用static修饰符限定的方法称为对象(或实例)方法,下列哪一个说法是正确的?() A)实例方法可以直接调用父类的实例方法。 B)实例方法可以直接调用父类的类方法。 C)实例方法可以直接调用其他类的实例方法。 D)实例方法可以直接调用本类的类方法。28. 设有下面两个类的定义: class Person class Student extends Person long id; / 身份证号 int score; / 入学总分 String name; / 姓名 int getScore() return score; 问:类Person和类Student的关系是( )。 A)包含关系 B)继承关系 C)关联关系 D)无关系,上述类定义有语法错误29. 在Java中,一个类可同时定义许多同名的方法,这些方法的形式参数的个数、类型或顺序各不相同,传回的值也可以不相同。这种面向对象程序特性称为( )。 A)隐藏 B)覆盖 C)重载 D)Java不支持此特性30. 对于构造函数,下列叙述不正确的是( )。 A)构造函数也允许重载。 B)子类无条件地继承父类的无参构造函数。 C)子类不允许调用父类的构造函数。 D)在同一个类中定义的重载构造函数可以相互调用。31. 在使用interface声明一个接口时,只可以使用( )修饰符修饰该接口。 A)privateB)protected C)private protected D)public32. 在Java Applet程序用户自定义的Applet子类中,常常重载( )方法在Applet的界面中显示文字、图形和其它界面元素。 A)start( ) B)stop( ) C)init( ) D)paint( )33. 在Java中,存放字符串常量的对象属于( )类对象。 A)Character B)String C)StringBuffer D)Vector34. 在Java图形用户界面编程中,若显示一些不需要修改的文本信息,一般是使用( )类的对象来实现。 A)Label B)Button C)TextArea D)TextField35. 创建一个标识有关闭按钮的语句是( )。 A)TextField b = new TextField(关闭); B)Label b = new Label(关闭); C)Checkbox b = new Checkbox(关闭); D)Button b = new Button(关闭);36. 在编写Java Applet程序时,若需要对发生的事件做出响应和处理,一般需要在程序的开头写上( )语句。 A)import java.awt.* ; B)import java.applet.* ; C)import java.io.* ; D)import java.awt.event.* ;37. 当Frame改变大小时,放在其中的按钮大小不变,则使用如下哪个Layout?A)FlowLayout B)CardLayoutC)BorderLayout E)GridLayout38. 哪个关键字可以抛出异常? A)transient B)finally C)throw D)static 39. System类在哪个包中? A)java.util B)java.io C)java.awt D)java.lang 40. 以下哪个方法用于定义线程的执行体? A)start( ) B)init( ) C)run( ) D)main( ) 二、读程序(每小题只有一个正确答案,每小题2分,共40分)1. Give the code fragment:if(x4)System.out.println(“Test 1”);else if (x9)System.out.println(“Test 2”);else System.out.println(“Test 3”);Which range of value x would produce of output “Test 2”?A. x4C. x9D. None2. Which correctly create an array of five empty Strings?A. String a = new String5;for (int i=0;i5;ai+=”);B. String a5;C. String 5 a;D. String a = new String5;for (int i = 0 ;i5;ai+ = null);3. 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?Select all valid answers:A. class B B. class B extends A C. class B extends AB()System.out.println(“i=”+i);D. class Bclass A4. What happens when you try to compile and run the following program?class MysteryString s;public static void main(String args)Mystery m=new Mystery();m.go();void Mystery()s=”constructor”;void go()System.out.println(s);A. this code will not compileB. this code runs and writes ”null” in the standard outputC. this code runs but nothing appears in the standard outputD. this code runs and “constructor” in the standard output5. Give the following class:public class ExampleString str=new String(“good”);char ch=a,b,c;public static void main(String args)Example ex=new Example();ex.change(ex.str,ex.ch);System.out.println(ex.str+”and”+ex.ch);public void change(String str,char ch)str=”test ok”;ch0=g;Which is the output:A. good and abcB. good and gbc C. test ok and abcD. test ok and gbc6. Give following class:class AClassprivate long val;public AClass(long v)val=v;public static void main(String args)AClass x=new AClass(10L);AClass y=new AClass(10L);AClass z=y;long a=10L;int b=10;Which expression result is true?A. a=b;B. a=x;C. x=y;D. a=10.0;7. 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.8. Give the following java class:public class Examplepublic static void main(String args)static int x = new int15;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.9. Given this class:class Loop public static void main (String args)int x=0;int y=0;outer: for (x=0; x100; x+) middle: for (y=0; y100; y+) System.out.println(x= + x + ; y= + y);if (y=10) /main/classThe question is which code must replace the to finish(终止) the outer loop?A. continue middle;B. break outer;C. break middle;D. continue outer;10. What is the output of the following code?outer: for(int i=1; i2; i+)inner: for(int j=1; j0)System.out.println(“Finish”);Which well be output:A. Doing it for l is 3B. Doing it for l is 1 C. Doing it for l is 2D. Doing it for l is 0 and Finish 14. What is the result of executing the following code:public class Test int x=2; int y; public static void main(String args) int z=3; Test t=new Test(); System.out.println(t.x+t.y+z); A)2 B)3 C)5 D)12 15. What is the result of executing the following code:public class Test public static void main(String args) A a=new A(aaaaa);A.B b=a.new B(); System.out.println(b.inStr); class A private String outStr; public A(String s) outStr=s; public class B public String inStr=abcd; A)aaaaa B)ababa C)abcd D)aaaaaabcd 16. 下面的程序编译运行后,从键盘输入9,回车后输出的结果是( )。import java.io.*;public class Test public static void main(String args) throws IOException BufferedReader buf=new BufferedReader( new InputStreamReader(System.in); while(true) String str=buf.readLine(); if(str.equals(quit) break; int x=Integer.parseInt(str); System.out.println(x*x); A)9 B)81 C)quit D)3 17. 应用程序的main方法中有以下语句,则执行后输出的结果是 ( )。int x=25, 2, 55, 68, 98; int max=x0; for(int i=1; imax) max=xi; System.out.println(min);A)12 B)2 C)98 D)55 18. What is the result of executing the following code:public class Test implements A int x=10; public static void main(String args) Test c1 = new Test(); System.out.println(c1.x+A.k); interface A int k= 10;A)10 B)0 C)20 D)100 19. What is the result of executing the following code:public class Test public static void main(String args) X a=new X( ) public void showX() System.out.println(yyyyy); ; a.showX(); class X public void showX() System.out.println(xxxxx); A)yyyyy B)xxxxx C)xy D)xxxxxyyyyy 20. What is the result of executing the following code:class Outer private int a; void foo(double d,final float f) String s; final boolean b;class Innervoid methodInner() System.out.println(in the Inner); public static void main(String args) Outer me=new Outer(); me.foo(123,234); System.out.println(outer); A)in the Inner outer B)outer C)in the Inner D)error三、编程题(20分)1输入两个正整数m和n,求其最大公约数和最小公倍数。2. 输入一个正整数,判断它是不是回文数。班 级 学 号 姓 名 密封装订线 密封装订线 密封装订线答题卷一、单项选择题(140每小题1分,共40分

温馨提示

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

评论

0/150

提交评论