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

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

  Q31.What will appear in the standard output when you run the Tester class?
  1. class Tester {
  2. int var;
  3. Tester(double var) {
  4. this.var = (int)var;
  5. }
  6. Tester(int var) {
  7. this(“hello”);
  8. }
  9. Tester(String s) {
  10. this();
  11. System.out.println(s);
  12. }
  13. Tester() {
  14. System.out.println(“good-bye”);
  15. }
  16. public static void main(String args[]) {
  17. Tester t = new Tester(5);
  18. }
  a. “hello”
  b. 5
  c. “hello” followed by “good-bye”

  d. “good-bye” followed by “hello”

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

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

</p>  Q32.What are the range of values for a variable of type short?
  a. -2^7 to 2^7-1
  b. 0 to 2^8
  c. -2^15 to 2^15-1
  d. -2^15-1 to 2^15
  Q33.Analyze the following two classes
  1. class First {
  2. static int a = 3;
  3. }
  4. final class Second extends First {
  5. void method() {
  6. System.out.println(a);
  7. }
  8. }
  a. Class First compiles, but class Second does not.
  b. Neither class compiles.
  c. Both classes compile, and if method() is invoked, it writes 3 to the output.
  d. Both classes compile, and if method() is invoked, it throws an exception.
  31. d
  32. c
  33. c
页: [1]
查看完整版本: 2011年JAVA认证模拟题第二阶段(11)