posts - 108,comments - 56,trackbacks - 0
                ☆來自網(wǎng)絡(luò),都是基礎(chǔ)題目

                ☆Please write the output result :
          public class Test {
              
          public static void changeStr(String str){
                  str
          ="welcome";
              }
              
          public static void main(String[] args) {
                  String str
          ="1234";
                  changeStr(str);
                  System.out.println(str);
              }
          }
          答案


                ☆What is the result?
          public class Test {
              
          static boolean foo(char c) {
                  System.out.print(c);
                  
          return true;
              }
              
              
          public static void main( String[] argv ) {
                  
          int i =0;
                  
          for ( foo('A'); foo('B')&&(i<2); foo('C')){
                      i
          ++ ;
                      foo(
          'D');
                  }
              }
          }
          A. ABDCBDCB
          B. ABCDABCD
          C. Compilation fails.
          D. An exception is thrown at runtime.
          答案


                ☆Which two are valid in a class that extends class A? (Choose two)
          class A {
              
          protected int method1(int a, int b) { return 0; }
          }
          A. public int method1(int a, int b) { return 0; }
          B. 
          private int method1(int a, int b) { return 0; }
          C. 
          private int method1(int a, long b) { return 0; }
          D. 
          public short method1(int a, int b) { return 0; }
          E. 
          static protected int method1(int a, int b) { return 0; }
          答案


                ☆Which instantiates an instance of Inner?
          public class Outer {
              
          public void someOuterMethod() {
                  
          // Line 3
              }
              
          public class Inner {
              }
              
          public static void main(String[] argv) {
                  Outer o 
          = new Outer();
                  
          // Line 8
              }
          }
          A. new Inner(); // At line 3
          B. new Inner(); // At line 8
          C. new o.Inner(); // At line 8
          D. new Outer.Inner(); // At line 8//new Outer().new Inner()
          答案


                ☆找錯(cuò)?
          public class Test {
              
          public Test(int a){
                  
              }
              
              
          public static void main(String args[]){
                  Test t
          =new Test();
              }
          }
          答案


                ☆輸出結(jié)果
              System.out.println(1+'\2');
              System.out.println(
          1+'2');
              System.out.println(
          1+2+"3"+4+5);
          答案
          posted on 2008-03-08 17:53 破繭而出 閱讀(711) 評(píng)論(1)  編輯  收藏 所屬分類: Java七七八八

          FeedBack:
          # re: Java試題
          2008-07-25 21:59 | tetyetyeg
          cgdfghdfdgfdgf  回復(fù)  更多評(píng)論
            
          主站蜘蛛池模板: 嘉义县| 澄江县| 翁源县| 清原| 佛学| 资中县| 玉门市| 会同县| 土默特左旗| 辛集市| 舞阳县| 新龙县| 浦县| 田阳县| 宜黄县| 灵宝市| 无棣县| 灌云县| 乌苏市| 察隅县| 民勤县| 洪洞县| 巴马| 衡东县| 敖汉旗| 渭源县| 明溪县| 林芝县| 谷城县| 金塔县| 旌德县| 盐亭县| 丰宁| 吕梁市| 福州市| 涟源市| 五指山市| 蒙自县| 长治县| 杨浦区| 顺昌县|