1.寫出以下程序的執行結果。
class First {
First( ) {
tln ("in First"); } }
public class Second extends First { Second( ) {
tln("in Second"); } public static void main(String[] args) { Second mine= new Second( ); } }
程序執行的'結果:
in First in Second
2.解釋程序中語句的含義
純文字檔案中的內容是 abcd
下面的程序將檔案中的內容寫到檔案中和屏幕上 import .*;
public class filecopy {
public static void main(String[] args) { try {
StringBuffer str=new StringBuffer( );
FileInputStream fin=new FileInputStream("");
意義
FileOutputStream fout=new FileOutputStream("");
意義
int c;
while((c=( ))!=-1) {
e(c); 意義
nd((char)c); 意義
}
e( ); e( );
String str2=ring( );
tln(str2); 顯示的結果是
}catch(Exception c) {
tln(c); } } }
實例化輸入流對象,指定輸入流來源檔案爲 實例化輸出流對象,指定輸出流目標檔案爲 將C寫入到輸出流對象中
將整數C轉化爲字元,並添加到字元串str的尾部 abcd