Java程序设计预赛模拟题-6

2026/1/24 9:49:51

B.t .equals(c);

C.s==t;

D.t .equals(new String(“hello”)); E. t==c;

8.请看下面的代码

String s = “story”;

下面选项语句书写正确的是: A.s += “books”; B.char c = s[1]; C.int len = s .length;

D.String t = s.toLowerCase( );

9.使用catch(Exception e)的好处是▁▁。

A.只会捕获个别类型的异常

B.捕获try块中产生的所有类型的异常 C.不会漏掉所产生的异常 D.执行一些程序

10.请看下面的代码

public void test( ) { try { oneMethod( );

System .out .println(“condition 1”);

} catch (ArrayIndexOutOfBoundsException e) { System .out .println(“condition 2”); catch (Exception e) {

System .out .println(“condition 3”); } finally {

System .out .println(“condition 4”); } }

如果oneMethod抛出NullPointerException,则程序输出结果为: A.condition 1 B.condition 2 C.condition 3 D.condition 4 11. 请看下面的代码

public void fun( ) {

int i; try {

i=System .in .read( );

System .out .println(“location 1”); } catch (IOException e) {

System .out .println(“location 2”); } finally {

System .out .println(“location 3”); }

System .out .println(“location 4”); }

如果IOException块执行,程序的输出结果为: A.location 1 B.location 2 C.location 3 D.location 4

12.下面那一个选项正确创建一个空的含有6个元素的字符数组:

A.String s[6]; B.String [6]s;

C.String s[ ]={“”,””,””,””,””,””}; D.String s[ ]=new String[6];

For(int m=0;m<6;m++) { s[m]=””;} E. String s[ ]=new String[6];

For(int m=0;m<6;m++) { s[m]=null;} 13.关于变量和它们范围的说法,正确的是:

A.实例变量是类的成员变量

B.实例变量要用关键字static来声明

C.在一个方法执行时,定义在该方法的局部变量才被创建 D.局部变量必须在它们使用前初始化 14.四种成员访问形式是▁▁。

A.public B.private

C.protected D.包访问

15.下面选项正确创建一个字符型数组(含有4个元素)的是:

A.String a[ ] = new String[4];

for(int i=0;i<4;a[i++]=””); B.String a[ ]={“”,””,””,””}; C.String a[4];

D.String [4]a;

E. String [ ]a = new String[4];

For(int i=0;i<4;a[i++]=null);

16.请看下面的代码

1.StringBuffer sb = new StringBuffer(“abc”);

2.String s = new String(“abc”); 3.sb.append(“def”); 4.s.append(“def”); 5.sb.inser(1,”zzzz”); 6.s.concat(sb);

7.s.trim( );

下面说法正确的是:

A.编译时在第一行发生一个错误 B.编译时在第二行发生一个错误 C.编译时在第三行发生一个错误 D.编译时在第四行发生一个错误 E. 编译时在第五行发生一个错误 F. 编译时在第六行发生一个错误 G. 编译时在第七行发生一个错误 17、下列程序段执行后t5的结果是( )。

int t1 = 9, t2 = 11, t3=8; int t4,t5;

t4 = t1 > t2 ? t1 : t2+ t1; t5 = t4 > t3 ? t4 : t3;

A.8 B.20 C.11 D.9

18、请看下面的代码。如果oneMethod抛出NullPointerException,则程序输出结果为( )。

public void test( ) {

try { oneMethod( ); System .out .println(“condition 1”); }

catch (ArrayIndexOutOfBoundsException e){ System .out .println(“condition 2”);} catch (Exception e) { System .out .println(“condition 3”);} finally { System .out .println(“condition 4”); } }

A.condition 1 B.condition 2 C.condition 3 D.condition 4

19.请看下面的代码

public void test( ) {

try { oneMethod( );

System .out .println(“condition 1”); } catch (ArrayIndexOutOfBoundsException e) { System .out .println(“condition 2”); catch (Exception e) {

System .out .println(“condition 3”); } finally {

System .out .println(“finally”); }

}

如果oneMethod正常运行,则程序输出结果为: A.condition 1 B.condition 2 C.condition 3 D.finally

20.请看下面未完成的代码

1.

2.{ success = connect( ); 3. if(success==-1) {

4. throw new TimedOutException( );

5. } 6.}

其中TimedOutException不是运行时间异常,则在第1行需要添加那一条语句来完成方法的声明:

A.public void method( )

B.public void method( )throws Exception

C.public void method( )throws TimedOutException D.public void method( )throw TimedOutException E. public throw TimedOutException void method( )


Java程序设计预赛模拟题-6.doc 将本文的Word文档下载到电脑
搜索更多关于: Java程序设计预赛模拟题-6 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219