欢迎光临
我们一直在努力

JAVA模拟试题

多项选择题 ( 在每小题的五个备选答案中选出正确答案,并将正确答案的序号填入题干后面的括号内,错选多选,漏选均不得分。 )1 、给出如下代码 :class Test{private int m;public static void fun() {// some code...}}如何使成员变量 m  被函数 fun() 直接访问 ?A 、将 private int m  改为 protected int mB 、将 private int m  改为  public int mC 、将 private int m  改为  static int mD 、将 private int m  改为  int m答 : C2 、下面哪几个函数是 public void example(){...} 的重载函数?A 、  public void example( int m){...}B 、 public int example(){...}C 、 public void example2(){...}D 、  public int example ( int m, float f){...}答 : A , D3 、给出下面的代码段 :public class Base{int w, x, y ,z;public Base(int a,int b){x=a; y=b;}public Base(int a, int b, int c, int d){// assignment x=a, y=bw=d;z=c;}}在代码说明 // assignment x=a, y=b 处写入如下哪几个代码是正确的?A 、  Base(a,b);B 、 x=a, y=b;C 、 x=a; y=b;D 、 this(a,b);答 : C , D4 、已知如下定义: String s = "story";下面哪个表达式是合法的?A 、  s += "books";B 、 char c = s[1];C 、 int len = s.length;D 、 String t = s.toLowerCase();答 : A , D5 、 Java 中 main() 函数的值是什么 ?A 、  StringB 、 intC 、 charD 、 void答 :D6 、如下哪些字串是 Java 中的标识符?  A 、  fieldnameB 、 superC 、 3numberD 、 #numberE 、 $number答:  A,E7 、如下哪些是 Java 中有效的关键字?  A 、  constB 、 NULLC 、 falseD 、 thisE 、  native答: A,C,D,E 8 、如下哪些是 Java 中正确的整数表示 ?A 、 22B 、 0x22C 、 022D 、 22H答 : A,B,C9 、下面的代码段中,执行之后 i  和 j  的值是什么 ?int i = 1;int j;j = i++; A 、  1, 1B 、 1, 2C 、 2, 1D 、 2, 2答 : C10 、下面句话是正确的 ?A 、  >>  是算术右移操作符 .B 、 >>  是逻辑右移操作符 .C 、 >>>  是算术右移操作符D 、 >>>  是逻辑右移操作符答: A,D11 、下面哪个赋值语句是合法的?A 、 float a = 2.0B 、 double b = 2.0C 、 int c = 2D 、 long d = 2答: B,C,D12 、下面哪个是 main() 函数的合法参数 ?A 、 char args[]B 、 char args[][]C 、 String arg 要 []D 、 String args答:  C13 、下面哪个语句是创建数组的正确语句?A 、  float f[][] = new float[6][6];B 、 float []f[] = new float[6][6];C 、 float f[][] = new float[][6];D 、 float [][]f = new float[6][6];E 、 float [][]f = new float[6][];答: A,B,C,D14 、已知表达式 int m[] = {0, 1, 2, 3, 4, 5, 6 };下面哪个表达式的值与数组下标量总数相等?A 、  m.length()B 、 m.lengthC 、 m.length()+1D 、 m.length+1答: B15 、已知如下的命令执行  java MyTest a b c请问哪个语句是正确的?A 、  args[0] = "MyTest a b c"B 、 args[0] = "MyTest"C 、 args[0] = "a"D 、 args[1]= 'b'答: C, D16 、已知如下代码:public class Test{long a[] = new long[10];public static void main ( String arg[] ) {System.out.println ( a[6] );}}请问哪个语句是正确的?  A 、 Output is null.B 、 Output is 0.C 、 When compile, some error will occur.D 、 When running, some error will occur.答: B 17 、已知如下代码:boolean m = true;if ( m == false )System.out.println("False");elseSystem.out.println("True");执行结果是什么?A 、 FalseB 、 TrueC 、 NoneD 、 An error will occur when running.答:  B18 、已知如下代码:public class Test{public static void main(String arg[]){int i = 5;do {System.out.println(i);} while (--i>5)System.out.println("finished");}}执行后的输出是什么?A 、  5B 、 4C 、 6D 、 FinishedE 、 None答: A,D 19 、下面代码执行后的输出是什么?outer: for(int i=0;i<3; i++)inner: for(int j=0;j<2;j++){if(j==1) continue outer;System.out.println(j+ "and "+i);} A 、  0 and 0B 、 0 and 1C 、 0 and 2D 、 1 and 0E 、 1 and 1F 、 1 and 2G 、 2 and 0H 、  2 and 1I 、  2 and 2答:  A,B,C20 、已知如下代码:switch (m){case 0: System.out.println("Condition 0");case 1: System.out.println("Condition 1"); case 2: System.out.println("Condition 2");case 3: System.out.println("Condition 3");break;default: System.out.println("Other Condition"); }当 m  的值为什么时输出 "Condition 2"?A 、  0B 、 1C 、 2D 、 3E 、 4F 、 None 答: A,B,C21 、当浏览器返回到新 URL 的包含 applet  的页面时调用以下哪个函数?A 、  init()B 、 start()C 、 stop()D 、 destroy() 答: B22 、以下哪个方法用于定义线程的执行体?  A 、  start()B 、 init()C 、 run()D 、 main()E 、 synchronized() 答: C23 、 Java 中如下哪个约束符是正确的 ?A 、  privateB 、 publicC 、 protectedD 、 protectE 、 friend 答: A,B,C24 如果类中的成员变量可以被同一包访问,则使用如下哪个约束符 ?A 、  privateB 、 publicC 、 protectedD 、 no modifierE 、 final 答: D25 、以下哪个约束符可用于定义成员常量?  A 、  staticB 、 finalC 、 abstractD 、 No modifier can be used 答: B 26 、如下哪个语句正确说明了 native 方法 ?A 、  public native void test();B 、 public native void test(){}C 、 public void native test();D 、 public native test(){} 答: A27 、已知如下类说明:public class Test {private float f = 1.0;int m = 12;static int n=1;public static void main(String arg[]) {Test t = new Test();// some code...} }如下哪个使用是正确的?A 、  t.fB 、 this.nC 、 Test.mD 、 Test.n 答: A,D28 、已知如下代码:1: class Example{2: String str;3: public Example(){4: str= "example";5: }6: public Example(String s){7: str=s;8: }9:} }10: class Demo extends Example{11: }12: public class Test{13:public void f () {14:Example ex = new Example("Good");15:Demo d = new Demo("Good");16:} }哪句语句会导致错误?A 、  line 3B 、 line 6C 、 line 10D 、 line 14E 、 line 15 答: E29 、已知如下类定义:class Base {public Base (){ //... }public Base ( int m ){ //... }protected void fun( int n ){ //... }}public class Child extends Base{// member methods}如下哪句可以正确地加入子类中?A 、  private void fun( int n ){ //...}B 、 void fun ( int n ){ //... }C 、 protected void fun ( int n ) { //... }D 、 public void fun ( int n ) { //... } 答: C,D30 、如下哪个语句是正确的?A 、  In Java single inheritance is allowed, which makes code more reliable.B 、 A subclass inherits all methods ( including the constructor ) from the superclass.C 、  A class can implement as many interfaces as needed.D 、 When a class implements an interface, it can define as many methods of the interface as needed.答: A,C31 、在如下源代码文件 Test.java 中 ,  哪个是正确的类定义?A 、  public class test {public int x = 0;public test(int x) {this.x = x;}}B 、 public class Test{public int x=0;public Test(int x) {this.x = x;}}C 、 public class Test extends T1, T2 {public int x = 0;public Test (int x) {this.x = x;}}D 、  public class Test extends T1{public int x=0;public Test(int x){this.x = x;}} E 、 protected class Test extends T2{public int x=0;public Test(int x){this.x=x;}}答: B,D32 、 Person, Student  和 Teacher  都是类名。这些类有以下继承关系。Person|---------------| |Student Teacher并且在 Java 源代码中有如下表达式:Person p = new Student();如下哪个语句是正确的?  A 、  The expression is legal.B 、 The expression is illegal.C 、 Some errors will occur when compile.D 、 Compile is correct but it will be wrong when running. 答: A33 、当 Frame 改变大小时,放在其中的按钮大小不变,则使用如下哪个 layout?A 、  FlowLayoutB 、 CardLayoutC 、 North and South of BorderLayoutD 、 East and West of BorderLayoutE 、 GridLayout答: D34 、当 Frame 改变大小时,放在其中的按钮大小不变,则使用如下哪个 layout?A 、  FlowLayoutB 、 CardLayoutC 、 North and South of BorderLayoutD 、 East and West of BorderLayoutE 、 GridLayout答: A35 、如下哪个方法可以从 WindowEvent 获取事件源 ?A 、  getFrame()B 、 getID()C 、 getSource()D 、 getWindow() 答: C,D36 、以下哪个有关事件监听器的语句是正确的?A 、  Multiple listeners can be attached to one component.B 、 Only one listener can be attached to one component.C 、 One listener can receive and process the events from multiple components.D 、 One listener can receive and process the events from only one component.答: A,C37 、监听器接口的方法返回值是什么?  A 、  intB 、 StringC 、 voidD 、 ObjectE 、 AWTEvent 答: C38 、下面哪个事件监听器在 Java 中有事件适配器 ?A 、  MouseListenerB 、 KeyListenerC 、 ActionListenerD 、 ItemListenerE 、 WindowListener 答: A,B,E39 、下面哪个方法与 applet 的显示无关 ?A 、  update()B 、 draw()C 、 repaint()D 、 paint() 答: B40 、已知如下说明:TextArea ta = new TextArea ("Hello", 5, 5);请问哪个语句是正确的?  A 、  The maximum number of characters in a line is 5.B 、 The displayed height is 5 lines otherwise constrain.C 、 The displayed string can use multiple fonts.D 、 The displayed strings are editable. 答: B,D41 、请问如下哪个方法可以将 MenuBar 加入 Frame 中 ?A 、  setMenu()B 、 setMenuBar()C 、 add()D 、 addMenuBar() 答: B42 、下面哪个不是 Java 中的容器 ?A 、  ScrollPaneB 、 CanvasC 、 ScrollbarD 、 AppletE 、 Dialog 答: B,C43 、下面哪个方法可用于定义新线程类?A 、  implement the Runnable interfaceB 、 add a run() method in the classC 、 create an instance of ThreadD 、 extend the Thread class 答: A,D 44 、下面哪个 stream 是 node 流 ?A 、  FileInputStreamB 、 BufferedInputStreamC 、 PushbackInputStreamD 、 ByteArrayInputStream 答: A,D45 、哪个类可用于处理 Unicode?A 、  InputStreamReaderB 、 BufferedReaderC 、 WriterD 、 PipedInputStream 答: A,B

赞(0)
未经允许不得转载:福利吧|福利社|fuliba » JAVA模拟试题

相关推荐

  • 暂无文章