Java錯題

來源:互聯網
上載者:User

標籤:cas   tput   space   alt   string   ext   ack   choice   radio   

加粗為正確答案,綠色為錯選答案

 

1.對於以下代碼:

  1. for ( int i=0; i<10; i++)

     System.out.println(i);

for迴圈後,i的值是多少?

 

  • A.i不再存在了(i定義在for迴圈裡面)
  • B.9
  • C.11
  • D.10
5以下程式碼片段編譯啟動並執行結果是:
  1. int Output=10;
  2. boolean b1 = false;
  3. if((b1==true) && ((Output+=10)==20)){
  4.     System.out.println("We are equal "+Output);
  5. } else {
  6.     System.out.println("Not equal! "+Output);
  7. }
  • A.輸出"Not equal! 20"?
  • B.輸出"We are equal 10"
  • C.輸出"Not equal! 10"(跟c語言機制一樣,在判斷b1==true為假後就不在判斷後面的了
  • D.編譯錯誤

 

19.下面的方法,當參數值為2的時候傳回值是多少
  1. public int getValue(int i) {
  2.          int result = 0;
  3.          switch (i) { 
  4.             case 1: 
  5.                 result = result + i; 
  6.             case 2: 
  7.                 result = result + i  * 2; 
  8.             case 3: 
  9.                 result = result + i  * 3; 
  10.         } 
  11.         return result; 
  12.  }
  • A.10(沒有break)
  • B.8
  • C.4
  • D.0
正確答案:A你錯選為C 23.Java的各種資料類型佔用固定長度,與具體的軟硬體平台環境無關
  • A.對
  • B.錯
正確答案:B你錯選為A 

Java錯題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.