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