What happens when you compile and run the following program?
import java.awt.*;
public class X
{
public static void main(String[] args) throws Exception
{
final Button b1 = new Button("Button1");
final Button b2 = new Button("Button2");
final Panel p = new Panel();
p.add(b1);
p.add(b2);
final Frame f = new Frame();
f.add(p);
f.pack();
f.setVisible(true);
}
}
A) Compilation error.
B) Button1 in a frame.
C) Button2 in a frame.
D) Button1 and Button2 in a frame.
E) Exception: "use java.awt.Frame.getContentPane().add() instead."