wangchao.org
添加收藏 | 博客
 
购物视频论坛IT业界自然风光美女图片王朝网络小游戏BT下载生活百科编程设计手机图铃小说
 
笑话 | 水库 | 娱乐 | 体育 | 英语 | 宠物 | 美食 | 旅游 | 养生 | 手机 | 数码 | 汽车 | 珠宝 | 美容 | 装修 | 厨房 | 科普 | 动物 | 植物 | 影音 | 百科 | 知道 | 词典
  
 
 您好! 您现在位于: 王朝网络 → 编程设计 → 《SCJP模拟题104道返回上一页 
 
1楼 

SCJP模拟题104道

  网上购物、在线购物、购物搜索 欢迎光临本站购买图书、影视、音乐、数码、百货,手机等商品。

  Simulated Test of SCJP for Java2 PlatFORM
   (only for training)
  
  1. 1) public class ReturnIt{
  2) returnType methodA(byte x, double y){
  3) return (short)x/y*2;
  4) }
  5) }
  what is valid returnType for methodA in line 2?
  Answer:double
  2. 1) class Super{
  2) public float getNum(){return 3.0f;}
  3) }
  4)
  5) public class Sub extends Super{
  6)
  7) }
  which method, placed at line 6, will cause a compiler error?
  A. public float getNum(){return 4.0f;}
  B. public void getNum(){}
  C. public void getNum(double d){}
  D. public double getNum(float d){return 4.0d;}
  Answer:B
  3. public class IfTest{
  public static void main(String args[]){
   int x=3;
  int y=1;
  if(x=y)
  System.out.println("Not equal");
  else
  System.out.println("Equal");
  }
  }
  what is the result?
  Answer:compile error
  4. public class Foo{
   public static void main(String args[]){
   try{return;}
   finally{ System.out.println("Finally");}
   }
   }
  what is the result?
  A. print out nothing
  B. print out "Finally"
  C. compile error
  Answer:B
  5. public class Test{
   public static String output="";
   public static void foo(int i){
   try {
  if(i==1){
  throw new Exception();
  }
  output +="1";
  }
  catch(Exception e){
  output+="2";
  return;
  }
  finally{
  output+="3";
   }
  output+="4";
  }
  public static void main(String args[]){
  foo(0);
  foo(1);
  24)
   }
   }
  what is the value of output at line 24?
  Answer:13423
  6. public class IfElse{
  public static void main(String args[]){
  if(odd(5))
  System.out.println("odd");
  else
  System.out.println("even");
  }
   public static int odd(int x){return x%2;}
   }
   what is output?
  
  Answer:Compile Error
  
  7. class ExceptionTest{
   public static void main(String args[]){
   try{
  methodA();
  }
   catch(IOException e){
  System.out.println("caught IOException");
   }
   catch(Exception e){
   System.out.println("caught Exception");
   }
   }
   }
  If methodA() throws a IOException, what is the result?
  Answer:caught IOException
  exception can catch once only
  if change the sequence of catch
   catch(IOException e) can't execute and compiler will report rongyu error
  
  8. int i=1,j=10;
  do{
  if(i++--j) continue;
  }while(i
  After Execution, what are the value for i and j?
  A. i=6 j=5
  B. B.i=5 j=5
  C. i=6 j=4
  D. i=5 j=6
  E. i=6 j=6
  Answer:D
  
  9. 1)public class X{
  2) public Object m(){
  3) Object o=new Float(3.14F);
  4) Object[] oa=new Object[1];
  5) oa[0]=o;
  6) o=null;
  7) oa[0]=null;
  System.out.println(oa[0]);
  9) }
  10) }
  which line is the earliest point the object a refered is definitely elibile
  to be garbage collectioned?
  A.After line 4 B. After line 5 C.After line 6
  D.After line 7 E.After line 9(that is,as the method returns)
  Answer:D
  
  10. 1) interface Foo{
   2)int k=0;
   3) }
   4) public class Test implements Foo{
   5) public static void main(String args[]){
   6)int i;
   7)Test test =new Test();
   8)i=test.k;
   9)i=Test.k;
   10)i=Foo.k;
   11) }
   12) }
   what is the result?
  Answer:compile sUCcessed and i=0
  11. what is reserved Words in java?
   A. run
   B. default
   C. implement
   D. import
  Answer:B,D
  12. public class Test{
   public static void main(String[] args){
   String foo=args[1];
   Sring bar=args[2];
   String baz=args[3];
   }
   }
   java Test Red Green Blue
   what is the value of baz?
   A. baz has value of ""
   B. baz has value of null
   C. baz has value of "Red"
   D. baz has value of "Blue"
   E. baz has value of "Green"
   F. the code does not compile
   G. the program throw an exception
  Answer:G
  13. int index=1;
   int foo[]=new int[3];
   int bar=foo[index];
   int baz=bar+index;
   what is the result?
   A. baz has a value of 0
   B. baz has value of 1
   C. baz has value of 2
   D. an exception is thrown
   E. the code will not compile
  Answer:B
  14. which three are valid declaraction 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;
  Answer:A,D,F
  15. public class Foo{
   public static void main(String args[]){
   String s;
   System.out.println("s="+s);
   }
   }
   what is the result?
  Answer:compile error
  16. 1) public class Test{
   2) public static void main(String args[]){
   3) int i=oxFFFFFFF1;
   4) int j=~i;
   5)
   6) }
   7) }
   which is decimal value of j at line 5?
   A. 0 B.1 C.14 D.-15 E. compile error at line 3
   F. compile error at line 4
  Answer:C
  17. float f=4.2F;
   Float g=new Float(4.2F);
   Double d=new Double(4.2);
   Which are true?
   A. f==g B. g==g C. d==f D. d.equals(f) E d.equals(g) F. g.equals(4.2);
  Answer:B,E
  18. public class Test{
   public static void add3(Integer i){
  3) int val=i.intvalue();
   val+=3;
   i=new Integer(val);
   }
   public static void main(String args[]){
   Integer i=new Integer(0);
   add3(i);
   System.out.println(i.intvalue());
   }
   }
   what is the result?
   A. compile fail B.print out "0" C.print out "3"
   D.compile succeded but exception at line 3
  Answer:B
  19. public class Test{
   public static void main(String[] args){
   System.out.println(6^3);
   }
   }
   what is output?
  Answer:5
  ^ is yi huo
  20. public class Test{
   public static void stringReplace(String text){
   text=text.replace('j','l');
   }
   public static void bufferReplace(StringBuffer text){
   text=text.append("c");
   }
   public static void main(String args[]){
   String textString=new String("java");
   StringBuffer textBuffer=new StringBuffer("java");
   StringReplace(textString);
   bufferReplace(textBuffer);
   System.out.println(textString+textBuffer);
   }
   }
   what is the output?
  Answer:javajavac
  21. public class ConstOver{
   public ConstOver(int x, int y, i

   Simulated Test of SCJP for Java2 PlatFORM    (only for training)         1. 1) public class ReturnIt{    2) returnType methodA(byte x, double y){    3) return (short)x/y*2;    4) }    5) }    what is valid returnType for methodA in line 2?   Answer:double      2. 1) class Super{    2) public float getNum(){return 3.0f;}    3) }    4)    5) public class Sub extends Super{    6)    7) }   which method, placed at line 6, will cause a compiler error?   A. public float getNum(){return 4.0f;}   B. public void getNum(){}   C. public void getNum(double d){}   D. public double getNum(float d){return 4.0d;}   Answer:B      3. public class IfTest{    public static void main(String args[]){    int x=3;    int y=1;    if(x=y)    System.out.println("Not equal");    else    System.out.println("Equal");    }    }    what is the result?   Answer:compile error      4. public class Foo{    public static void main(String args[]){    try{return;}    finally{ System.out.println("Finally");}    }    }    what is the result?    A. print out nothing    B. print out "Finally"    C. compile error   Answer:B      5. public class Test{    public static String output="";    public static void foo(int i){    try {   if(i==1){   throw new Exception();   }   output +="1";    }    catch(Exception e){    output+="2";    return;    }    finally{    output+="3";    }    output+="4";    }    public static void main(String args[]){    foo(0);    foo(1);    24)    }    }    what is the value of output at line 24?      Answer:13423      6. public class IfElse{    public static void main(String args[]){    if(odd(5))    System.out.println("odd");    else    System.out.println("even");    }    public static int odd(int x){return x%2;}    }    what is output?         Answer:Compile Error         7. class ExceptionTest{    public static void main(String args[]){    try{   methodA();   }    catch(IOException e){   System.out.println("caught IOException");    }    catch(Exception e){    System.out.println("caught Exception");    }    }    }    If methodA() throws a IOException, what is the result?   Answer:caught IOException   exception can catch once only   if change the sequence of catch    catch(IOException e) can't execute and compiler will report rongyu error         8. int i=1,j=10;    do{    if(i++--j) continue;    }while(i   After Execution, what are the value for i and j?   A. i=6 j=5   B. B.i=5 j=5   C. i=6 j=4   D. i=5 j=6   E. i=6 j=6   Answer:D         9. 1)public class X{    2) public Object m(){    3) Object o=new Float(3.14F);    4) Object[] oa=new Object[1];    5) oa[0]=o;    6) o=null;    7) oa[0]=null;    System.out.println(oa[0]);    9) }    10) }    which line is the earliest point the object a refered is definitely elibile    to be garbage collectioned?    A.After line 4 B. After line 5 C.After line 6    D.After line 7 E.After line 9(that is,as the method returns)   Answer:D         10. 1) interface Foo{    2)int k=0;    3) }    4) public class Test implements Foo{    5) public static void main(String args[]){    6)int i;    7)Test test =new Test();    8)i=test.k;    9)i=Test.k;    10)i=Foo.k;    11) }    12) }    what is the result?   Answer:compile sUCcessed and i=0      11. what is reserved Words in java?    A. run    B. default    C. implement    D. import   Answer:B,D      12. public class Test{    public static void main(String[] args){    String foo=args[1];    Sring bar=args[2];    String baz=args[3];    }    }    java Test Red Green Blue    what is the value of baz?    A. baz has value of ""    B. baz has value of null    C. baz has value of "Red"    D. baz has value of "Blue"    E. baz has value of "Green"    F. the code does not compile    G. the program throw an exception   Answer:G      13. int index=1;    int foo[]=new int[3];    int bar=foo[index];    int baz=bar+index;    what is the result?    A. baz has a value of 0    B. baz has value of 1    C. baz has value of 2    D. an exception is thrown    E. the code will not compile   Answer:B      14. which three are valid declaraction 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;   Answer:A,D,F      15. public class Foo{    public static void main(String args[]){    String s;    System.out.println("s="+s);    }    }    what is the result?   Answer:compile error      16. 1) public class Test{    2) public static void main(String args[]){    3) int i=oxFFFFFFF1;    4) int j=~i;    5)    6) }    7) }    which is decimal value of j at line 5?    A. 0 B.1 C.14 D.-15 E. compile error at line 3    F. compile error at line 4   Answer:C      17. float f=4.2F;    Float g=new Float(4.2F);    Double d=new Double(4.2);    Which are true?    A. f==g B. g==g C. d==f D. d.equals(f) E d.equals(g) F. g.equals(4.2);   Answer:B,E      18. public class Test{    public static void add3(Integer i){    3) int val=i.intvalue();    val+=3;    i=new Integer(val);    }    public static void main(String args[]){    Integer i=new Integer(0);    add3(i);    System.out.println(i.intvalue());    }    }    what is the result?    A. compile fail B.print out "0" C.print out "3"    D.compile succeded but exception at line 3   Answer:B      19. public class Test{    public static void main(String[] args){    System.out.println(6^3);    }    }    what is output?   Answer:5   ^ is yi huo      20. public class Test{    public static void stringReplace(String text){    text=text.replace('j','l');    }    public static void bufferReplace(StringBuffer text){    text=text.append("c");    }    public static void main(String args[]){    String textString=new String("java");    StringBuffer textBuffer=new StringBuffer("java");    StringReplace(textString);    bufferReplace(textBuffer);    System.out.println(textString+textBuffer);    }    }    what is the output?   Answer:javajavac      21. public class ConstOver{    public ConstOver(int x, int y, i

 
标签: 104  SCJP  模拟  
 
您可以将本页贴到其他网站
UBB代码HTML代码
 
 
 
 
 
 
 更多内容
 ·SCJP1.4高效率复习提纲 ·刚过了SCJP,分享我的体会! ·SCJP 中文大纲 ·现在应该考 SCJP 1.2 还是 SCJP
 ·[精品网址]JAVA学习网站 ·我的Java培训与学习之路 ·Java走势分析 ·对比C++和Java
 ·学习笔记之JAVA图形设计卷I AWT— ·Java 2 新的焦点子系统 ·消除关于.NET的四个误解 ·.Net和Java应融合
 ·带你步入J2EE殿堂:最易懂的J2EE ·Apache如日中天,微软奋起直追 ·XML带来的好处 ·为Java加速 ——JBuilder 6可视化
 ·JBoss与Sun的Java标准之争日趋严 ·垃圾! ·Java IDE漫谈(-)—— VAJ之后 ·为什么要学习Java,成为Java程序
 ·Sun让软件没有国界 ·SCJP考生的顾虑! ·Sun授权ASEC-Java培训中心(表) ·关于 Java
 
 
最新评论  点此查看所有评论
 
 
 
 
发表评论(支持UBB码)


验证码:  
 
 
 
© 2005- 王朝网络 版权所有