问题 填空题

下列程序的作用是在屏幕上显示一个200×200大小的窗口,在横线上填入相应的语句。 import java.awt.*; public class Test extends Frame { public static void main (String args[]) { Test t=new Test ("Hello"); t.setSize (200,200); t.setBackground (Color.red); 【13】 ; } public Test (String str) { super(str); } }

答案

参考答案:t. setVisible (true)

解析: 要生成一个窗口,通常用Window的子类Frame来进行实例化,而不是直接用Window类。每个Frame的对象实例化以后,都是没有大小和不可见的,必须调用setSize ()来设置大小,调用setVisible (true)来设置该窗口为可见。

多选题
单项选择题