程序員想要創(chuàng)建一個名為MyThread的類以便在main方法中用Thread實例化。對于下面三行: MyThread必須繼承Thread。 MyThread必須實現(xiàn)Thread。 MyThread必須覆蓋public void run()。 有幾行是正確的?()
A. 0 B. 1 C. 2 D. 3
class Thread2 implements Runnable { void run() { System.out.print("go "); } public static void main(String [] args) { Thread2 t2 = new Thread2(); Thread t = new Thread(t2); t.start(); } } 結(jié)果為:()
A. go B. 編譯失敗 C. 代碼運行,無輸出結(jié)果 D. 運行時異常被拋出
在Swing GUI編程中, setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) 語句的作用是()
A.當執(zhí)行關(guān)閉窗口操作時,不做任何操作。 B.當執(zhí)行關(guān)閉窗口操作時,調(diào)用WindowsListener對象并將隱藏JFrame C.當執(zhí)行關(guān)閉窗口操作時,調(diào)用WindowsListener對象并隱藏和銷毀JFrame D.當執(zhí)行關(guān)閉窗口操作時,退出應(yīng)用程序。