荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: junire (找不回那个我), 信区: Java
标  题: SCJP全真试题第一套(下)
发信站: 荔园晨风BBS站 (Mon Dec 17 22:59:56 2001), 转信

1.Which three are valid declarations of a float?

  A. float foo=-1;

  B. float foo=1.0;

  C. float foo=42e1;

  D. float foo=2.02f;

  E. float foo=3.03d;

  F. float foo=0x0123;



2.Given:

  interface Foo{

    int k=0;

  }



  public class Test implements Foo{

    public static void main(String args[]){

       int i;

       Test test=new Test();

       i=test.k;

       i=Test.k;

       i=Foo.k;

    }

  }



  Which statement is true?

  A. Compilation succeeds

  B. An error at line 2 causes compilation to fail

  C. An error at line 9 causes compilation to fail

  D. An error at line 10 causes compilation to fail

  E. An error at line 11 causes compilation to fail



3.Given:

  public class Foo{

    public static void main(String args[]){

       StringBuffer a=new StringBuffer("A");

           StringBuffer b=new StringBuffer("B");

           operate(a,b);

           System.out.println(a+","+b);

    }

    static void operate(StringBuffer x,StringBuffer y){

       x.append(y);

       y=x;

    }

  }



  What is the result?

  A. The code compiles and prints "A,B"

  B. The code compiles and prints "A,A"

  C. The code compiles and prints "B,B"

  D. The code compiles and prints "AB,B"

  E. The code compiles and prints "AB,AB"



4.Given:

  public class Test{

    public static void main(String sss[]){

       int i=0xFFFFFFF1;

       int j=~i;



    }

  }



  What is the decimal value of j at line 5?

  A. 0

  B. 1

  C. 14

  D. 15

  E. An error at line 3 causes compilation to fail

  F. An error at line 4 causes compilation to fail



5.Which two demonstrate an "is a" relationship?

  A. public interface Person{}

     public class Employee extends Person{}

  B. public interface Shape{}

     public interface Retangle extends Shape{}

  C. public interface Color{}

     public class Shape{private Color color;}

  D. public class Species{}

     public class Animal{private Species species;}

  E. interface Component{}

     class Container implements Component{

       private Component[] children;

     }



6.Given:

  package foo;

  public class Outer{

    public static class Inner{

    }

  }



  Which statement is true?

  A. An instance of the Inner class can be constructed with "new Outer.
Inner();"

  B. An instance of the Inner class cannot be constructed outside of
package foo

  C. An instance of the Inner class can only be constructed from
within the Outer calss

  D. From within the package bar,an instance of the Inner class can be
constructed with "new


Inner()"



7.Which statement is true?

  A. An anonymous inner class may be declared as final

  B. An anonymous inner class can be declared as private

  C. An anonymous inner class can implement multiple interfaces

  D. An anonymous inner class can access final variables in any
enclosing scope

  E. Constuction of an instance of a static inner class requires an
instance of the enclosing


 outer class



8.Which statement is true?

  A. If only one thread is blocked in the wait method of an object,and
another thread executes


     the notify method on that same object,then the first thread
immediately resumes execution

  B. If a thread is blocked in the wait method of an object,and
another thread executes the

     notify method on the same object,it is still possible that the
first thread might never


resume execution

  C. If a thread is blocked in the wait method of an object,and
another thread executes the

     notify method on the same object,then the first thread definitely
resumes execution as a


 direct and sole consequence of the notify call

  D. If two thread is blocked in the wait method of one object,and
another thread executes the

     notify method on the same object,  then the thread that executed
the wait call first


definitly resumes execution as a direct and sole consequence of the
notify call



9.You are assigened the task of building a Panel containing a TextArea
at the top,a Label


directly below it,and a Button directly below the Label.If the three
components are added


directly to the Panel,which layout manager can the Panel use to ensure
that the TextArea


absorbs all of the free vertical space when the Panel is resized?

  A. GridLayout

  B. FlowLayout

  C. GridBagLayout

  D. CardLayout

  E. BorderLayout



10.Given:

  String foo="ABCDE";

  foo.substring(3);

  foo.concat("XYZ");





  What is the value of the variable foo at line 4?

  Shortanswer:



11.Which statement about static inner classes is true?

  A. An anonymous class can be declared as static

  B. A static inner class cannot be a static member of the outer class

  C. A static inner calss does not require an instance of the
enclosing class

  D. Instance members of a static inner class can be referenced using
the class name of the


static inner class



12.Which statement is true for the class java.util.ArrayList?

  A. The elements in the collection are ordered

  B. The collection is guaranteed to be immutable

  C. The elements in the collection are guaranteed to be immutable

  D. The elements in the collection are accessed using a unique key

  E. The elements in the collection are guaranteed to be synchronized



13.Which two cannot directly cause a thread to stop executing?

  A. exiting from a synchronized block

  B. calling the wait method on an object

  C. calling the notify method on an object

  D. calling the read method on an InputSteam object

  E. calling the setPriority method on a thread object



14.Given:

  public class SynchTest{

    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 will check() return true when called from a
different class?

  A. check() can never return true

  B. check() can return true when setXY is called by multiple threads

  C. check() can return true when multiple threads call setX and setY
deparately

  D. check() can only return true if SynchTest is changed to allow x and
 y to be set separately



15.Given:

  class A implements Runnable{

    int i;

    public void run(){

       try{

           Thread.sleep(50000);

           i=10;

       }catch(InterruptedException e){}

    }

  }



  public class Test{

    public static void main(String args[]){

       try{

           A a=new A();

           Thread t=new Thread(a);

           t.start();

  //line 17



          int j=a.i;

       }catch(Exception e){}

    }

  }



  Which statement at line 17 will ensure that j=10 at line 19?

  A. a.wait();

  B. t.wait();

  C. t.jion();

  D. t.yield();

  E. t.notify();

  F. a.notify();

  G. t.interrupt();

--


                偶然
                 我是天空里的一片云,
                 偶尔投影在你的波心.
                 *******你不必惊讶,

※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.0.180]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店