當前位置:才華齋>IT認證>JAVA認證>

2016年Java考試精選程式閱讀題

JAVA認證 閱讀(2.86W)

  1.寫出以下程式的執行結果。

2016年Java考試精選程式閱讀題

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