CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Java >  J2SE / 基础类

多多问题,请大家帮忙。

楼主orange2002(orange)2003-02-03 22:29:35 在 Java / J2SE / 基础类 提问

在网上找了份题,以下我用()括起来的是默认答案。  
  1》  
  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);   javajavac    
                }   string   类的对象本来就不可以改变,但StringBuffer   对象是可以改变的???  
                }    
          what   is   the   output?   (javajavac)    
  string   类的对象本来就不可以改变,但StringBuffer   对象是可以改变的???  
  不是说JAVA   的调用都是传值调用吗?何况上面两个函数都是VOID呀?  
   
  2》   public   class   ConstOver{    
          public   ConstOver(int   x,   int   y,   int   z){}    
            }    
          which   two   overload   the   ConstOver   constructor?    
          (A.)ConstOver(){}    
          B.protected   int   ConstOver(){}    
          (C.)private   ConstOver(int   z,   int   y,   byte   x){}    
          D.public   void   ConstOver(byte   x,   byte   y,   byte   z){}   //这个为什么不可以??  
          E.public   Object   ConstOver(int   x,   int   y,   int   z){}    
   
  3》class   BaseClass{    
          private   float   x=1.0f;    
          private   float   getVar(){return   x;}    
              }    
        class   SubClass   extends   BaseClass{    
          private   float   x=2.0f;    
          //insert   code    
          }    
        what   are   true   to   override   getVar()?    
        (A.)float   getVar(){    
        B.public   float   getVar(){    
        C.public   double   getVar(){    
        D.protected   float   getVar(){   //why   not?????  
        E.public   float   getVar(float   f){    
   
  4>>   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();    
   
  5》   public   class   Test{    
          public   static   void   main(String[]   args){    
          StringBuffer   a=new   StringBufer("A");    
          StringBuffer   b=new   StringBufer("B");    
          operate(a,b);    
          System.out.pintln(a+","+b);    
            }    
          public   static   void   operate(StringBuffer   x,   StringBuffer   y){    
            x.append(y);    
            y=x;   //y不可以指向x的对象吗?  
          }    
          }    
          what   is   the   output?   (ab,b)   和第一题很象  
   
  6》which   interface   Hashtable   implements?    
      (   A.)   java.util.Map   //同意的请举手  
        B.   java.util.List    
        C.   java.util.Hashable    
        D.   java.util.Collection    
   
  7》57.   which   two   interfaces   provide   the   capability   to   store   objects   using   a   key-value   pair?   //同上题。  
        (A.)   java.util.Map    
        B.   java.util.Set    
        C.   java.util.List    
        D.   java.util.SortedSet    
      (   E.)   java.util.SortedMap    
        F.   java.util.Collection    
   
  8》61.   which   two   statements   declare   an   array   capable   of   10   ints?   //这里是说十个数还是十bit?  
        (A).   int[]   foo;    
      (B).   int   foo[];   //这里是说十个数还是十bit?  
        C.   int   foo[10];    
        D.   Object[]   foo;    
        E.   Object   foo[10];    
   
  9>>是不是抽象类的子类必须把自己实现的方法定义为public?  
   
  10》83.   byte[]   array1,array2[]//array2[]是个多维数组???    
        byte   array3[][]    
        byte[][]   array4    
        if   each   has   been   initialized,   which   statement   will   cause   a   compile   error?    
        (A)array2=array1         B.array2=array3       C.array2=array4    
   
  10》   int   i=1,j=10;    
            do{    
                if(i>j)continue;    
                j--;    
                }while(++i<6);    
          what   are   the   vale   of   i   and   j?    
          (A)i=6,j=5   //我想i=6,j=4  
          B.i=5,j=5    
          C.i=6,j=4    
          D.i=5,j=6    
          E.i=6,j=6    
  11>>   public   class   Foo{    
            public   static   void   main(String[]   args){    
              int   i=1;    
              int   j=i++;    
              if((i>++j)&&(i++==j)){   //i>++j这个已经是FALSE了,省下不执行。  
                      i+=j;    
                      }    
                      }    
                    }    
          what   is   the   final   value   i   and   j?   (i=2,j=2)  
   
  12>>public   class   X{    
          public   static   void   main(String[]   args){    
              int[]   a=new   int[1];    
            4}   modify(a);    
              System.out.println(a[0]);    
              }    
              public   static   void   modify(int[]   a){   //这里是传地址还是传值调用  
            9}   a[0]++;}    
                }    
            what   is   the   result?    
            A.The   program   runs   and   prints   "0";    
          (   B).The   program   runs   and   prints   "1";    
            C.The   program   runs   but   aborts   with   an   exception;    
   
  13》class   Super{    
            public   int   i=0;    
            public   Super(String   text){    
            i=1;    
            }    
            }    
            public   class   Sub   extends   Super{    
                public   Sub(String   text){    
                  i=2;    
                }    
            public   static   void   main(String   args[]){    
              Sub   sub=new   Sub("Hello");    
              System.out.println(sub.i);    
              }    
              }    
            what   is   the   result?            
              A.   compile   will   fail   //why  
              B.   compile   success   and   print   "0"    
              C.   compile   success   and   print   "1"    
              D.   compile   success   and   print   "2"   //Sub都承继了i,为什么不可以访问。  
   
   
   
   
   
   
  问题点数:100、回复次数:3Top

1 楼helpall(was jl)回复于 2003-02-04 00:23:05 得分 50

The   difference   between   String   and   StringBuffer   is   that   StringBuffer   is   mutable   while   String   is   not.  
   
  So   String.replace(...)   will   create   a   new   String.   StringBuffer.repleace(...)   will   use   the   same   StringBuffer   object.   Actually   for   the   StringBuffer   case,   even   if   you   use   text.append("c");   The   result   will   be   the   same.Top

2 楼helpall(was jl)回复于 2003-02-04 00:44:48 得分 50

2》   constructor   can   not   have   return   type   :-)  
  4》   wait   for   the   t   thread   to   die   before   continue   processing.  
  5》   Well,   inside   the   operate(..)   function,   y   is   indeed   "ab"   if   you   want   to   print   the   value.   But   remember   this   y   is   only   a   copy   of   the   a,   which   is   a   pointer   to   the   original   "b".   So   y=x   just   let   y   points   to   "ab",   then   this   y   is   discarded,   the   b   outside   of   the   function   remains   the   same.  
  6》Why   don't   you   agree   with   it?   Hashtable   can   put   key   and   value,   it   is   a   kind   of   Map.  
  12》   Address.   Address   does   not   change.   Value   inside   changed.Top

3 楼orange2002(orange)回复于 2003-02-04 10:50:13 得分 0

多谢   helpall   ,新年快乐,恭喜发财!Top

相关问题

  • 请
  • 请
  • 请教!请教!
  • 请 请问???
  • 请进!请进?
  • 请进,请进....
  • 请教请教!!!
  • 请教!请教!
  • 请教,请教!!!
  • 请教~~请教!!!

关键词

  • constover
  • getvar
  • stringbuffer
  • textbuffer
  • textstring
  • 调用
  • util
  • array
  • 对象
  • float

得分解答快速导航

  • 帖主:orange2002
  • helpall
  • helpall

相关链接

  • CSDN Java频道
  • Java类图书
  • Java类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo