import java.awt.*;import java.awt.event.*;public class MyFrameCanExit extends Frame implements ① {public MyFrameCanExit(String str){super(str);}public void windowClosing( ② e) {System.exit(0);}public void windowClosed(WindowEvent e) { }public void windowOpened(WindowEvent e) { }public void windowIconified(WindowEvent e) { }public void windowDeiconified(WindowEvent e) { }public void windowActivated(WindowEvent e) { }public void windowDeactivated(WindowEvent e) { }public static void main(String args[ ]){MyFrameCanExit fr = new MyFrameCanExit("Hello !");fr. ③ (fr); //注冊窗口事件監(jiān)聽器。fr. ④ (200,200);fr.setVisible(true);}1. 閱讀下面的程序MyAdd.java,填寫劃線部分的語句或注釋,并寫出程序執(zhí)行結果。public class MyAdd { //繼承線程類static int total = 10;int n;public MyAdd(int n){this.n=n;}public void run() {try{sleep(n); //含義是:total=total+n;System.out.println(total);}catch(Exception e){System.out.println(“EXCEPTION!”);}}public static void main(String[] args) {MyAdd t1 = new MyAdd(3000);; //啟動線程t1}}
添加回答
舉報
0/150
提交
取消