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

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

  Q64.Given the following code for the Demo class
  1. public class Demo {
  2. private String [] userNames;
  3. public Demo() {
  4. userNames = new String;
  5. }
  6. public void showName(int n) {
  7. System.out.println(“Name is “ + userNames);
  8. }
  9.
  10. public String getName(int n) {
  11. return(userNames);
  12. }
  13. }
  What would be the result of calling the showName method with a parameter of 2 immediately after creating an instance of Demo
  a. Standard output would show “Name is null”.
  b. A NullPointerException would be thrown, halting the program.
  c. An ArrayIndexOutOfBoundsException would be thrown halting the program.
  d. Standard output would show “Name is”.
  Q65.What will be the result of attempting to compile and run the following class?
  1. public class Integers {
  2. public static void main(String args[]
         ) {

  3. System.out.printl(0x10 + 10 + 010);

  4. }

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

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

</p>  5. }
  Select the one right answer.
  a. The code won't compile. The compiler will complain about the expression 0x10 + 10 + 010
  b. When run, the program will print “28”
  c. When run, the program will print “34”
  d. When run, the program will print “36”
  Q66.How will the following program lay out its buttons?
  1. import java.awt.*;
  2. public class MyClass {
  3. public static void main(String args[]) {
  4. String labels[] = {”A”,”B”,”C”,”D”,”E”,”F”};
  5. Window grid = new Frame();
  6. grid.setLayout(new GridLayout(0,1,2,3));
  7. for(int i=0;i
  8. grid.add(new Button(labels));
  9. }
  10. grid.pack();
  11. grid.setVisible(true);
  12. }
  Select the one right answer
  a. The program will not show any buttons at all.
  b. It will place all buttons in one row - A B C D E F.
  c. It will place all buttons in one column, i.e., each button in a separate row - A B C D E and F.

  d. It will place pairs of buttons in three separate row A B, C D and E F.
  64. a
  65. c
  66. c
页: [1]
查看完整版本: 2011年JAVA认证模拟题第二阶段(22)