全國(guó)2011年10月自學(xué)考試Java語(yǔ)言程序設(shè)計(jì)(一)試題及答案(共9頁(yè))_第1頁(yè)
全國(guó)2011年10月自學(xué)考試Java語(yǔ)言程序設(shè)計(jì)(一)試題及答案(共9頁(yè))_第2頁(yè)
全國(guó)2011年10月自學(xué)考試Java語(yǔ)言程序設(shè)計(jì)(一)試題及答案(共9頁(yè))_第3頁(yè)
全國(guó)2011年10月自學(xué)考試Java語(yǔ)言程序設(shè)計(jì)(一)試題及答案(共9頁(yè))_第4頁(yè)
全國(guó)2011年10月自學(xué)考試Java語(yǔ)言程序設(shè)計(jì)(一)試題及答案(共9頁(yè))_第5頁(yè)
已閱讀5頁(yè),還剩4頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上全國(guó)2011年10月自學(xué)考試Java語(yǔ)言程序設(shè)計(jì)(一)試題課程代碼:04747一、單項(xiàng)選擇題(本大題共10小題,每小題1分,共1O分) 在每小題列出的四個(gè)備選項(xiàng)中只有一個(gè)是符合題目要求的,請(qǐng)將其代碼填寫(xiě)在題后的括號(hào)內(nèi)。錯(cuò)選、多選或未 選均無(wú)分。1下面供選字符序列中,不屬于Java語(yǔ)言關(guān)鍵字的是 ( )A. throw B. synchronizedC. protect D. try2以下程序代碼的輸出的結(jié)果是 ( )double x = 25.6;System.out.println(int)x << 1);A. 48 B. 50C. 51 D. 523在

2、以下供選擇的概念中,不屬于面向?qū)ο笳Z(yǔ)言概念的是 ( ) A類 B.函數(shù) C動(dòng)態(tài)聯(lián)編 D.抽象4在Java語(yǔ)言中,能夠?qū)崿F(xiàn)字符串連接的方法是 ( )A. String substring(int startpoint) B. String concat(String s)C. String replace(char old,char new) D. String trim()5在以下供選擇的容器類中,屬于頂層容器的是 ( ) AJDialog B.JPanel CJScrollPane D.JToolBar6在以下選項(xiàng)中,屬于MouseListener接口的方法是 ( ) AmouseDoubl

3、eClicked(MouseEvent) B.mouseDragged(MouseEvent) CmouseMoved(MouseEvent) D.mousePressed(MouseEvent)7設(shè)已經(jīng)有Graphics2D對(duì)象g2d,Line2D對(duì)象line,繪制對(duì)象line的代碼是( ) Ag2ddraw(1ine) B.g2ddrawLine(1ine) C1inedraw() D.1inedrawLine()8設(shè)Thread對(duì)象thd的優(yōu)先級(jí)為7,thd又創(chuàng)建了另一個(gè)Thread對(duì)象chd,如果未對(duì)chd 的優(yōu)先級(jí)進(jìn)行修改,則chd的優(yōu)先級(jí)為 ( ) A1 B. 5 C7 D. 10

4、9在以下供選擇的操作中, File對(duì)象能夠提供的操作是 ( ) A刪除文件 B.讀寫(xiě)文件 C打開(kāi)文件 D.查詢文件屬性10在編寫(xiě)訪問(wèn)數(shù)據(jù)庫(kù)的Java程序時(shí),Statement對(duì)象的作用是 ( ) A建立新數(shù)據(jù)庫(kù)連接 B.設(shè)置查詢命令 C創(chuàng)建SQL語(yǔ)句對(duì)象 D.存儲(chǔ)查詢結(jié)果二、填空題(本大題共10小題,每小題2分,共20分) 請(qǐng)?jiān)诿啃☆}的空格中填上正確答案。錯(cuò)填、不填均無(wú)分。11Java語(yǔ)言是一種 _ 語(yǔ)言,它約束程序員必須遵守規(guī)定編寫(xiě)程序,能讓編譯器檢測(cè)出程序中盡可能多的錯(cuò)誤。12在Java語(yǔ)言中, _ 語(yǔ)句用于表示出現(xiàn)在該文件中的所有類都屬于這個(gè)程序包。13在Java程序系統(tǒng)中,對(duì)象之間的交

5、互通過(guò)相互發(fā)送 _ 實(shí)現(xiàn)。14數(shù)組每個(gè)元素按存儲(chǔ)順序?qū)?yīng)一個(gè)下標(biāo),下標(biāo)從 _ 開(kāi)始順序編號(hào)。15用Swing編寫(xiě)GUI程序時(shí),通常用 _ 類派生的子類創(chuàng)建窗口對(duì)象。16強(qiáng)制型對(duì)話框強(qiáng)制對(duì)話過(guò)程 _ ,直至對(duì)話過(guò)程結(jié)束,才讓程序響應(yīng)對(duì)話框以外的事件。17在Graphics類中,用于在指定的位置顯示字符串的方法是 _ 。18在Java中,線程的調(diào)度策略采用_,優(yōu)先級(jí)高的線程比優(yōu)先級(jí)低的優(yōu)先執(zhí)行。19字符流數(shù)據(jù)中使用的Unicode字符有_位二進(jìn)制位。20J包中有 _ 類,它的對(duì)象用于存儲(chǔ)IP地址和域名。三、簡(jiǎn)答題(本大題共6小題,每小題3分,共18分)21請(qǐng)使用for循環(huán)語(yǔ)句實(shí)現(xiàn)計(jì)算的值。22請(qǐng)寫(xiě)

6、出Java語(yǔ)言中編寫(xiě)事件處理程序的兩種方案。23.請(qǐng)寫(xiě)出代碼段,用來(lái)創(chuàng)建一個(gè)標(biāo)簽對(duì)象lbl,顯示文字為“Java”,背景色設(shè)為綠色。24請(qǐng)寫(xiě)出JComboBox對(duì)象上可能發(fā)生的兩種事件類型的名字。25請(qǐng)寫(xiě)出線程從阻塞狀態(tài)恢復(fù)到就緒狀態(tài)的三種途徑。26請(qǐng)寫(xiě)出URIConnection類提供的獲得輸入輸出流對(duì)象的方法和實(shí)現(xiàn)網(wǎng)絡(luò)連接的方法。四、程序填空題(本大題共5小題,每空2分,共20分)27. 方法 void moveOddForward(int a)的功能是將數(shù)組中的所有奇數(shù)移到所有偶數(shù)之前。void moveOddForward(int a) for(int i=0,odd=0;_;i+)

7、if(_) int t=ai;ai=aodd;aodd=t;odd+;28以下程序片段定義由JFrame類派生的子類MyWindowDemo。類MyWindowDemo 的構(gòu)造方法有五個(gè)參數(shù):窗口的標(biāo)題名,加入窗口的按鈕,按鈕的背景顏色,以及窗口的寬和高。class MyWindowDemo extends JFrame public MyWindowDemo(String name, JButton button, Color c, int w, int h)setTitle(name); setSize(w, h);Container contentPane =_; contentPane

8、. _;button.setBackground(c);29小應(yīng)用程序有一個(gè)按鈕和一個(gè)文本區(qū),按鈕作為發(fā)生鍵盤(pán)事件的事件源,并對(duì)鍵盤(pán) 事件實(shí)施監(jiān)視。程序運(yùn)行時(shí),先點(diǎn)擊按鈕,讓按鈕激活。以后輸入英文字母時(shí),在 文本區(qū)顯示輸入的字母。import java.applet.*;import javax.swing.*;import java.awt.event.*;public class Test29 extends Applet implements _ JButton button = new JButton(); JTextArea text = new JTextArea(5, 20);

9、public void init()button.addKeyListener(this); add(button); add(text); public void keyPressed(KeyEvent e)int t = e. _ ;if(t>= KeyEvent.VK_A &&t<= KeyEvent.VK_Z)text.append(char)t+" "); public void keyTyped(KeyEvent e) public void keyReleased(KeyEvent e) 30以下程序的界面有一個(gè)文本區(qū)text,一個(gè)

10、按鈕button。程序運(yùn)行時(shí),單擊按鈕,則 將文本區(qū)中的內(nèi)容輸出到out,其中out為BufferWriter類的一個(gè)對(duì)象。public void actionPerformed(ActionEvent e) String s; if(e._= button) try out. _(text.getText(),0,(text.getText().length(); out. flush(); text.setText(null); System.exit(0); catch(IOException exp) text.setText("文件定出錯(cuò)! n"); System

11、.exit(-1); 31數(shù)據(jù)庫(kù)連接方法connectByJdbcOdbc()按給定的數(shù)據(jù)庫(kù)URL、用戶名和密碼連接數(shù) 據(jù)庫(kù),如果連接成功,方法返回連接對(duì)象,連接不成功,則返回空。public static Connection connectByJdbcOdbc(String url, String usemame, String password) Connection con = null; try Class. _("sun.jdbc.odbc.JdbcOdbcDriver"); catch (Exception e) e.printStackTrace(); re

12、turn null; try con =_.getConnection(url, usemame, password); catch (SQLException e) e.printStackTrace(); return null; return con; 五、程序分析題(本大題共5小題,每小題4分,共20分)32閱讀下列程序,請(qǐng)寫(xiě)出該程序的輸出結(jié)果。class Test32a String name; int age; long number; Test32a(long number, String name,int age) System.out.println("Name:

13、"+name); System. out. println("Age: "+age); System.out.println("Tel: " +number); class Test32b extends Test32a Test32b(long number, String name,int age,boolean b) super(number, name,age); System.out.println("Married: "+b); public class Test32 public static void mai

14、n(String args) Test32b abe=new Test32b(4747,"Tony",29,true); 33閱讀下列程序,請(qǐng)寫(xiě)出該程序的輸出結(jié)果。class Test33 String myString = "1" public static void main(String args) Test33 myObj = new Test33(); myObj.stringModifier(myObj.myString); System.out.println(" "+ myObj.myString); void str

15、ingModifier(String theString) theString = theString + "2" System.out.print(theString); 34閱讀下列程序,請(qǐng)寫(xiě)出該程序的功能。import java.awt.*; import java.awt.event.*; import java.applet.*;public class Test34 extends Applet implements ActionListener String msg = "" Button bList = new Button3;publi

16、c void init() Button yes = new Button("Yes"); Button no = new Button("No"); Button maybe = new Button("Undecided"); bList0 = (Button) add(yes); bList 1 = (Button) add(no); bList2 = (Button) add(maybe); for(inti= 0;i < 3; i+) bListi.addActionListener(this); public voi

17、d actionPerformed(ActionEvent ae) for(int i = 0;i < 3; i+) if(ae.getSource() = bListi) msg = "You pressed "+ bListi.getLabel(); repaint(); public void paint(Graphics g) g.drawString(msg, 6, 100); 35閱讀下列程序,請(qǐng)寫(xiě)出該程序的功能。import java.awt.event.*; import javax.swing.*; import java.awt.*;public

18、class MenuWindow extends JFrame implements ActionListener JTextField text = new JTextField(); JMenuBar menuBar; JMenu menuFruits; JMenultem menultem1,menultem2,menultem3; public MenuWindow() menuBar = new JMenuBar(); setJMenuBar(menuBar); menuFruits = new JMenu("水果"); menuBar.add(menuFruit

19、s); menultem 1 = new JMenultem("蘋(píng)果"); menultem1 .addActionListener(this); menuFruits.add(menultem1 ); menultem2 = new JMenultem("桔子"); menultem2.addActionListener(this); menuFruits.add(menultem2); menuFruits.addSeparator(); menultem3 = new JMenultem("退出"); menultem3.add

20、ActionListener(this); menuFruits.add(menultem3); Container con = getContentPane(); con.add(text); setSize(200,150); setVisible(true); public void actionPerformed(ActionEvent e) if (e.getActionCommand() = "退出") System.exit(0); else text.setText(e.getActionCommand(); public static void main(

21、String args) MenuWindow mw = new MenuWindow();36閱讀下列程序,請(qǐng)寫(xiě)出該程序的輸出結(jié)果。class MyThread extends Thread String message; int s; MyThread(String message, int sec) this.message = message; s = sec; public void run( ) try sleep(s); catch(InterruptedException e) System.out.println(message+" "+getPriority( ); class ThreadTest public static void main(String args) Thread foo = new MyThread("Foo", 1000); foo.setPriority(Thread.MIN_PRIORITY); foo.start( ); Thread bar = new My

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論