JAVA双语教学考试试卷和答案B
班 级学 号姓 名密封装订线密封装订线密封装订线B卷注意事项:请将各题答案按编号顺序填写到答题卷上,答在试卷上无效。单选题(本题共40小题,每小题1分,共40分)What is the return-type of the methods that implement the MouseListener interface?A. booleanB. BooleanC. voidD. PointSelect valid identifier of Java:A. %passwdB. 3d_gameC. $chargeD. thisWhich 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() {}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 allows you to call an addXxxxListener method as manytimes as is needed, specifying as many different listeners as your design require.Which method you define as the starting point of new thread in a class from which new thethread can be excution?A. public void start()B. public void run()C. public void int()D. public static void main(String args[]) Which statement is correctly declare a variable a which is suitable for refering to an array of50 string empty object?A. String [] aB. String aC. char a[][]D. String a[50] Which cannot be added to a Container?A. a MenuB. a ComponentC. a ContainerD. an AppletWhich is the main() method’s return of a application?A. StringB. byteC. charD. voidWhich is corrected argument of main() method of application?A. String argsB. String ar[]C. Char args[][]D. StringBufferarg[]Float s=new Float(0.9F);Float t=new Float(0.9F);Double u=new Double(0.9);Which expression’s result is true?A. s==tB. s.equals(t)C. s==uD. t.equals(u)Which are not Java keyword?A. gotoB. nullC. FALSED. constRun a corrected class: java –csAClass a b c <enter>Which statement is true?A. args[0]=”-cs”;B. args[1]=”a b c”;C. args[0]=”java”;D. args[0]=”a”;Short answer:The decimal value of i is 12, the octal i value is: A. 14B. 014C. 0x14D. 012Short answer:The decimal value of i is 7, the hexadecimal i value is:A.7B. 07C. 0x7D. x07Which is the range of char?A. -27~27-1B. 0~216-1C. 0~216D. 0~28Which 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.What is written to the standard output given the following statement:System.out.println(4|7);Select the right answer:A.4B.5C.6D.7A class design requires that a particular member variable must be accessible for direct accessby any subclasses of this class. but otherwise not by classes which are not members of the samepackage. 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 modifiermain方法是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[] )下面哪种注释方法能够支持javadoc命令: A)/**...**/ B) /*...*/ C)// D)/**...*/Java? Application源程序的主类是指包含有(? )方法的类。
A)main方法? B)toString方法 C)init方法 D)actionPerfromed方法Java的字符类型采用的是Unicode编码方案,每个Unicode码占用(? )个比特位。 A)8? B)16 C)32 D)64设 a = 8,则表达式? a >>> 2 的值是( )。 A)1 B)2 C)3 D)4 若需要定义一个类域或类方法,应使用哪种修饰符?(? ) A)static B)package? C)private D)public若在某一个类定义中定义有如下的方法: abstract? void?performDial( );该方法属于()。 A)本地方法 B)最终方法 C)解态方法 D)抽象方法下列关于静态初始化块的叙述中,哪一个是正确的?() A)静态初始化块是在构造函数之前加上static修饰符。 B)静态初始化块是对类自身进行初始化。 C)静态初始化块在同一个类中只能有一个。 D)静态初始化块是在其所属的类加载内存时由系统自动调用执行。不使用static修饰符限定的方法称为对象(或实例)方法,下列哪一个说法是正确的?() A)实例方法可以直接调用父类的实例方法。 B)实例方法可以直接调用父类的类方法。 C)实例方法可以直接调用其他类的实例方法。 D)实例方法可以直接调用本类的类方法。设有下面两个类的定义:? class? Person { class? Student? extends? Person { long id;? // 身份证号? ? int? score;? // 入学总分 String? name; // 姓名 int? getScore(){ } return? score;? ? } ? }问:类Person和类Student的关系是(? )。 A)包含关系? B)继承关系 C)关联关系? D)无关系,上述类定义有语法错误在Java中,一个类可同时定义许多同名的方法,这些方法的形式参数的个数、类型或顺序各不相同,传回的值也可以不相同。这种面向对象程序特性称为(? )。 A)隐藏 B)覆盖C)重载 D)Java不支持此特性对于构造函数,下列叙述不正确的是(? )。 A)构造函数也允许重载。 B)子类无条件地继承父类的无参构造函数。 C)子类不允许调用父类的构造函数。 D)在同一个类中定义的重载构造函数可以相互调用。在使用interface声明一个接口时,只可以使用(? )修饰符修饰该接口。 A)privateB)protected C)private? protectedD)public在Java? Applet程序用户自定义的Applet子类中,常常重载( )方法在Applet的界面中显示文字、图形和其它界面元素。 A)start( )? B)stop( ) C)init( )D)paint( )在Java中,存放字符串常量的对象属于(? )类对象。 A)CharacterB)String C)StringBuffer D)Vector在Java图形用户界面编程中,若显示一些不需要修改的文本信息,一般是使用(? )类的对象来实现。A)Label B)Button C)TextArea? D)TextField创建一个标识有"关闭"按钮的语句是( )。 A)TextField? b = new? TextField("关闭"); B)Label? b = new? Label("关闭"); C)Checkbox? b = new? Checkbox("关闭"); D)Button b = new? Button("关闭");在编写Java? Applet程序时,若需要对发生的事件做出响应和处理,一般需要在程序的开头写上( )语句。 A)import java.awt.* ;? B)import java.applet.* ;? C)import java.io.* ; D)import java.awt.event.* ;当Frame改变大小时,放在其中的按钮大小不变,则使用如下哪个Layout?A)FlowLayoutB)CardLayoutC)BorderLayoutE)GridLayout哪个关键字可以抛出异常?A)transient B)finally C)throw D)static System类在哪个包中? A)java.util B)java.io C)java.awt D)java.lang以下哪个方法用于定义线程的执行体?A)start()B)init()C)run()D)main()二、读程序(每小题只有一个正确答案,每小题2分,共40分)Give the code fragment:if(x>4){System.out.println(“Test 1”);}else if (x>9){System.out.println(“Test 2”);}else {System.out.println(“Test 3”);}Which range of value x would produce of output “Test 2”?A. x<4B. x>4C. x>9D. NoneWhich correctly create an array of five empty Strings?A. String a[] = new String[5];for (inti=0;i<5;a[i++]=””);B. String a[5];C. String [5] a;D. String [] a = new String[5];for (inti = 0 ;i<5;a[i++] = null);Given the following class definition:class A{protected inti;A(inti){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 A{B(){System.out.println(“i=”+i);}}D. class B{class A{}}What happens when you try to compile and run the following program?class Mystery{String 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 outputGive the following class:public class Example{String 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,charch[]){str=”test ok”;ch[0]=’g’;}}Which is the output:A. good and abcB. good and gbcC. test ok and abcD. test ok and gbcGive following class:class AClass{private 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;Give the following java class:public class Example{static int x[]=new int[15];public static void main(String args[]){System.out.println(x[5]);}}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.Give the following java class:public class Example{public static void main(String args[]){static int x[] = new int[15];System.out.println(x[5]);}}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.Given this class:class Loop {public static void main (String [] args){int x=0;int y=0;outer: for (x=0; x<100;x++) {middle: for (y=0;y<100; 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;What is the output of the following code?outer: for(inti=1; i<2; i++){inner: for(int j=1; j<2; j++){if (j==2){continue outer;}System.out.println(i + " and " + j);}}A. 1 and 1B. 1 and 2C. 2 and 1D. 2 and 2Give the code fragment:1) switch(x){2) case 1:System.out.println(“Test 1”);break;3) case 2:4) case 3:System.out.println(“Test 2”);break;5) default:System.out.println(“end”);6) }which value of x would cause “Test 2” to the output:A. 1B. 2C. 4D. defaultThe following code is entire contents of a file called Example.java,causes precisely one errorduring compilation:1) class SubClass extends BaseClass{2) }3) class BaseClass(){4) String str;5) public BaseClass(){6) System.out.println(“ok”);}7) public BaseClass(String s){8) str=s;}}9) public class Example{10) public void method(){11) SubClass s=new SubClass(“hello”);12) BaseClass b=new BaseClass(“world”);13) }14) }Which line would be cause the error?A. 9B. 10C. 11D.12Give the following code:public class Example{public static void main(String args[] ){int l=0;do{System.out.println(“Doing it for l is:”+l);}while(--l>0)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 0and FinishWhat 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)2B)3 C)5 D)12 What is the result of executing the following code:public class Test { public static void main(String args[]) {A a=new A("aaaaa");A.Bb=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)aaaaaB)ababaC)abcdD)aaaaaabcd下面的程序编译运行后,从键盘输入9,回车后输出的结果是( )。import java.io.*;public class Test { public static void main(String args[]) throws IOException {BufferedReaderbuf=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)81C)quitD)3 应用程序的main方法中有以下语句,则执行后输出的结果是 ( )。int[] x={25,2,55,68,98};int max=x[0]; for(inti=1;i<x.length;i++){ if(x[i]>max) max=x[i]; }System.out.println(min);A)12 B)2 C)98 D)55 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)10B)0 C)20D)100 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)yyyyyB)xxxxxC)xyD)xxxxxyyyyyWhat 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 Inner{void 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)outerC)in the Inner D)error三、编程题(20分)1.输入两个正整数m和n,求其最大公约数和最小公倍数。。2.输入一个正整数,判断它是不是回文数。班 级学 号姓 名密封装订线密封装订线密封装订线答题卷一、单项选择题(1~40每小题1分,共40分)1C2C3B4D5B6A7A8D9B10B11C12D13B14C15B16D17A18C19D20C21A22B23B24A25D26D27A28B29C30C31D32D33B34A35D36D37A38C39D40C二、读程序(1~20每小题2分,共40分)1D2A3A4B5B6A7C8A9B10A11B12C13D14C15C16B17C18C19A20B三、编程题(每小题10分,共20分)1.import java.util.*;public class? lianxi06? { public static void main(String[] args) {int? a ,b,m;Scanner s = new Scanner(System.in);System.out.print( "键入一个整数: "); a = s.nextInt();System.out.print( "再键入一个整数: "); b = s.nextInt(); deff cd = new deff(); m = cd.deff(a,b); int n = a * b / m; System.out.println("最大公约数: " + m); System.out.println("最小公倍数: " + n);} }class deff{public intdeff(int x, int y) {? int t;? if(x < y) { t = x; x = y; y = t;? } while(y != 0) { if(x == y) return x; else { int k = x % y; x = y; y = k; }? }? return x;}2.import java.util.*;public class lianxi25a {public static void main(String[] args) { Scanner s = new Scanner(System.in); boolean is =true; System.out.print("请输入一个正整数:"); long a = s.nextLong(); String ss = Long.toString(a); char[] ch = ss.toCharArray(); int j=ch.length; for(inti=0; i<j/2; i++) { if(ch[i]!=ch[j-i-1]){is=false;} } if(is==true){System.out.println("这是一个回文数");}? else {System.out.println("这不是一个回文数");} } }
热门文章:
- 2023年春节优美文案句子简短,新...2023-09-27
- 2023年想北平教学反思简短,想北...2023-09-27
- 2023年小学生作文加批改评语,小...2023-09-27
- 闹元宵主题手抄报设计图片优质2023-09-27
- 美丽校园小学生作文2023-09-27
- 2023年给公司道歉信,给公司道歉...2023-09-27
- 2023年定风波,苏轼,定风波苏轼原...2023-09-27
- 2023年我卧室作文200字,我卧室作...2023-09-27
- 最新美国杰出人才移民申请条件3...2023-09-27
- 2023年新西兰地震满天中国飞机2023-09-27
- 最新《化石吟》教学教案设计及反...2023-09-26
- 2023年有关感谢老师感谢信(十二篇)2023-09-26
- 2023年大班艺术教育活动方案(1合集)2023-09-25
- 最新《化石吟》教学教案设计及反...2023-09-25
- 最新感恩节活动方案中班,感恩节...2023-09-25
- 2023年春节优美文案句子简短,新...2023-09-25
- 大赛活动策划方案,ppt制作大赛活...2023-09-25
- 2023年游华西村古诗实用2023-09-25
- 2023年物业发言稿,交房仪式物业...2023-09-24
- 2023年机械修理工岗位职责实用2023-09-24
相关文章:
- 2023年春节优美文案句子简短,新春文案句子(3篇)
- 2023年想北平教学反思简短,想北平,教学实录
- 2023年小学生作文加批改评语,小学生作文批改评语简短模板
- 闹元宵主题手抄报设计图片优质
- 美丽校园小学生作文
- 2023年给公司道歉信,给公司道歉信格式(14篇)
- 2023年定风波,苏轼,定风波苏轼原文大全
- 2023年我卧室作文200字,我卧室作文600字通用
- 最新美国杰出人才移民申请条件3篇(实用)
- 2023年新西兰地震满天中国飞机
- 最新《化石吟》教学教案设计及反思,化石吟阅读答案汇总
- 2023年有关感谢老师感谢信(十二篇)
- 2023年大班艺术教育活动方案(1合集)
- 最新《化石吟》教学教案设计及反思,化石吟阅读答案汇总
- 最新感恩节活动方案中班,感恩节活动方案小班(合集)
- 2023年春节优美文案句子简短,新春文案句子(3篇)
- 大赛活动策划方案,ppt制作大赛活动策划方案(五篇)
- 2023年游华西村古诗实用
- 2023年物业发言稿,交房仪式物业发言稿优秀
- 2023年机械修理工岗位职责实用
- 最新学生期中考试总结与反思500字,学生期中考试总结与反思语文实用
- 2023年早安励志文案,简单早安心语说说(3篇)
- 2023年如何防范办公室职业病传染优质
- 最新廊坊高考成绩查询系统入口汇总
- 白醋美容方法大全
- 2023年物业发言稿,交房仪式物业发言稿优秀
- 2023年春节优美文案句子简短,新春文案句子(3篇)
- 手心中温暖汇总
- 2023年广西少数民族节日风俗大全
- 《颐和园》教学反思与评价(10篇)