华南俳烁实业有限公司

自考

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

排行熱點(diǎn)

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

全國2013年10月自考《Java語言程序設(shè)計(jì)(一)》真題_第6頁

來源:考試網(wǎng) [ 2014年3月24日 ] 【大 中 小】
36.閱讀下列程序,請寫出該程序的功能。
 import java.io.*;
 class Test36{
     public static void main(Stringarg[]){
         int ch;
         try{
            FileReader in=new FileReader(new File("file 1.txt"));
            FileWriter out=new FileWriter(new File("file2.txt"));
            while((ch=in.read())!=-1){
                if(ch>=(int)′A′&&ch<=(int) ′Z′)
                   ch+=32;
                else if(ch>=(int) ′a′&& ch<=(ira) ′z′)
                   ch-=32;
                out.write(ch);
            }
           in.close();             out.close();
        }catch (FileNotFoundException e1){
             System.out.println("文件沒有找到! "+e1);
        }catch(IOException e2){
             System.out.println("文件讀寫出錯(cuò)! "+e2);
        }
        System.out.println("程序結(jié)束! "’);
     }
 }
六、程序設(shè)計(jì)題(本大題共2小題,每小題6分,共12分)
37.編寫方法int[][]transpose(int[][]a),方法將生成并返回一個(gè)新數(shù)組b,該數(shù)組為a的轉(zhuǎn)置數(shù)組。
注:數(shù)組轉(zhuǎn)置指的是將數(shù)組的行、列內(nèi)容互換。
38.以下程序界面有一個(gè)標(biāo)以“OK”的按鈕bt、一個(gè)文本區(qū)ta和一個(gè)文本框tf。當(dāng)在文本框中輸入內(nèi)容完畢后,點(diǎn)擊“OK”按鈕可以使文本框內(nèi)的字符串添加到文本區(qū)中,并輸出文字“因點(diǎn)擊按鈕而引發(fā)添加”;或者按回車鍵使得文本框內(nèi)的字符串添加到文本區(qū)中,并輸出文字“因在文本框里回車而引發(fā)添加”。
注:這里是給定程序的部分代碼,你要編寫的是actionPerformed(ActionEvent e)方法。
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.*;
 public class Test38 extends JFrame implements ActionListener{
          JButton bt=new JButton("OK");
          JTeXtField tf=new JTextField(20);
          JTextArea ta=new JTextArea(10,20);
          public Test38()    {
             Container c=getContentPane();
             c.setLayout(new FlowLayout());  //指定布局方式為順序布局
             c.add(ta);
             c.add(bt);
             c.add(tf);
             bt.addActionListener(this);
             tf.addActionListener(this);
             setSize(400,300);
             setVisible(true);
         }
         public void actionPerformed(ActionEvent e)     {
         //請?jiān)凇按痤}紙’’上編寫以下代碼
 
         }
         public static void main(String args[])   {
             new Test38();
        }
 }

首頁 1 2 3 4 5 6 尾頁
責(zé)編:abcwuli1234
句容市| 兴山县| 通化县| 门头沟区| 密云县| 巴南区| 利津县| 大宁县| 岐山县| 固安县| 兴海县| 平遥县| 揭阳市| 远安县| 施秉县| 呼伦贝尔市| 沧州市| 梓潼县| 宁蒗| 巴彦淖尔市| 山阳县| 屏边| 吴江市| 九台市| 吐鲁番市| 哈巴河县| 鄯善县| 梧州市| 南城县| 宝清县| 合作市| 新蔡县| 法库县| 石渠县| 汝阳县| 宁远县| 江口县| 宁南县| 青龙| 合水县| 潼关县|