题目
A.程序可以通过编译并正常运行,结果输出“0false”
B.程序可以通过编译并正常运行,结果输出“1true”
C.程序无法通过编译
D.程序可以通过编译,但无法正常运行
第1题
在下面程序的空白处,应填入的正确选项是 import java.io.*; public class ObjectStreamTest { public static void main(String args[])throws IOExeeption } ObjectoutputStream os=new ObjectOutputStream(new FileOutputStream("serial.bin")); java.util.Date d=new java.util.Date(); oos. ______(d); ObjectInputStream is=new ObjecttInputStream(new FileInputStream("serial.bin")); try{ java.util.Date restoredDate=(java.util.Date)ois.readObject(); System.out.println("read object back from serial.bin file:"+restoredDate); } catch(classNotFoundException cnf) { System.out.println("class not found"); } } }
A.WriterObject
B. write
C.BufferedWriter
D.writerObject
第2题
3下面程序段的输出结果为()。package test;public class ClassA{ int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); }}class ClassB{ int x; void go(int y) { ClassA a=new ClassA(); x=a.y; }}
A.x=10
B.x=20
C.x=6
D.编译不通过
第3题
A.上面程序含有编译错误
B.上面程序在运行时会产生一个运行时异常
C.上面程序会正常运行,但不产生任何输出
D.上面程序输出“1”
第4题
下面程序中错误之处是 ______。
include<iostream.h>
class A{
private:
int xl;
protected:
int x2;
public:
int x3;
};
class B: public A{
private:
int b1;
protected:
int b2;
public:
int b3;
void disp(){cout<<x1<<b2<<end1;} //A
void set(int i){x3=i;} //B
};
void main()
B bb;
bb. a3=10 //C
bb. b3=10 //D
}
第5题
下面程序的功能是将一个整数数组写入二进制文件。在下画线处应填入的选项是 import java.io.*; public class XieShuzu { public static void main(String[] a) { int[]myArray={10,20,30,40}; try { DataoutputStream dos=new DataOutputStream(new FileoutputStream("ints.dat")); for(int i=0;i<myArray.1ength;i++)dos.______(myArray[i]); dos.close(); System.out.println("已经将整数数组写入二进制文件:ints.dat"); } catch(IOException ice) { System.out.println("IO Exception"); } } }
A.writeArray
B.writeByte
C.writeInt
D.writeDouble
第6题
A.不能通过编译,因为类J_Test没有定义无参数的构造方法
B.不能通过编译,因为类J_SubClass没有定义无参数的构造方法
C.不能通过编译,因为没有实现J_SubClass(inti)的构造方法
D.可以成功通过编译
第7题
3阅读下面程序 1 public class Try extends Thread{ 2 public static void main(String args[ ]){ 3 Try t = new Try(); 4 t.start(); 5 } 6 7 public void run(int j){ 8 int i = 0; 9 while(i<5) { 10 System.out.pfintln("祝你成功"); 11 i++; 12 } 13 } 14 } 该程序要求打印5行“祝你成功”必须改正程序中的某行代码,程序才能完成。选择正确的修改是()。
A.将第1行的extends Thread改为implements Runnable
B.将第3行的new Try()改为new Thread()
C.将第4行t.sta.rt()改为start(t)
D.将第7行的publ void run(int j)改为public void run()
第8题
A.a和b指向同一个实例对象,a和c指向同一个实例对象
B.a和b指向同一个实例对象,a和c不指向同一个实例对象
C.a和b不指向同一个实例对象,a和c指向同一个实例对象
D.a和b不指向同一个实例对象,a和c不指向同一个实例对象
第9题
在Visual FoxPr0程序中不需要用PUBl,IC等命令明确声明和建立,可直接使用的内存变量是()。
A.局部变量
B.私有变量
C.公共变量
D.全局变量
第10题
对下列程序的叙述中,正确的是
1:public class X extends Thread implements Runnable{
2:publ主c void run(){
3: System.out.println(“this is run()”);
4:}
5:public static void main(String args〔〕){
6:Threadt二new Thread(new X());
7:t.start();
8:}
9:}
A.第1行会产生编译错误
B.第6行会产生编译错误
C.第6行会产生运行错误
D.程序正常运行
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!