[單項選擇題] 給出下面代碼段: public class Test{ public static void main(String args[]) {
2021-07-20
[單項選擇題] 給出下面代碼段: public class Test{ public static void main(String args[]) {int m;switch(m){ case 0 :System.out.println("case 0"); case 1 :System.out.println("case 1"); break; case 2 :break; default :System.out.println("default");} } } 下列m的值能引起輸出“default”的是( )。
A. 0
B. 1
C. 2
D. 4
正確答案:D
參考解析:本題考查條件語句switch的應(yīng)用。此代碼段最后輸出default,則表示m的值不能為0、1和2三者其中之一,故m的值只能選擇D。
詞條內(nèi)容僅供參考,如果您需要解決具體問題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。