posted 24 years ago
Hi
Two question from IBM mock
1)
Based upon the code below, what is true about the Frame constructed:
public LayoutFrame() {
2. super();
3. Button b = new Button("What is my location?");
4. Panel p1 = new Panel();
5. p1.add(b);
6. add(p1);
7. }
a) The push button is located in the center of the Frame and will expand to all sides.
b) The push button is located at the top of the Frame and centered.
c) The code does compile successfully because the superclass constructor is called.
d) The size of the push button is just larger than the label.
e) The push button is located in the upper-left hand corner of the Frame.
Multiple Select - Please select all of the correct answers (this question has 2 correct choices).
2)
Assuming the code below is part of a Frame subclass, which are true?
1.public LayoutFrame() {
2. setLayout(new GridLayout(1, 3));
3. Button b = new Button("What is b location?");
4. Button a = new Button("What is a location?");
5. Panel p1 = new Panel();
6. p1.setLayout(new GridLayout(2, 1));
7. p1.add(a);
8. p1.add(b);
9. add(p1);
10. }
a) Two push buttons are added. Each is half the size of the entire Frame vertically and the entire width, with a above b.
b) Two push buttons are added. Each is half the width of the Frame and the entire length vertically, with a above b.
c) There is a compile error since there is no receiving object specified for the methods in lines 2 and 9.
d) There is a compile error since the superclass constructor is not called.
Single Select - Please select the best answer (one and only one choice must be selected).
According to me Answer is :
Ans 1: code compile successfully and there is no output becoz no setvisible,setsize method in code.
Ans 2: Compile successfully - no output.
Que 1 say there is two correct choice.
Que 1 say there is only one correct choice.
pls clarify.
Best Regards
Avi