当前位置: 技术问答>java相关
scjp的一道题?
来源: 互联网 发布时间:2015-07-16
本文导语: 1. import java.awt.*; 2. 3. public class Test extends Frame { 4. public Test() { 5. add(new Label(“Hello”) ); 6. add(new TextField(“Hello”) ); 7. add(new Button(“Hello”) ); 8. pack(); 9. show(); 10. } 11. 12. pu...
1. import java.awt.*;
2.
3. public class Test extends Frame {
4. public Test() {
5. add(new Label(“Hello”) );
6. add(new TextField(“Hello”) );
7. add(new Button(“Hello”) );
8. pack();
9. show();
10. }
11.
12. public static void main(String args[]) {
13. new Test ();
14. }
15. )
What is the result?
A. The code will not compile.
B. A Window will appear containing only a Button.
C. An IllegalArgumentException is thrown at line 6.
D. A Window button will appear but will not contain the Label, TextField, or Button.
E. A Window will appear containing a Label at the top, a TextField below the Label, and a Button below the TextField.
F. A Window will appear containing a Label on the left, a TextField to the right of the Label, and a button to the right of the TextField.
请说一下理由
2.
3. public class Test extends Frame {
4. public Test() {
5. add(new Label(“Hello”) );
6. add(new TextField(“Hello”) );
7. add(new Button(“Hello”) );
8. pack();
9. show();
10. }
11.
12. public static void main(String args[]) {
13. new Test ();
14. }
15. )
What is the result?
A. The code will not compile.
B. A Window will appear containing only a Button.
C. An IllegalArgumentException is thrown at line 6.
D. A Window button will appear but will not contain the Label, TextField, or Button.
E. A Window will appear containing a Label at the top, a TextField below the Label, and a Button below the TextField.
F. A Window will appear containing a Label on the left, a TextField to the right of the Label, and a button to the right of the TextField.
请说一下理由
|
F
默认的布局管理器是流管理器
默认的布局管理器是流管理器
|
答案应该为B
默认的布局管理器是BorderLayout
默认的布局管理器是BorderLayout
|
向一个frame中add几个component的时候,默认是一个覆盖一个的.
|
B
|
为什么?