云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > Java基础练习题附答案

Java基础练习题附答案

  • 62 次阅读
  • 3 次下载
  • 2025/12/3 5:57:28

word格式

3) 设有如下代码: public void fun () { int i; try {

i=System.in.read ();

System.out.println(\ } catch (IOException e) {

System.out.println(\ } finally {

System.out.println(\ }

System.out.println(\}

如果有一个IOException发生, 则输出有哪些? A. Location 1 B. Location 2 C. Location 3 D. Location 4 4) 设有如下代码:

1 String s = null;

2 if ( s != null & s.length() > 0)

3 System.out.println(\ 4 if ( s != null && s.length() > 0)

5 System.out.println(\ 6 if ( s != null || s.length() > 0)

7 System.out.println(\ 8 if ( s != null | s.length() > 0)

9 System.out.println(\以下行中哪些会产生空指针异常。 A. 2,4 B. 6,8 C. 2,4,6,8 D. 2,6,8

5) 类Test1、Test2定义如下:

.. ..

word格式

1.public class Test1 {

2. public float aMethod(float a,float b) throws IOException { 3. } 4. }

5. public class Test2 extends Test1{ 6. 7. }

将以下哪种方法插入行6是不合法的。

A、float aMethod(float a,float b){ }

B、public int aMethod(int a,int b)throws Exception{ } C、public float aMethod(float p,float q){ }

D、public int aMethod(int a,int b)throws IOException{ } 6)设有如下代码: try {

tryThis(); return;

} catch (IOException x1) {

System.out.println(\ return;

} catch (Exception x2) {

System.out.println(\ return; } finally {

System.out.println(\ }

如果tryThis() 抛出 NumberFormatException,则输出结果是? A. 无输出

B. \后跟 \C. \后跟 \D. \E. \

十三、流式输入输出与文件处理

1)以下哪个是RandomAccessFile文件的构造方法: A.RandomAccessFile(\B.RandomAccessFile(\

.. ..

word格式

C.RandomAccessFile(\D.RandomAccessFile(\2)设有如下代码: import java.io.*; public class Th{

public static void main(String argv[]){ Th t = new Th(); t.amethod(); }

public void amethod(){ try{ ioCall();

}catch(IOException ioe){} } }

以下哪个最有可能是ioCall方法的方法体? A. public void ioCall () throws IOException{

DataInputStream din = new DataInputStream(System.in); din.readChar(); }

B. public void ioCall () throw IOException{

DataInputStream din = new DataInputStream(System.in); din.readChar(); }

C. public void ioCall (){

DataInputStream din = new DataInputStream(System.in); din.readChar(); }

D. public void ioCall throws IOException(){

DataInputStream din = new DataInputStream(System.in); din.readChar(); }

3)当前目录不存在名为Hello.txt的文件,执行下面代码的输出结果为? import java.io.*; public class Mine{

.. ..

word格式

public static void main(String argv[]){ Mine m=new Mine( );

System.out.println(m.amethod()); }

public int amethod(){ try{

FileInputStream file=new FileInputStream(\ }

catch(FileNotFoundException e){

System.out.print(\ return -1; }

catch(IOException e){

System.out.print(\ } return 0; } }

A. No such file found B. No such file found-1

C. No such file foundDoing finally-1 D. 0

4) 使用哪个类可创建目录?

A. File B. DataOutput C. Directory D. FileDescriptor E. FileOutputStream

5) 假设raf是一个随机访问文件,以下语句的编译和运行结果为?raf.seek( raf.length() ); A.代码不能编译. B.会出现IOException

C.文件指针将定位到文件的最后一个字符之前 D.文件指针将定位到文件的最后一个字符

6)以下哪些是FileOutputStream 构造方法的合法形式? A. FileOutputStream( FileDescriptor fd ) B. FileOutputStream( String n, boolean a ) C. FileOutputStream( boolean a )

.. ..

搜索更多关于: Java基础练习题附答案 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

word格式 3) 设有如下代码: public void fun () { int i; try { i=System.in.read (); System.out.println(\ } catch (IOException e) { System.out.println(\ } finally { System.out.println(\ } System.out.println(\} 如果有一个IOException发生, 则输出有哪些? A. Location 1 B. Location 2 C. Location 3 D. L

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com