填空题 下列程序的作用是在屏幕上显示一个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); {{U}} 【13】 {{/U}}; } public Test (String str) { super(str); } }
  • 1、
【正确答案】 1、t. setVisible (true)    
【答案解析】[解析] 要生成一个窗口,通常用Window的子类Frame来进行实例化,而不是直接用Window类。每个Frame的对象实例化以后,都是没有大小和不可见的,必须调用setSize ()来设置大小,调用setVisible (true)来设置该窗口为可见。