java程序程序试题_2016年Java考试精选程序阅读题

2016年Java考试精选程序阅读题

1.写出以下程序的运行结果。

class First {

First(  ) {

System.out.println ("in First"); } }

public class Second extends First { Second(  ) {

System.out.println("in Second"); } public static void main(String[] args) { Second mine= new Second(  ); } }

程序运行的结果:

in First in Second

2.解释程序中语句的含义

纯文本文件f1.txt中的.内容是 abcd

下面的程序将f1.txt文件中的内容写到f2.txt文件中和屏幕上 import java.io.*;

public class filecopy {

public static void main(String[] args) { try {

StringBuffer str=new StringBuffer(  );

FileInputStream fin=new FileInputStream("f1.txt");

意义

FileOutputStream fout=new FileOutputStream("f2.txt");

意义

int c;

while((c=fin.read(  ))!=-1) {

fout.write(c); 意义

str.append((char)c); 意义

}

fin.close(  ); fout.close(  );

String str2=str.toString(  );

System.out.println(str2); 显示的结果是

}catch(Exception c) {

System.out.println(c); } } }

将整数C转化为字符,并添加到字符串str的尾部 abcd

【2016年Java考试精选程序阅读题】相关文章:

2016年Java考试精选程序阅读题 1.写出以下程序的运行结果。 class First { First(  ) { System.out.println ("in First"); } } public class Second extends First { Second(  ) { System.out.println("in Second"); } public static void main(String[] args) { Second mine= new Second(  ); } } 程序运行的结果: in First in Second 2.解释程序中语句的含义 纯文本文件f1.txt中的.内容是 abcd 下面的程序将f1.txt文件中的内容写到f2.txt文件中和屏幕上 import java.io.*; public class filecopy { public static void main(String[] args) { try { StringBuffer str=new StringBuffer(  ); FileInputStream fin=new FileInputStream("f1.txt"); 意义 FileOutputStream fout=new FileOutputStream("f2.txt"); 意义 int c; while((c=fin.read(  ))!=-1) { fout.write(c); 意义 str.append((char)c); 意义 } fin.close(  ); fout.close(  ); String str2=str.toString(  ); System.out.println(str2); 显示的结果是 }catch(Exception c) { System.out.println(c); } } } 将整数C转化为字符,并添加到字符串str的尾部 abcd 【2016年Java考试精选程序阅读题】相关文章:
经验分享 程序员 微信小程序 职场和发展