当前位置: 首页 > 所有资源 > 《面向对象程序设计》资源 > 电大资源网1008《面向对象程序设计》形考任务4答案(课程号:02372)

电大资源网1008《面向对象程序设计》形考任务4答案(课程号:02372)2025年春

最近更新:2020-10-26
761

 

下面()既可以作为流的数据源,又可以作为流的目的地。

进行文件输入输出操作时,最常用的系统包是()。

Java中有3个标准输入/输出流,下面的()不包含在内。

在读字符文件Employee.dat时,使用该文件作为参数的类是()。

下列不是InputStream子类的是()。

下列哪个类不是异常类的父类?()。

下面的关键字()与异常处理无关。

下面的异常()为数组下标越界异常。

下面()既可以作为流的数据源,又可以作为流的目的地。

Java中有3个标准输入/输出流,下面的()不包含在内。

Java中将信息的输入与输出过程抽象为输入/输出流。输入是指数据流入程序,输出是指数据从程序流出。

向文本文件中写入字符数据,在任何时候都只需要用到文件写入器类(FileWriter),不需要用到缓冲写入器类(BufferedWriter)

FileWriterFileWriter类的构造函数的参数都需要一个文本文件名。

在对文件进行的输入/输出(I/O)方法的调用中,当遇到错误时通常会抛出一个IOException异常。

当一个方法进行文件访问操作可能生成一个IOException异常时,该方法必须在方法头声明抛出该异常,别无其他选择。

输入流类(InputStream)和输出流类(OutputStream)是用来处理字节流的抽象基类。

JavA.io包中的OutputStream及其子类专门用于把字节数据写入二进制数据文件中。

文件输出流类(FileOutputStream)和数据输出流类(DataOutputStream)不是OutputStream类的子类。

DataOutputStream类的文件流能够把各种基本类型的数据写入到二进制数据文件中。

javA.io包中提供的ObjectOutputStream类能够把对象信息存储到文件中。

"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);

}

}

"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);

}

}

"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());

}

}

"class Rectangle {

private int a,b;

public Rectangle(int aa, int bb) {a=aa; b=bb;} p

ublic 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);

}

}

"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());

}

}

 

下载地址1
3积分
下载附件

重要提示:本站不支持微信或苹果手机充值及下载,为了避免下载出错,请用电脑访问下载资源