题目内容

//把几个JAVA类型的数据写到一个文件,并读取出来。importjava.io.*;publicclassDataInAndOutStream{publicstaticvoidmain(String args[]){try{ FileOutputStream fos=newFileOutputStream("DataOut.dat");(1)out_data.writeInt(156);out_data.writeLong(987654L);out_data.writeFloat(3.14f);out_data.writeDouble(92521.14);out_data.writeBoolean(true);out_data.writeUTF("JAVA语言真奇妙!");out_data.writeByte(123);out_data.writeChars("I am ok");}catch(IOException e){}try{ (2)DataInputStream in_data=newDataInputStream(fis);(3)//读取long整数System.out.println(":"+in_data.readLong());//读取第1个float数System.out.println(":"+in_data.readFloat());//读取第1个double数System.out.println(":"+_(4) );//读取第1个boolean值System.out.println(":"+in_data.readBoolean());//读取第1个UTF值System.out.println(":"+in_data.readUTF());//读取第1个Byte数System.out.println(":"+in_data.readByte());charc;while((5)_) //'\0'表示空字符System.out.print(c);}catch(IOException e){}}}

查看答案
更多问题

写出下列程序段的运行结果public class Test{public static void main(String[]args){int x;int a[]={0,0,0,0,0,0};calculate(a,a[5]);System.out.println("the value of a[0] is "+a[0]);System.out.println("the value is a[5] is "+a[5]);}static int calculate(int x[],int y){for(int i=1;i

写出下列程序段的运行结果classA{doublef(doublex,doubley){returnx*y;}}classBextendsA{doublef(doublex,doubley){returnx+y;}}publicclassTest{publicstaticvoidmain(Stringargs[]){Bobj=newB();System.out.println("Theprogramoutputis"+obj.f(4,6));}}

写出下列程序段的运行结果publicclassUnchecked{publicstaticvoidmain(String[]args){try{method();}catch(Exceptione){System.out.println("A");}finally{System.out.println("B");}}staticvoidmethod(){try{wrench();System.out.println("C");}catch(ArithmeticExceptione){System.out.println("D");}finally{System.out.println("E");}System.out.println("F");}staticvoidwrench(){thrownewNullPointerException();}}

写出下列程序段的运行结果class father{void speak(){System.out.println("I am father!");}}public class son extends father{void speak(){super.speak();System.out.println("I am son!");}public static void main(String args[]){son cxz=new son();cxz.speak();}}

答案查题题库