亚洲欧洲国产欧美一区精品,激情五月亚洲色五月,最新精品国偷自产在线婷婷,欧美婷婷丁香五月天社区

      自考

      各地資訊
      當(dāng)前位置:考試網(wǎng) >> 自學(xué)考試 >> 自考真題 >> 工學(xué)類 >> Java 語(yǔ)言程序設(shè)計(jì)(一) >> 文章內(nèi)容

      排行熱點(diǎn)

      • 歷年真題
      • 模擬試題
      • 自考自答

      全國(guó)2014年4月高等教育自學(xué)考試Java語(yǔ)言程序設(shè)計(jì)(一)試題_第4頁(yè)

      來(lái)源:考試網(wǎng) [ 2014年7月7日 ] 【大 中 小】

      31.某個(gè)緩沖式輸出的示意程序的界面有一個(gè)文本框fileOut和一個(gè)文本區(qū)text,程序運(yùn) 行時(shí),先在文本區(qū)中輸入要存入文件的內(nèi)容,接著在文本框中輸入文件名并回車, 則程序?qū)⑽谋緟^(qū)中的內(nèi)容保存到指定的文件中。以下是該程序中相應(yīng)文本框文件名 的輸入事件的方法。

      public void actionPerformed(ActionEvent e){

      if (e.getSource()==fileOut){

      try{

      out = new BufferedWriter(new ______ );

      out.______ ;

      out.flush(); out.close(); text.setText(null);

      } catch (FileNotFoundException el){

      System.out.print("文件沒(méi)有找到!\n");

      }catch (IOException exp){

      System.out.print("文件讀寫出錯(cuò)!\n");

      }

      }

      }

      五、程序分析題(本大題共5小題,每小題4分,共20分)

      32.閱讀下列程序,請(qǐng)寫出該程序的輸出結(jié)果。

      class Mother{

      public voicl methodl(){

      System.out.println("Call Mother's methodl()");

      }

      public void method2(){

      System.out.println("Call Mother's method2()"); methodl();

      }

      }

      class Girl extends Mother{

      public void methodl(){

      System.out.println("Call Girl's methodl()");

      }

      public static void main(String args[]){

      Girl g= new Girl(); g.method2();

      }

      }

      33.閱讀下列程序,請(qǐng)寫出調(diào)用Test33(4)的輸出結(jié)果。

      public static void Test33(int n){

      int i,j,a[][]=new int[n][n];

      for(i=0;i

      if(i%2==0)

      for(j=0;j

      a[i][j]=j+1;

      else for (j=n-l;j>=0;j--)

      a[i][j]=n-j;

      }

      for(i=0;i

      for(j=0;j

      System.out.print("t"+ a[i][j]);

      System.out.println();

      }

      }

      34.閱讀下列程序,請(qǐng)回答以下問(wèn)題:

      (1)在文本框中輸入1 7,在文本區(qū)中會(huì)顯示多少行整數(shù),各行有幾個(gè)數(shù)?

      (2)如果將程序的第一行刪除,程序中標(biāo)號(hào)①~⑨語(yǔ)句中哪些會(huì)出現(xiàn)錯(cuò)誤?

      import java.awt.*;∥問(wèn)題(2)所指要?jiǎng)h除的行

      import javax.swing.*;

      import java.awt.event.*;

      public class Test34 extends JFrame implements ActionListener{

      JTextField textF; JTextArea textA;

      Test34(){

      Container con = getContentPane(); ∥①

      con.setLayout(new BorderLayout()); ∥②

      textF = new JTextField(10); ∥③

      textF.addActionListener(this); ∥④

      textA = new JTextArea(6, 10); ∥⑤

      setSize(240, 200); ∥⑥

      con.add(textF, "North"); ∥⑦

      con.add(textA, "Center"); ∥⑧

      setVisible(true); ∥⑨

      public static void main(String[] args){

      new Test34();

      }

      public voicl actionPerformed(ActionEvent e){

      int n,d;

      if(e.getSource()==textF){

      n = Integer.parseInt(textF.getText());

      for (int k=1;k<=n; k++){

      d= (int) (Math.ranclom()*1000 % 1000);

      textA.append(" "+d);

      if(k%5==0)textA.append("");

      }

      }

      }

      }

      35.閱讀下列程序,請(qǐng)回答以下問(wèn)題:

      (1)程序運(yùn)行時(shí),呈現(xiàn)的界面中菜單條有哪些菜單?

      (2)程序中帶注釋/*1*/的代碼行的作用是什么?

      import javax.swing.*;import java.awt.*;import java.awt.event.*;

      class MenuWindow extends JFrame implements ActionListener{

      JTextField text;

      MenuWindow (String s,String menuList[][]){

      setTitle(s);

      Container con = this.getContentPane();

      con.setLayout(new BorderLayout());

      this.setLocation(100, 100); this.setSize(300, 100);

      JMenuBar menubar=new JMenuBar();

      for(int i=0;i< menuList.length; i++){

      JMenu menu = new JMenu(menuList[i][0]);

      for(int j=1;j

      JMenuItem anItem=new JMlenuItem(menuList[i][j]);

      /*1*/ anItem.setActionCommand(menuList[i][j]);

      anItem.addActionListener(this); menu.add(anItem);

      }

      menubar.add(menu);

      }

      text = new JTextField(); setjMenuBar(menubar);

      con.add(text,BorderLayout.SOUTH);

      }

      public void actionPerformed(ActionEvent e){

      text.setText("<"+e.getActionCommand()+">菜單項(xiàng)被選中!");

      }

      }

      public class Test35{

      public static void main(String[] args){

      MenuWindow window;

      String menuList[][]={{"體育","跑步","打籃球","打乒乓"},

      {"娛樂(lè)","唱歌","跳舞"},

      {"學(xué)習(xí)","數(shù)學(xué)","語(yǔ)文"}};

      window=new MenuWindow("菜單示例程序",menuList);

      window.setVisible(true);

      }

      }

      責(zé)編:wuhuirong