第1题
A.必须由程序员完成对象的清除
B.Java把没有引用的对象作为垃圾收集起来并释放
C.只有当程序中调用System.gc()方法时才能进行垃圾收集
D.Java中的对象都很小,一般不进行删除操作
第2题
A.只有当程序中调用System.gc()方法时才能进行垃圾收集
B.Java中的对象都很小,一般不进行删除操作
C.Java把没有引用的对象作为垃圾收集起来并释放
D.必须由程序员完成对象的清除
第4题
A、Java虚拟机
B、垃圾收集机制
C、三级代码安全检查机制
D、程序员用代码来完成的
第6题
A.程序员必须创建一个线程来释放内存
B.内存回收程序允许程序员直接释放内存
C.内存回收程序负责释放无用内存
D.内存回收程序可以在指定的时间释放内存对象
第7题
注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。程序运行结果如下:
ex3_2: i=123 d=123.456
ex3_2: i=123 d=123.456
import java.io.*;
public class ex3_2 implements Serializable {
private int n3_2;
private double d3_2;
ex3_2() {
n3_2 = 25;
d3_2 = 12.23;
}
public void setDouble(double x) {
d3_2 = x;
}
public void setInt(int x) {
n3_2 = x;
}
public String toString() {
return("ex3_2: i=" + n3_2 + "d=" + d3_2);
}
public static void main(String[] arg) {
ex3_2 e1 = new ex3_2 );
ex3_2 e2;
e1.setInt(123);
e1.setDouble(123.456);
System.out.println(e1);
try {
FileOutputStream fos3_2 = new FileOutputStream("ex3_2.data");
ObjectOutputStream oos3_2 = new ObjectOutputStream(fos3_2);
________________;
} catch(IOException ioe) {
System.out.println(ioe);
}
try {
FileInputStream fis3_2 = new FileInputStream("ex3_2.data");
ObjectInputStream ois3_2 = new ObjectInputStream(fis3_2);
________________;
System.out.println(e2);
}catch(10Exception ioe) {
System.out.println(ioe);
}catch(ClassNotFoundException cnfe) {
System.out.println(cnfe);
}
}
}
第9题
注意:请勿改动main()主方法和其他已有语句内容,仅在横线处填入适当语句。
import java.io.*;
class TheSerial implements Serializable
{
private int intValue;
private double doubleValue;
private String string;
TheSerial()
{
intValue = 123;
doubleValue = 12.34;
string = "Serialize Test";
}
public void setDouble(double d)
{
doubleValue = d;
}
public void setInt(int i)
{
intValue = i;
}
public void setString(String s)
{
string = s;
}
public String toString()
{
return("int="+intValue+"double="+doubleValue+" string="+string);
}
}
public class Example2_3
{
public static void main(String argv[])
{
TheSerial e1 = new TheSerial();
TheSerial e2;
try
{
e1.setInt(Integer.parseInt(argv[0]));
e1.setDouble(Double.parseDouble(argv[1]));
e1.setString[argv[2]);
}
catch(Exception e)
{
e1.setString(e.getMessage{));
}
System.out.println(e1);
try
{
FileOutputStream S = new FileOutputStream("TheSerial.data");
ObjectOutputStream IS = new ObjectOutputStream(oS);
______;
}
catch(IOException ioException)
{
System.out.println(ioException.getMessage());
}
try
{
FileInputStream iS = new FileInputStream("TheSerial. data");
ObjectInputStream IS = new ObjectInputStream(iS);
______
System.out.println(e2);
}
catch(IOException ioException)
{
System.out.println(ioException.getMessage());
}
catch(ClassNotFoundException cnfException)
{
System.out.println(cnfException.getMessage());
}
}
}
第10题
A.Java语言是一种强类型语言,即在编译和运行时进行大量的类型检查,防止不匹配的数据类型的发生
B.Java语言允许使用指针,这一点与C++相似
C.Java语言设计有自动收集垃圾功能,防止了内存分配的错误
D.Java语言使程序员从繁忙的内存管理中解脱出来
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!