阅读下面程序classex31{publicstaticvoidmain(String[]args){intx=60;inty,z;if(x>50){y=10;}z=y+x;}}现在想先编译再运行该程序,结果是()
A.70
B.60
C.编译出错
D.运行出错
A.70
B.60
C.编译出错
D.运行出错
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()
在下面程序的空白处,应填入的正确选项是 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
下面程序中错误之处是 ______。
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
}
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.编译不通过
下面程序的功能是将一个整数数组写入二进制文件。在下画线处应填入的选项是 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
在Visual FoxPr0程序中不需要用PUBl,IC等命令明确声明和建立,可直接使用的内存变量是()。
A.局部变量
B.私有变量
C.公共变量
D.全局变量
public class A { public void draw(){System.out.println(“NO?”)}};} class B extends A { public void draw(){ System.out.println(“YES!”)};} A a=new B(); a.draw(); 输出结果是__________,最后两条语句程序体现了java的__________性质。
写出程序的输出结果
public abstract class A
{
public A()
{
Console.WriteLine('A');
}
public virtual void Fun()
{
Console.WriteLine("A.Fun()");
}
}
public class B: A
{
public B()
{
Console.WriteLine('B');
}
public new void Fun()
{
Console.WriteLine("B.Fun()");
}
public static void Main()
{
A a = new B();
a.Fun();
}
}
有如下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } };
A.2
B.5
C.7
D.3
对下列程序的叙述中,正确的是
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.程序正常运行
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!