【正文】
{ …}和public int Test(int x, int y){ …}27) 下面C代碼執(zhí)行的結(jié)果是()。public class A { }public class B : A{ static void Main() { A a = new A()。 B b = a as B。 if (b == null) (null)。 else (b is A)。 }} a) nullb) Truec) Falsed) 出現(xiàn)異常28) 如下C代碼的執(zhí)行結(jié)果是()。public class Test{ public int i = 1。 public Test(int i) { += i。 } static void Main() { Test t = new Test(2)。 ()。 }} a) 1b) 2c) 3d) 429)有如下C 代碼,則下面選項(xiàng)中說法正確的是()。public class A { }public class B : A { }A a = new A()。B b = new B()。a) 表達(dá)式a is B的值為trueb) 表達(dá)式b is A的值為truec) 表達(dá)式a as B的值為nulld) 表達(dá)式b as A的值為null30) 在C中,下面類型中是引用類型的是()。a) DialogResult枚舉b) c) stringd) StringBuilder二 簡答題:1.請簡述泛型集合ListT中“T”的含義和作用。并說明ListT與ArrayList的異同。2.面向?qū)ο蟮娜筇匦允鞘裁矗坎⒑喪雒總€(gè)原則的基本功能。《編程》內(nèi)部測試題筆試試卷答案答案一、選擇題c a c b da c b bc d1d 1c 1d 1d 1c1d 1c 1c 1b c2a 2d 2c 2c 2d2c 2a 2c 2bc cd二 簡答題要點(diǎn):n ListT中的T可以對集合中的元素類型進(jìn)行約束;n T表明集合中管理的元素類型;n ArrayList與ListT都使用索引訪問元素;n ArrayList與ListT可以通過索引刪除、也可以直接刪除對象;n ArrayList與ListT遍歷時(shí)直接遍歷元素對象;n ArrayList獲取元素時(shí)需要類型轉(zhuǎn)換,ListT不需要類型轉(zhuǎn)換;n 同一個(gè)ArrayList可以保存不同類型的元素,ListT只能保存T允許的類型。要點(diǎn):n 封裝:保證對象自身數(shù)據(jù)的完整性、安全性;n 繼承:建立類之間的關(guān)系,實(shí)現(xiàn)代碼復(fù)用,方便系統(tǒng)的擴(kuò)展;n 多態(tài):相同的方法調(diào)用可實(shí)現(xiàn)不同的實(shí)現(xiàn)方式。