知道美河 | 上传资料 | VIP申请 | 精品课程 | 资料搜索 | 问题反馈 | 会员手册 | 积分消费 | 积分充值 | 帐号保护

javalea 发表于 2005-3-19 18:54:17

方联scjp权威考题

Sample TextJava培训考题
1.        给出以下程序:
1. public class Colors {
2. public static void main(String args[]) {
3. int n = 1;
4. System.out.println("The Color is " + args);
5. }
6. }
假定程序已经编译通过,下面那个命令行可以输出“The Color is blue”
A.        Colors red green blue yellow
B.        java Colors blue green red yellow
C.        java Colors green blue red yellow
D.        java Colors.class blue green red yellow
E.        java Colors.class green blue red yellow
2.        读程序:
1. public class Test{
2. public static void main(String args[]){
3. char c = '\u0009';
4. if( c == 0x0009L)
5. System.out.println("Equal");
6. else System.out.println("Not Equal");
7. }
8. }
当编译和运行该类时,将会发生什么:
A.        程序因为第4行将出现一个编译错误
B.        程序因为第4行将出现一个运行错误
C.        程序因为第3行将出现一个编译错
D.        程序输出”Equal"
E.        程序输出"Not Equal”
3.        读程序:
1. public class StrEq{
2. private StrEq(){
3. String s = "Bob";
4. String s2 = new String("Bob");
5. if(s == s2){
6. System.out.println("Equal");
7. }
8. else{
9. System.out.println("Not equal");
10. }
11. }
12. public static void main(String args[]){
13. StrEq s = new StrEq();
14. }
15. }
当编译和运行该类时,将会发生什么:
A.        程序能够编译,并且输出“Equal”
B.        程序能够编译,并且输出“Not equal”
C.        程序因为第2行导致一个运行时错误
D.        程序因为第2行导致一个编译错误
4.        以下那个赋值是非法的:
A.        longtest = 012;
B.        floatb = -412;
C.        int other = (int )true;
D.        double d = 0x12345678;
E.        short   s = 10;
5.        读程序:
1. class CompareString{
2. public static void main(String[] args) {
3. Integer x = new Integer(5);
4. Integer y = new Integer(5);
5. Integer z = x;
6. if ( ______ )
7. System.out.println("true");
8. }
9. }
以下哪个选项填入第6行后,不能输出true:
A.        x==z
B.        x==y
C.        y.equals(z)
D.        x.equals(y)
6.        读程序(双选):
1. public class Declare {
2.
3. public static void main(String [] args) {
4.
5. System.out.println("The variable is " + x);
6. }
7. }
以下哪个选项中的代码可以使程序编译通过
A.        把“int x;”放在程序的第2行
B.        把“int x;”放在程序的第4行
C.        把“int x=5;”放在程序的第2行
D.        把“int x=5;”放在程序的第4行
E.        把“static int x;”放在程序的第2行



7.        读程序(双选):
1. public class Child extends Parent{
2. int a, b, c;
3. public Child(int x, int y) {
4. a = x; b = y;
5. }
6. public Child(int x) {
7. super(x);
8. }
9. }
为了能使该类编译通过,下面那个构建器必须出现在父类中:
A. public Parent(int m,int n)
B.public Parent(int m)
C.public Parent()
D. public Parent(int m,int n, int o)
8.        读程序:
1. public class Derive extends Base{
2. public static void main(String argv[]){
3. Derive a = new Derive();
4. a.method2();
5. }
6. public void method1(){
7. System.out.println("method 1");
8. }
9. public void method2(){
10. method1();
11. }
12. }
13. abstract class Base{
14. abstract public void method1();
15. public void method3(){
16. System.out.println("method 3");
17. }
}
当编译和运行该类时,将出现什么:
A.        程序输出“method 1”
B.        程序输出“method 3”
C.        程序因为第15行而出现编译错误
D.        程序因为第15行而出现运行错误
9.        以下哪个接口的定义是合法的:
A.        public interface A {int a();}
B.        public interface B implements A {}
C.        interface C {int a;}
D.        private interface D {}
10.        读程序:
1. //File SuperClass.java
2. package MyPackage;
3. class SuperClass{
4. void myMethod(){
5. System.out.println("SuperClass");
6. }
7. }
8. //File SubClass.java
9. public class SubClass extends SuperClass{
10. public static void main(String[] args) {
11. myMethod();
12. }
13. }
当SuperClass.java和SubClass.java在同一个目录下时,如果编译和运行SunClass.java则会出现什么情况:
A.        两个类都可以编译通过,并且SubClass运行时会输出“SuperClass”
B.        两个类都回出现编译时错误
C.        两个类都可以编译通过,但SubClass会在运行时出现运行时错误
D.        SuperClass.java可以编译通过,但SunClass会出现一个编译错误
11.        读程序:
1. public class Test{
2. public static void main(String args[]){
3. int[] i = new int;
4. System.out.println(i);
5. }
6. }
当编译和运行该类时,会:
A.        出现编译时错误
B.        出现运行时错误
C.        输出0
D.        输出null
12.        以下哪个选项是正确的数组声明或初始化:
A.        Array sizes = new Array(4);
B.        double [] sizes = {1, 2, 3, 4};
C.        int sizes;
D.        long sizes [] = new long;
13.        读程序:
1. public class Initialize{
2. int x = 200;
3. static {
4. int x = 100;
5. }
6. public static void main(String[] args){
7. Initialize init = new Initialize();
8. System.out.println(init.x);
9. }
10. }
当编译和运行该类时:
A.        程序因为第3行产生一个编译错误
B.        程序因为第4行产生一个运行时错误
C.        程序输出100
D.        程序输出200
14.        读程序:
1. public int abcd( char x) {
2. if ( x <= 'M' ) {
3. if ( x == 'D')
4. return 2;
5. return 1;
6. }
7. else if( x == 'S') return 3;
8. else if( x == 'U') return 4;
9. return 0;
10. }
在调用abcd(char x)函数时,下面哪个选项作为参数时,会返回1
A.‘X’
B. ‘A’
C.‘D’
D.‘Z’
15.        读程序:
1. class TryTest {
2. public static void main(String[] args) {
3. try{
4. System.exit(0);
5. }
6. finally {
7. System.out.println("Finally");
8. }
9. }
10. }
当编译和运行该类时,将:
A.程序因为第4行出现编译错误
B.程序因为第4行出现运行时错误
C.程序因为第6行出现编译错误
D.程序因为第6行出现运行时错误
E.程序输出“Finally”
F.程序可以运行,但什么也不打印

16.        Given the following variable declarations:
Boolean b1 = new Boolean(true);
Boolean b2 = new Boolean(true);
Which expression is a legal Java expression that returns true?
A.        b1==b2
B.        b1.equals(b2)
C.        b1&&b2
D.        b1||b2
E.        b1&b2
F.        b1|b2
17.        Given:
1. public class Employee {
2.
3. }
4.
5. class Managerextends Employee{
6. }
What is the relationship between Employee and the Manager?
A.        has a
B.        is a
C.        both has a and is a
D.        neither has a nor is a
18.        Which layout manager arranges components from left to right, then top to bottom, centering each row as it moves to the next?
A.        BorderLayout
B.        FlowLayout
C.        CardLayout
D.        GridLayout
19.        Which of the following AWT components can generate an ActionEvent?
A.        java.awt.Button
B.        java.awt.Panel
C.        java.awt.Canvas
D.        java.awt.Scrollbar
20.        What kind of Stream is the System.out object?
A.        java.io.PrintStream
B.        java.io.TerminalStream
C.        java.io.FileWriter
D.        java.io.FileWriter
21.        Which of the following events has a matching adapter class that implements the appropriate listener interface?(双选)
A.        java.awt.event.FocusEvent
B.        java.awt.event.KeyEvent
C.        java.awt.event.ItemEvent
D.        java.awt.event.ActionEvent
22.        Which of the following methods are static methods of the Thread class?(双选)
A.        sleep(ling time)
B.        yield()
C.        wait()
D.        notify()
23.        Which method do you have to define if you implement the Runnable interface?
A.        run()
B.        runnable()
C.        start()
D.        init()
E.        main()
24.        Given:
1. class MyThread extends Thread {
2.
3. public static void main(String [] args) {
4. MyThread t = new MyThread();
5. t.run();
6. }
7.
8. public void run() {
9. for(int i=1 ; i<3 ; ++i) {
10. System.out.print(i + "..");
11. }
12. }
13. }
What is the result of this code?C
A.        This code will not compile due to line 4
B.        This code will not compile due to line 5
C.        1..2..
D.        1..2..3..
25.        Given a local inner class defined inside a method code block, which of the following statements is correct?
A.        Any variables declared locally within the method can be accessed by the inner class
B.        Only static variables in the enclosing class can be accessed by the inner class
C.        Only local variables declared final can be accessed by the inner class
D.        Only static variables declared locally can be accessed by the inner class.



26.public class SychTest{
   private int x;
   private int y;
   public void setX(int i){ x=i;}
   public void setY(int i){y=i;}
   public Synchronized void setXY(int i){
   setX(i);
   setY(i);
   }
   public Synchronized boolean check(){
      return x!=y;   
   }
   }
    Under which conditions willcheck() return true when called from a different class?
   A.check() can never return true.
   B.check() can return true when setXY is callled by multiple threads.
   C.check() can return true when multiple threads call setX and setY separately.
   D.check() can only return true if SychTest is changed allow x and y to be set separately.

27. 1)public class X implements Runnable{
2)private int x;
3)private int y;
4)public static void main(String[] args){
5)   X that =new X();
6) (new Thread(that)).start();
7) (new Thread(that)).start();
   }
9) public synchronized void run(){
10)for(;;){
11)      x++;
12)      Y++;
13) System.out.println("x="+x+",y="+y);
14)    }
15)   }
16)}   
    what is the result?
A.compile error at line 6
B.the program prints pairs of values for x and y that are
    always the same on the same time

28.class A implements Runnable{
int i;
public void run(){
   try{
       Thread.sleep(5000);
      i=10;
       }catch(InterruptException e){}
       }
       }
   public static void main(String[] args){
      try{
         A a=new A();
         Thread t=new Thread(a);
         t.start();
17)
      int j=a.i;
19)
      }catch(Exception e){}
      }
      }
what be added at line line 17, ensure j=10 at line 19?
A. a.wait();   B.t.wait();   C. t.join();   D.t.yield();   
E.t.notify();F.a.notify(); G.t.interrupt();
29.1)public class X{
2)    public static void main(String[] args){
3)   String foo="ABCDE";
4)   foo.substring(3);
5)   foo.concat("XYZ");
6)    }
7)   }
what is the value of foo at line 6?
30.public class Test{
   public static void main(String[] args){
   StringBuffer a=new StringBuffer("A");
   StringBuffer b=new StringBuffer("B");
   operate(a,b);
   System.out.pintln(a+","+b);
    }
   public static void operate(StringBuffer x, StringBuffer y){
    x.append(y);
    y=x;
   }
   }
   what is the output?

yangyu638 发表于 2005-3-20 12:49:05

感谢楼主分享
我已下载。。。。。
特感谢您的大公无私EMB_12

weichl 发表于 2005-9-29 21:51:28

感谢楼主分享

ptzhiwei 发表于 2006-6-24 19:00:04

JAVA还没学呢,先下载来再说。。。

sjah113 发表于 2008-5-23 21:00:52

支持楼主。

fangzhilong 发表于 2008-12-15 08:22:28

谢谢楼主发这么好的东东!!EMB_05 EMB_05 EMB_05

sd012 发表于 2009-7-7 16:26:16

EMB_17
页: [1]
查看完整版本: 方联scjp权威考题