会计考友 发表于 2012-8-4 12:33:16

2011年JAVA认证模拟题第二阶段(4)

  Q10.In the following applet, how many buttons will be displayed?
  1. import java.applet.*;
  2. import java.awt.*;
  3. public class Q16 extends Applet {
  4. Button okButton = new Button(“Ok”);
  5. public void init() {
  6. add(okButton);
  7. add(okButton);
  8. add(okButton);
  9. add(okButton);
  10. add(new Button(“Cancel”));
  14. add(new Button(“Cancel”));
  15. add(new Button(“Cancel”));
  16. add(new Button(“Cancel”));
  18. setSize(300,300);
  19. }
  20. }
  a. 1 Button with label “Ok” and 1 Button with label “Cancel”.
  b. 1 Button with label “Ok” and 4 Buttons with label “Cancel”.
  c. 4 Buttons with label “Ok” and 1 Button with label “Cancel”.
  d. 4 Buttons with label “Ok” and 4 Buttons with label “Cancel”.
  Q11.What is the output of the following program?
  1. class Test {
  2. void show() {
  3. System.out.println(“non-static method in Test”);
  4. }
  5. }
  6. public class Q3 extends Test {
  7. static void show() {
  8. System.out.println(“Overridden non-static method in Q3”);
  9. }
  10. public static void main(String[] args) {

会计考友 发表于 2012-8-4 12:33:17

2011年JAVA认证模拟题第二阶段(4)

</p>  11. Q3 a = new Q3();
  12. }
  13 }
  a. Compilation error at line 2.
  b. Compilation error at line 7.
  c. No compilation error, but runtime exception at line 2.
  d. No compilation error, but runtime exception at line 7.
  Q12.What will happen if you compile/run the following code?
  1. public class Q21 {
  2. int maxElements;
  3. void Q21() {
  4. maxElements = 100;
  5. System.out.println(maxElements);
  6. }
  7. Q21(int i) {
  8. maxElements = i;
  9. System.out.println(maxElements);
  10. }
  11. public static void main(String[] args) {
  12. Q21 a = new Q21();
  13. Q21 b = new Q21(999);
  14.
  15. }
  16. }
  a. Prints 100 and 999.
  b. Prints 999 and 100.
  c. Compilation error at line 2, variable maxElements was not initialized.
  d. Compilation error at line 12.
  10. b
  11. b
  12. d
页: [1]
查看完整版本: 2011年JAVA认证模拟题第二阶段(4)