国家开放大学电大面向对象程序设计形考任务4答案

1. 下面(磁盘文件)既可以作为流的数据源,又可以作为流的目的地。
A. 键盘
B. 磁盘文件
C. 显示器
D. 扫描仪
2. 进行文件输入输出操作时,最常用的系统包是(java.io)。
A. java.io
B. java.lang
C. java.util
D. java.awt
3. Java中有3个标准输入/输出流,下面的(System.cur)不包含在内。
A. System.in
B. System.out
C. System.err
D. System.cur
4. 在读字符文件 Employee.dat 时,使用该文件作为参数的类是(FileInputStream)。
A. BufferedReader
B. DataInputStream
C. DataOutputStream
D. FileInputStream
5. 下列不是 InputStream 子类的是(FileOutputStream)。
A. FileInputStream
B. ObjectInputStream
C. FileOutputStream
D. ZipInputStream
6. 下列哪个类不是异常类的父类?(Error)。
A. Error
B. Throwable
C. Exception
D. Object
7. 下面的关键字(void)与异常处理无关。
A. throw
B. void
C. throws
D. try
8. 下面的异常(ArrayIndexOutOfBoundsException)为数组下标越界异常。
A. ArithmeticException
B. NullPointerException
C. ArrayIndexOutOfBoundsException
D. FileNotFoundException
9. 下面(磁盘文件)既可以作为流的数据源,又可以作为流的目的地。
A. 键盘
B. 磁盘文件
C. 显示器
D. 扫描仪
10. Java中有3个标准输入/输出流,下面的(System.cur)不包含在内。
A. System.in
B. System.out
C. System.err
D. System.cur
11. 在Java中将信息的输入与输出过程抽象为输入/输出流。输入是指数据流入程序,输出是指数据从程序流出。(对)
A. 对
B. 错
12. 向文本文件中写入字符数据,在任何时候都只需要用到文件写入器类(FileWriter),不需要用到缓冲写入器类(BufferedWriter)。(错)
A. 对
B. 错
13. FileWriter和FileWriter类的构造函数的参数都需要一个文本文件名。(对)
A. 对
B. 错
14. 在对文件进行的输入/输出(I/O)方法的调用中,当遇到错误时通常会抛出一个IOException异常。(对)
A. 对
B. 错
15. 当一个方法进行文件访问操作可能生成一个IOException异常时,该方法必须在方法头声明抛出该异常,别无其他选择。(错)
A. 对
B. 错
16. 输入流类(InputStream)和输出流类(OutputStream)是用来处理字节流的抽象基类。(对)
A. 对
B. 错
17. Java.io包中的OutputStream及其子类专门用于把字节数据写入二进制数据文件中。(对)
A. 对
B. 错
18. 文件输出流类(FileOutputStream)和数据输出流类(DataOutputStream)不是OutputStream类的子类。(错)
A. 对
B. 错
19. DataOutputStream类的文件流能够把各种基本类型的数据写入到二进制数据文件中。(对)
A. 对
B. 错
20. java.io包中提供的ObjectOutputStream类能够把对象信息存储到文件中。(对)
A. 对
B. 错
21. public class XXK2 {
private final int a;
public XXK2(int a) {this.a=a;}
public int f1(int x) {
if(x%2==1) return 2*(a+x);
else return 3*a+x;
}
public int get() {return a;}
public static void main(String[] args) {
XXK2 x=new XXK2(8);
int y=x.f1(20);
y+=x.get();
System.out.println(“y=”+y);
}
}
A. y =52
B. y =62
答案:(y =52)
22. public class XXK2 {
private int a; public XXK2(int aa) {a=aa;}
public int f1(int x) {
if(x%2==1) return 2*(a+x);
else return 3*a+x;
}
public int get() {return a;}
public static void main(String[] args) {
XXK2 x=new XXK2(5);
int y=x.f1(9);
y+=x.get()*x.get();
System.out.println(“y=”+y);
}
}
A. y =53
B. y =62
答案:(y =53)
23. public class XXK2 {
private int a;
public XXK2() {a=3;}
public XXK2(int aa) {a=aa;}
public double f1() {
return 2*Math.pow(a,3)+a;
}
public static void main(String[] args) {
XXK2 x=new XXK2(), y=new XXK2(5);
System.out.println(x.f1()+”, “+y.f1());
}
}
A. 67.0, 255.0
B. 57.0, 255.0
答案:(57.0, 255.0)
24. class Rectangle {
private int a,b;
public Rectangle(int aa, int bb) {a=aa; b=bb;}
public int area() {return a*b;}
public int girth() {return 2*(a+b);}
}

public class XXK3 extends Rectangle {
private int c;
public XXK3(int aa, int bb, int cc) {super(aa,bb); c=cc;}
public int volume() {return area()*c;}
public int arrisLength() {return 2*girth()+4*c;}

public static void main(String[] args) {
XXK3 x=new XXK3(2,3,4);
int y1=x.volume();
int y2=x.arrisLength();
System.out.println(y1+”, “+y2);
}
}
A. 34, 36
B. 24, 36
答案:(24, 36)
25. public class SetTest {
public static void main(String[] args) {
HashSet hs = new HashSet();
boolean b1 = hs.add(“a”);
hs.add(“b”);
hs.add(“c”);
hs.add(“d”);
hs.add(“d”);
boolean b2 = hs.add(“a”);
System.out.println(“size=”+hs.size());
}
}
A. size=5
B. size=4
答案:(size=4)

资源下载
下载价格3
点点赞赏,手留余香 给TA打赏

评论0

请先
  • u******* 签到打卡,获得1元奖励
  • 游客 下载了资源 国开学习网《水利水电工程造价管理》形考作业3答案
  • 1******* 投稿收入增加1.5块钱
  • 游客 购买了资源 国开学习网《水利水电工程造价管理》形考作业3答案
  • u******* 购买了资源 云南开放大学创新创业能力培养离线作业 撰写创业计划书
  • a******* 投稿收入增加3.5块钱
  • u******* 加入了本站
  • l*****p 下载了资源 国开电大《计算机组网技术》形考任务四实训-小型校园网网络解决方案的设计与实施
  • l*****p 购买了资源 国开电大《计算机组网技术》形考任务四实训-小型校园网网络解决方案的设计与实施
  • a******* 投稿收入增加2.5块钱
  • l*****p 下载了资源 国开电大《计算机组网技术》形考任务三实训-咖啡店无线上网
  • l*****p 购买了资源 国开电大《计算机组网技术》形考任务三实训-咖啡店无线上网
  • a******* 投稿收入增加2.5块钱
  • l*****p 加入了本站
  • u******* 下载了资源 国开学习网《会计实务专题》形考作业四答案
  • 1******* 投稿收入增加2.5块钱
点击浏览器地址栏的⭐图标收藏本页
国开电大期末考试精准答案,原原本本的一题一题复刻,不需要自己一题一题找的那种,需要扫码加微信(也兼代写作业)
显示验证码

社交账号快速登录

微信扫一扫关注
扫码关注后会自动登录