第一范文网 - 专业文章范例文档资料分享平台

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

来源:用户分享 时间:2025/5/25 13:24:20 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

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 的文档
Java程序设计预赛模拟题-6.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c6qdxv6vd4n9emep57bop_4.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top