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

      自考

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

      排行熱點(diǎn)

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

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

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

      36.閱讀下列程序,請回答以下問題:

      (1)程序要求在文本框text中輸入的內(nèi)容是什么?

      (2)程序采用什么輸入方式下載網(wǎng)絡(luò)文件?

      import java.net.*; import java.awt.*;

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

      public class Test36{

      public static void main(String args[]){

      new ConnectNet("讀取網(wǎng)絡(luò)文本文件示意程序");

      }

      }

      class ConnectNet extends JFrame implements ActionListener{

      JTextField text = new JTextField(30);

      JTextArea showArea=new JTextArea();

      JButton b= new JButton("下載"); JPanel p= new JPanel();

      ConnectNet(String s){

      super(s);Container con = this.getContentPane();

      p.add(text); p.add(b);

      JScrollPane jsp = new JScrollPane(showArea);

      b.addActionListener(this);

      con.add(p,"North"); con.add(jsp, "Center");

      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      setSize(500, 400); setVisible(true);

      }

      public void actionPerformed(ActionEvent e){

      String urlName=text.getText();

      try{ URL url: new URL(urlName);∥由網(wǎng)址創(chuàng)建URL對象

      URLConnection tc =url.openConnection();∥獲得URLConnection對象

      tc.connect();∥設(shè)置網(wǎng)絡(luò)連接

      InputStreamReader in =

      new InputStreamReader(tc.getInputStream());

      BufferedReader dis = new BufferedReader(in);

      String inLine;

      while((inLine=dis.readLine())!=null){

      showArea.append(inLine+"");

      }

      dis.close();

      } catch (MalformedURLException e2){e2.printStackTrace();}

      catch(IOException e3){ e3.printStackTrace();}

      }

      }

      六、程序設(shè)計(jì)題(本大題共2小題,每小題6分,共1 2分)

       
      37.編寫方法int[] arrayReverse(int[]a),該方法的功能是返回一個(gè)新的數(shù)組b,新數(shù)組的 元素排列順序與參數(shù)數(shù)組的元素排列順序相反。

      38.類InputData是用于輸入考生考號、課程和成績的窗口,

      窗口的界面如右圖所示,其中三個(gè)文本框用來輸入考號、課

      程和成績。

      注:這里是給定程序的部分代碼,你要編寫的是完成該類的構(gòu)

      造方法。

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

      import java.awt.event.*;

      public class InputData extends JFrame implements ActionListener{

      JTextField noText, markText, courseText;

      JButton ok=new JButton("確 定");

      public static int no, mark;∥讓創(chuàng)建者直接獲取考號和成績

      public static String course;∥讓創(chuàng)建者直接獲取課程名稱

      InputData(){

      super("成績輸入窗");

      Container con = getContentPane();

      con.setLayout(new GridLayout(4, 1));

      noText = new JTextField(12);

      courseText = new JTextField(12);

      markText = new JTextField(12);

      ∥請?jiān)诖痤}紙相應(yīng)位置編寫代碼

      con.add(ok); ok.addActionListener(this);

      con.setSize(250, 70); setVisible(true); pack();

      }

      public void actionPerformed(ActionEvent e) {

      if (e.getSource() = ok) { ∥讀取考號和成績

      no = Integer.parseInt(noText.getText());

      course = courseText.getText();

      mark = Integer.parseInt(markText.getText());

      setVisible(false); dispose();

      }

      }

      public static void main(String[] args) {

      new InputData();

      }

      }

      首頁 1 2 3 4 5 尾頁
      責(zé)編:wuhuirong