⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mockcert05.txt

📁 一道JAVA方面的试题 很不错的 我很喜欢
💻 TXT
📖 第 1 页 / 共 5 页
字号:

public void init() {
  setLayout(new BorderLayout());
  add("East", new Button("hello"));
}

Select the one right answer.

Only One: _______
1) Nothing will appear in the applet
2) A button will appear in the applet set in the exact center
3) A button will appear on the left side of the applet
4) A button will appear on the right side of the applet
5) A button will fill the entire applet


Question 97
===========================================================
Choose all true statements about the paint() method defined in the Component class:

Select all valid answers.

Mutiple: ________________
1) it is protected
2) it takes an instance of class Graphics
3) it is static
4) it is invoked automatically whenever you minimize and then maximize a component, such as a window
5) there is also a version that takes an int


Question 98
===========================================================
Analyze the following code:

class WhatHappens implements Runnable {
  public static void main(String[] args) {
    Thread t = new Thread(this);
    t.start();
  }

  public void run() {
    System.out.println("hi");
  }
}

Select the one right answer.

Mutiple: ________________
1) This program does not compile
2) This program compiles but nothing appears in the standard output
3) This program compiles and the word "hi" appears in the standard output, once
4) This program compiles and the word "hi" appears continuously in the standard output until the user hits control-c to stop the program


Question 99
===========================================================
What is wrong with the following code?

final class First {
  private int a = 1;
  int b = 2;
}

class Second extends First {
  public void method() {
    System.out.println(a + b);
  }
}

Select all valid answers.

Mutiple: ________________
1) You cannot invoke println() without passing it a String
2) Since a is private, no classes other than First can access it
3) Second cannot extend First
4) final is not a valid keyword for a class


Question 100
===========================================================
Analyze the following two classes.

class First {
  static int a = 3;
}

final class Second extends First {
  void method() {
    System.out.println(a);
  }
}

Select the one right answer.

Mutiple: ________________
1) Class First compiles, but class Second does not
2) Class Second compiles, but class First does not
3) Neither class compiles
4) Both classes compile, and if method() is invoked, it writes 3 to the standard output
5) Both classes compile, but if method() is invoked, it throws an exception


Question 101
===========================================================
Why won抰 the following class compile?

class A {
  private int x;
  public static void main(String[] args) {
    new B();
  }

  class B {
    B() {
      System.out.println(x);
    }
  }
}

Select the one right answer.

Mutiple: ________________
1) Class B tries to access a private variable defined in its ouer class.
2) Class A attempts to create an instance of B when there is no current instance of class A.
3) Class B抯 constructor must be public.


Question 102
===========================================================
Analyze the following code.

void looper() {
  int x = 0;
  one:
  while (x < 10) {
    two:
    System.out.println(++x);
    if (x > 3)
       break two;
  }
}

Select all valid answers.

Mutiple: ________________
1) This code compiles
2) This code does not compile
3) This method writes the number 0 to the standard output
4) the numbers 1 and 2 to the standard output
5) the number 3 to the standard output


Question 103
===========================================================
What appears in the standard output when the method named testing is invoked?

void testing() {
  one:
  two:
  for (int i = 0; i < 3; i++) {
     three:
     for (int j = 10; j < 30; j+=10) {
         System.out.println(i + j);
         if (i > 2)
         continue one;
     }
  }
}

Select all valid answers.

Mutiple: ________________
1) 10 and 20
2) 11 and 21
3) 12 and 22
4) 13 and 23
5) 30, 31, 32, 33


Question 104
===========================================================
What will the user interface look like in an applet given the following init() method?

public void init() {
  setLayout(new BorderLayout());
  add(new Button("hello"));
}

Select the one right answer.

Mutiple: ________________
1) Nothing will appear in the applet
2) A button will appear in the applet set in the exact center
3) A button will appear in the applet along the top and centered horizontally
4) ) A button will appear in the top left corner
5) A button will fill the entire applet


Question 105
===========================================================
What expressions are true concerning the following lines of code?

int[] arr = {1, 2, 3};
for (int i=0; i < 2; i++)
    arr[i] = 0;

Select all valid answers.

Mutiple: ________________
1) arr[0] == 0
2) arr[0] == 1
3) arr[1] == 1
4) arr[2] == 0
5) arr[3] == 0


Question 106
===========================================================
What will happen if you try to compile and execute B抯 main() method?

class A {
  int i;
  A(int i) {
   this.i = i * 2;
  }
}

class B extends A {
  public static void main(String[] args) {
    B b = new B(2);
  }

  B(int i) {
    System.out.println(i);
  }
}

Select the one right answer.

Mutiple: ________________
1) The instance variable i is set to 4
2) The instance variable i is set to 2
3) The instance variable i is set to 0
4) This code will not compile


Question 107
===========================================================
Which best describes the user interface of an applet given the following init() method:

public void init() {
  setLayout(new BorderLayout());
  add("North", new TextField(10));
  add("Center", new Button("help"));
}

Select all valid answers.

Mutiple: ________________
1) The TextField object will be placed at the top of the applet and will be 10 columns wide
2) The Button object will be centered in the applet and will be just large enough to contain the text "help"
3) The Button object will be centered in the applet and will start at the left edge of the applet, fit just under the TextField object above it, and extend to the right and bottom edge of the applet
4) The TextField object will be placed along the top of the applet and will stretch from the left edge to the right edge
5) The placement of the Button object and the TextField object depends on the overall size of the applet.


Question 108
===========================================================
Which of the following statements about try, catch, and finally are true?

Select all valid answers.

Mutiple: ________________
1) A try block must always be followed by a catch block
2) A try block can be followed either by a catch block or a finally block, or both
3) A catch block must always be associated with a try block
4) A finally can never stand on its own (that is, without being associated with try block)
5) None of these are true


Question 109
===========================================================
When a Thread sleeps by invoking Thread.sleep(1000) method, it releases the 
lock on the Object and allows other Threads to acquire the lock on the object. 
True/False?

Only One: _______
1) True
2) False


Question 110
===========================================================
public class Test extends Object implements Runnable 
 { 
   String s1 = "Earth "; 
   String s2 = "Moon"; 

   public void run() 
   { 
     synchronized (s1) { 
       for (int i=0; i < 2; i++) 
       { 
        s1.concat(" to Moon "); 
        System.out.print(s1); 

        s2.concat(" to Earth "); 
        System.out.println(s2); 
       } 
     } 
   } 

  public static void main(String[] args) 
  { 
     Test t = new Test(); 
     new Thread(t).start(); 
     new Thread(t).start(); 
  } 
 }

Only One: _______
1) Prints 
   Earth to Moon Moon to Earth
   Earth to Moon Moon to Earth
   Earth to Moon Moon to Earth
   Earth to Moon Moon to Earth
2) Prints
    Earth to Moon Earth to Moon
    Earth to Moon Earth to Moon
    Earth to Moon Earth to Moon
    Earth to Moon Earth to Moon
3) Prints
   Earth to Moon Moon to Earth
   Moon to Earth Earth to Moon
   Earth to Moon Moon to Earth
   Moon to Earth Earth to Moon
4) Output cannot be determined.
5) Prints
    Earth Moon
    Earth Moon
    Earth Moon
    Earth Moon


                                 JTest
                 Sun Certified Programmer for Java2 Platform
                       Examination Score Report

     CANDIDATE:     JTest
     CANDIDATE ID:  JT12345678                DATE:2002-3-1(YYYY-MM-DD)
     Exam: JTest SCJP Mock Exam

Exam Results:

                   Correct Answers               Your Answers        Result
                    1  2  3  4  5                1  2  3  4  5
------------------------------------------------------------------------------------
Question # 01             3                            3               0
------------------------------------------------------------------------------------
Question # 02             3                            3               0
------------------------------------------------------------------------------------
Question # 03          2        5                   2        5         0
------------------------------------------------------------------------------------
Question # 04             3                            3               0
------------------------------------------------------------------------------------
Question # 05                4                            4            0
------------------------------------------------------------------------------------
Question # 06       1  2  3     5                1  2  3     5         0
------------------------------------------------------------------------------------
Question # 07       1                            1                     0
------------------------------------------------------------------------------------
Question # 08       1        4                   1        4            0
------------------------------------------------------------------------------------
Question # 09          2                            2                  0
------------------------------------------------------------------------------------
Question # 10       1                            1                     0
------------------------------------------------------------------------------------
Question # 11          2                            2                  0
------------------------------------------------------------------------------------
Question # 12                4                            4            0
------------------------------------------------------------------------------------
Question # 13                4                            4            0
------------------------------------------------------------------------------------
Question # 14          2        5                   2        5         0
------------------------------------------------------------------------------------
Question # 15             3                            3               0
------------------------------------------------------------------------------------
Question # 16       1        4                   1        4            0
------------------------------------------------------------------------------------
Question # 17                4                            4            0
------------------------------------------------------------------------------------
Question # 18                   5                            5         0
------------------------------------------------------------------------------------
Question # 19                   5                            5         0
------------------------------------------------------------------------------------
Question # 20             3                            3               0
------------------------------------------------------------------------------------
Question # 21          2  3                         2  3               0
------------------------------------------------------------------------------------
Question # 22             3                            3               0
------------------------------------------------------------------------------------
Question # 23       1  2        5                1  2        5         0
------------------------------------------------------------------------------------
Question # 24          2                            2                  0
------------------------------------------------------------------------------------
Question # 25             3  4  5                      3  4  5         0
------------------------------------------------------------------------------------
Question # 26       1  2                         1  2                  0
------------------------------------------------------------------------------------
Question # 27       1  2        5                1  2        5         0
------------------------------------------------------------------------------------
Question # 28             3                            3               0
------------------------------------------------------------------------------------
Question # 29          2  3                         2  3               0
------------------------------------------------------------------------------------
Question # 30       1        4                   1        4            0
------------------------------------------------------------------------------------
Question # 31          2  3  4                      2  3  4            0
------------------------------------------------------------------------------------
Question # 32       1  2     4                   1  2     4            0
------------------------------------------------------------------------------------
Question # 33       1  2        5                1  2        5         0
------------------------------------------------------------------------------------
Question # 34       1                            1                     0
------------------------------------------------------------------------------------
Question # 35             3                            3               0
------------------------------------------------------------------------------------
Question # 36          2                            2                  0
------------------------------------------------------------------------------------
Question # 37       1  2  3                      1  2  3               0
------------------------------------------------------------------------------------
Question # 38       1     3                      1     3               0
------------------------------------------------------------------------------------
Question # 39          2                            2                  0
------------------------------------------------------------------------------------
Question # 40             3                            3               0
------------------------------------------------------------------------------------
Question # 41       1  2  3     5                1  2  3     5         0
------------------------------------------------------------------------------------
Question # 42                   5                            5         0
------------------------------------------------------------------------------------
Question # 43                4                            4            0
------------------------------------------------------------------------------------
Question # 44       1           5                1           5         0
------------------------------------------------------------------------------------
Question # 45       1  2  3                      1  2  3               0
------------------------------------------------------------------------------------
Question # 46       1        4                   1        4            0
------------------------------------------------------------------------------------
Question # 47             3                            3               0
------------------------------------------------------------------------------------
Question # 48          2                            2                  0
------------------------------------------------------------------------------------
Question # 49          2                            2                  0
------------------------------------------------------------------------------------
Question # 50          2     4                      2     4            0
------------------------------------------------------------------------------------
Question # 51             3     5                      3     5         0
------------------------------------------------------------------------------------
Question # 52          2        5                   2        5         0
------------------------------------------------------------------------------------
Question # 53          2  3     5                   2  3     5         0
------------------------------------------------------------------------------------
Question # 54             3  4                         3  4            0
------------------------------------------------------------------------------------
Question # 55       1  2  3  4                   1  2  3  4            0
------------------------------------------------------------------------------------
Question # 56          2     4  5                   2     4  5         0
------------------------------------------------------------------------------------
Question # 57       1  2  3                      1  2  3               0
------------------------------------------------------------------------------------
Question # 58             3                            3               0
------------------------------------------------------------------------------------
Question # 59       1                            1                     0
------------------------------------------------------------------------------------
Question # 60       1                            1                     0
------------------------------------------------------------------------------------
Question # 61             3                            3               0
-------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -