1、g A、 good and abc B、 good and gbc C、test ok and abc D、 test ok and gbc 5.运行下列程序, 会产生什么结果 C Dpublic class X extends Thread implements Runable public void run() System.out.println(this is run() public static void main(String args) Thread t=new Thread(new X();t.start();A、 第一行会产生编译错误 B、 第六行会产生编译错误 C、 第六
2、行会产生运行错误 D、 程序会运行和启动 6.要从文件 file.dat文件中读出第10个字节到变量C中,下列哪个方法适合?A、 FileInputStream in=new FileInputStream(file.dat in.skip(9); int c=in.read();B、 FileInputStream in=new FileInputStream( in.skip(10);C、 FileInputStream in=new FileInputStream(D、 RandomAccessFile in=new RandomAccessFile( int c=in.readByte
3、();7.容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小的变化而改变?A、 CardLayout B、 FlowLayout C、 BorderLayout D、 GridLayout 8.给出下面代码:public class Person static int arr = new int10;public static void main(String a) System.out.println(arr1); 那个语句是正确的? CA、 编译时将产生错误;B、 编译时正确,运行时将产生错误;C 、输出零;D、 输出空。9.哪个关键字可以对对象加互斥锁?A、 transi
4、ent B synchronized C serialize D static 10.下列哪些语句关于内存回收的说明是正确的?A、 程序员必须创建一个线程来释放内存;B、 内存回收程序负责释放无用内存 C、内存回收程序允许程序员直接释放内存 D、内存回收程序可以在指定的时间释放内存对象 11.下列代码哪几行会出错:1) public void modify() 2) int I, j, k;3) I = 100;4) while ( I 0 ) 5) j = I * 2;6) System.out.println ( The value of j is + j );7) k = k + 1;8
5、) I-;9) 10 A、 line 4 B、 line 6 C、 line 7 D、 line 812.MAX_LENGTH是int型public成员变量, 变量值保持为常量100,用简短语句定义这个变量。 DA、 public int MAX_LENGTH=100;B、 final int MAX_LENGTH=100;C、 final public int MAX_LENGTH=100;D、 public final int MAX_LENGTH=100. 13.给出下面代码:1) class Parent 2 private String name;3 public Parent()
6、4 5) public class Child extends Parent 6 private String department;7 public Child() 8 public String getValue() return name; 9 public static void main(String arg) 10 Parent p = new Parent();11 12 那些行将引起错误?A、 第3行 B、 第6行 C、 第7行 D、 第8行14.类Teacher和Student是类Person的子类;Person p;Teacher t;Student s;/p, t and
7、 s are all non-null. if(t instanceof Person) s = (Student)t;最后一句语句的结果是: B CA、 将构造一个Student对象;B、 表达式是合法的;C、 表达式是错误的;D、 编译时正确,但运行时错误。15.给出下面代码段 1) public class Test 2) int m, n;3) public Test() 4) public Test(int a) m=a;5) public static void main(String arg) 6) Test t1,t2;7) int j,k;8) j=0; k=0;9) t1=
8、new Test();10) t2=new Test(j,k);11) 12) 哪行将引起一个编译时错误?A、 line 3 B、 line 5 C、 line 6 D、 line 10 16.对于下列代码:1) class Person 2) public void printValue(int i, int j) /. 3) public void printValue(int i)/. 4) 5) public class Teacher extends Person 6) public void printValue() /. 7) public void printValue(int
9、 i) /. 8) public static void main(String args) 9) Person t = new Teacher();10) t.printValue(10);第10行语句将调用哪行语句??A、 line 2 B、 line 3 D、 line 717.哪个关键字可以抛出异常?B、 finally C、 throw D、 static 18.Main()方法的返回类型是:A、 int B、 void C、 boolean 19.System类在哪个包中?A、 java.util B、 java.io C、 java.awt D、 java.lang20.对于下列
10、代码: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( i
11、nt a, int b )throws MyException /do something. 21.给出下面代码:public class test static int a = new a10;public static void main(String args) System.out.println(a10);那个选项是正确的?C、 输出零;22.下面哪些选项是正确的main方法说明?A、 public main(String args) B、 public static void main(String args) C、 private static void main(String
12、args) D、 void main() 23.给定下面的代码片段:1) String str = null;2) if (str != null) & (str.length() 10) 3) System.out.println(more than 105) else if (str ! (str.length() 2)5 D、 (23)40. 下面哪个是对字符串String的正确定义 ( A )A、String s1=null; B、String s2=null ; C、String s3=(String) abc ; D、String s4=(String) uface;41. 下面哪
13、条语句不能定义一个float型的变量( B )A、float f1= -343 ; B、float f2=3.14 ;C、float f3=0x12345 ; D、float f4=2.8F ;42. 下面哪条语句定义了5个元素的数组( A )A、int a=22,23,24,25,12;B、int a =new int(5);C、int 5 array;D、int arr;43. 下面哪个范围是char型的取值范围( c )A、-256 255 B、-(215) (215)-1 C、u0000 uffff D、 03276744. 给出一段程序,选择运行结果( D )public class
14、 sss public static void main(String args) String s1=args1; String s2=args2; String s3=args3; String s4=args4; System.out.println(“args2=”+s2);命令行执行: java sss 1 2 3 4 结果是下面哪一个?A、args2=2 B、args2=null C、args2=1 D、运行出现异常 45. 下面哪个描述是正确的( A )A、Applet程序中不需要main()方法,也不能有B、Application程序中可以没有main()方法。C、Applet
15、程序中可以不定义init( )方法D、Application程序中必须有run( )方法 46. 给出一段程序,试判断哪个是正确的结果( B )public class rtExcept public static void throwit()System.out.print(“throwit”);throw new RuntimeException(); public static void main(String aa) try System.out.print(“hello “); throwit(); catch(Exception re) System.out.print(“caug
16、ht ”); finally System.out.print(“finally ”); System.out.print(“after ”); A、hello throwit caughtB、hello throwit caught finally after C、hello throwit RuntimeException afterD、hello throwit caught finally after RuntimeException47. 对一个java源文件 aaa.java,编辑保存后但未编译,在其所在目录下执行 java aaa,则接着会出现什么( C )A、error: cannot read: aaa.jav
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1