freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

java基礎入門_課后習題-資料下載頁

2025-03-24 04:56本頁面
  

【正文】 public static void main(String args[])throws Exception{ int a=4。 BufferedReader br=new BufferedReader(new ())。 (請輸入一個數(shù)字)。 String input= 。 int b=(input)。 if(ba){ int sum=b/a。 (sum)。 }else{ (輸入錯誤)。 } }} 當輸入的數(shù)字是8時,打印輸出的結(jié)果是 。以下是使用FileInputStream類與FileOutputStream類復制文件。閱讀以下代碼,并將空處填寫完整。import .*。class Test2 { public static void main(String[] args) { String file1, file2。 int ch = 0。 file1 = 。 file2 = 。 try { FileInputStream fis = new 。 fos=new FileOutputStream(file2)。 int size= 。 (字節(jié)有效數(shù)、+size)。 while ((ch = ()) != 1) { (ch)。 (ch)。 } ()。 ()。 } catch (IOException e) { (())。 } }}五、簡答題簡述流的概念。Java流被分為字節(jié)流、字符流兩大流類,兩者有什么區(qū)別?簡要說明管道流。六、編程題按照題目需求,編寫程序并運行編寫一個程序,分別使用字節(jié)流和字符流拷貝一個文本文件。 提示:1)使用FileInputStream、FileOutputStream和FileReader、FileWriter分別進行拷貝 2)使用字節(jié)流拷貝時,定義一個1024長度的字節(jié)數(shù)組作為緩沖區(qū),使用字符流拷貝使用使用BufferedReader和BufferedWriter包裝流進行包裝某人在玩游戲的時候輸入密碼123456后成功進入游戲(輸錯5次則被強行退出),要求用程序?qū)崿F(xiàn)密碼驗證的過程。提示:1)。 2)BufferedReader對字符流進行包裝。調(diào)用BufferedReader的readLine()方法每次讀取一行。3)在for循環(huán)判中判斷輸入的密碼是否為“123456”,如果是則打印“恭喜你進入游戲”,并跳出循環(huán),否則繼續(xù)循環(huán)讀取鍵盤輸入。4)當循環(huán)完畢,密碼還不正確,則打印“密碼錯誤,結(jié)束游戲”,(0)方法結(jié)束程序。第9章 GUI(圖形用戶界面)一、填空題 GUI、 適配器 Graphics 事件監(jiān)聽器 JComponent 窗體事件、鍵盤事件、鼠標事件、動作事件 WindowListener、windowClosing(WindowEvent e) 模態(tài)對話框、非模態(tài)對話框 setLayout(null) JMenuBar、JMenu、JMenuItem二、判斷題對 錯 對 錯 錯 三、選擇題D D ABD A D ABCD ABD ABC D C四、程序分析題參考答案extends Stdno = new JTextField()。Name = new JTexxtField()。參考答案(cp)。(jbt)。五、簡答題參考答案l 通過實現(xiàn)XxxListener接口或者繼承XxxAdapter類實現(xiàn)一個事件監(jiān)聽器類,并對處理監(jiān)聽動作的方法進行重寫l 創(chuàng)建事件源對象和事件監(jiān)聽器對象l 調(diào)用事件源的addXxxLisntener()方法,為事件源注冊事件監(jiān)聽器對象參考答案AWT 是Abstract Window ToolKit (抽象窗口工具包)的縮寫,這個工具包提供了一套與本地圖形界面進行交互的接口。AWT 中的圖形函數(shù)與操作系統(tǒng)所提供的圖形函數(shù)之間有著一一對應的關系,當我們利用 AWT 來構件圖形用戶界面的時候,我們實際上是在利用操作系統(tǒng)所提供的圖形庫。由于不同操作系統(tǒng)的圖形庫所提供的功能是不一樣的,在一個平臺上存在的功能在另外一個平臺上則可能不存在。為了實現(xiàn)Java語言所宣稱的一次編譯,到處運行的概念,AWT 不得不通過犧牲功能來實現(xiàn)其平臺無關性,也就是說,AWT 所提供的圖形功能是各種通用型操作系統(tǒng)所提供的圖形功能的交集。由于AWT 是依靠本地方法來實現(xiàn)其功能的,我們通常把AWT控件稱為重量級控件。 Swing 是在AWT的基礎上構建的一套新的圖形界面系統(tǒng),它提供了AWT 所能夠提供的所有功能,并且用純粹的Java代碼對AWT 的功能進行了大幅度的擴充。由于在Swing 中沒有使用本地方法來實現(xiàn)圖形功能,我們通常把Swing控件稱為輕量級控件。 AWT和Swing之間的基本區(qū)別:AWT 是基于本地方法的C/C++程序,其運行速度比較快;Swing是基于AWT 的Java程序,其運行速度比較慢。對于一個嵌入式應用來說,目標平臺的硬件資源往往非常有限,而應用程序的運行速度又是項目中至關重要的因素。在這種矛盾的情況下,簡單而高效的AWT 當然成了嵌入式Java的第一選擇。而在普通的基于PC或者是工作站的標準Java應用中,硬件資源對應用程序所造成的限制往往不是項目中的關鍵因素,所以在標準版的Java中則提倡使用Swing,也就是通過犧牲速度來實現(xiàn)應用程序的功能。 六、編程題參考答案import .*。import .*。import .*。public class MyMouseHandler extends JFrame { public MyMouseHandler() { final JLabel label = new JLabel(此處顯示鼠標右鍵點擊的坐標)。 (true)。 ()。 (label, )。 (300, 200)。 ()。 (new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (() == ) { int x = ()。 int y = ()。 String banner = 鼠標當前點擊位置的坐標是 + x + , + y。 (banner)。 } } })。 (true)。 } public static void main(String[] args) { new MyMouseHandler()。 }}參考答案import .*。import .*。import .*。import .*。public class Information extends JFrame { // 窗口NORTH部的JPanel面板 private JPanel panel = new JPanel()。 // 愛好標簽 private JLabel lb1 = new JLabel(愛好)。 // 三個表示愛好的JCheckBox復選框 private JCheckBox cb1 = new JCheckBox(羽毛球)。 private JCheckBox cb2 = new JCheckBox(乒乓球)。 private JCheckBox cb3 = new JCheckBox(唱歌)。 // 性別標簽 private JLabel lb2 = new JLabel(性別)。 // 表示性別的JRadioButton單選框 private JRadioButton rb1 = new JRadioButton(男)。 private JRadioButton rb2 = new JRadioButton(女)。 // ButtonGroup添加JRadioButton,實現(xiàn)單選功能 private ButtonGroup bg = new ButtonGroup()。 // 文本域組件 private JTextArea area = new JTextArea()。 // 窗口CENTER部的JScrollPane面板,其中放置area文本域 private JScrollPane pane = new JScrollPane(area)。 // Set集合存放選中的興趣 private SetString hobbies = new HashSetString()。 // gender選中的性別 private String gender = 。 // JCheckBox復選框的事件監(jiān)聽器 private ActionListener listener1 = new ActionListener() { public void actionPerformed(ActionEvent e) { JCheckBox cb = (JCheckBox) ()。 // 選中的復選框把文本添加到Set集合中 if (()) { (())。 // 反之從集合中移除 } else { (())。 } print()。 } }。 // JRadioButton單選框的事件監(jiān)聽器 private ActionListener listener2 = new ActionListener() { public void actionPerformed(ActionEvent e) { JRadioButton jb = (JRadioButton) ()。 gender = ()。 print()。 } }。 // 打印方法 private void print() { // 清空文本域 ()。 // 如果Set集合中有元素,打印興趣 if (() 0) (你的興趣愛好有: )。 IteratorString it = ()。 while (()) { (() + )。 } // 如果gender不為空字符串,打印性別 if (!.equals(gender)) (你的性別為: + gender)。 } public Information() { //添加標簽、單選和復選按鈕 (lb1)。 (cb1)。 (cb2)。 (cb3)。 (lb2)。 (rb1)。 (rb2)。 (rb1)。 (rb2)。 // 為單選和復選按鈕添加事件監(jiān)聽器 (listener1)。 (listener1)。 (listener1)。 (listener2)。 (listener2)。 // 將JPanel面板和JScrollPane面板添加到JFrame容器中 Container container = ()。 (panel, )。 (pane, )。 ()。 ()。 (true)。 } public static void main(String[] args) { new Information()。 }}參考答案import .*。import .*。import .*。public class MyMenu extends JFrame implements ActionListener { JLabel label = new JLabel(請選擇菜單, )。 JMenuItem aaMenuItem, baMenuItem。 MyMenu() { JMenuBar menuBar = new JMenuBar()。 JMenu aMenu = new JMenu(菜單A)。 JMenu bMenu = new JMenu(菜單B)。 JMenuItem aaMenuItem = new JMenuItem(菜單項 AA)。 JMenuItem abMenuItem = new JMenuItem(菜單項AB)。 JMenuItem baMenuItem = new JMenuItem(菜單項 BA)。 (aMenu)。 (bMenu)。 (aaMenuItem)。 ()。 (abMenuItem)。 (baMenuItem)。 (this)。 (this)。 (this)。 setJMenuBar(menuBar)。 getContentPane().add(label, )。 } public void actionPerformed(ActionEvent e) { JMenuItem source = (JM
點擊復制文檔內(nèi)容
畢業(yè)設計相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1