list.Add(\list.Add(\list.Add(\list.RemoveAt(1);
Console.WriteLine(list[1]);
a) Yahoo b) Sina c) Google
d) 代码出现运行错误
18) 在C#语言中,以下关于集合的说法错误的是()。 19)
a) b) c) d)
ArrayList只能通过索引来访问和删除值 Hashtable可以直接通过键名来获取值
使用List
分析如下C#程序,运行输出的结果是( )。 public struct Size {
public int x; public int y;
public Size(int x, int y) {
this.x = x; this.y = y; } }
class Test {
static void Main() {
Size size1 = new Size(8,10); Size size2 = size1; size1.y = 200;
Console.WriteLine(\ } } a) 200 | 200 b) 200 | 10 c) 10 | 10
d) 10 | 200
20) 假设要使用C#设计一个日志系统,要求程序运行时,检查 system.log 文件是否存在,如果已经存在则直接打开,如果不存在则创建一个,为了实现这个目的,应该以FileMode的( )方式创建文件流。 a) CreateNew b) Open c) OpenOrCreate d) Create
21) 下面关于单例模式说法错误的是()。
a) 在单例模式中,允许通过new 构造实例 b) 单例模式确保某个类只有一个实例,而且自行实例化并向整个系统提供这个实例 c) 在C# 中,static 是实现单例模式的重要关键字 d) 单例模式可以确保所有对象都访问唯一的实例
22) 下面不是C#中类的访问修饰符的是()。 a) protected b) internal c) public d) internal protected
23) 在C#中,下面关于结构的说法中,正确的是()。
a) b) c) d)
24) 关于如下C#的代码,说法正确的是();
public class A {
string S1;
protected string S2; protected void M1() {} }
public class B : A {
protected string S3; }
结构和类都是引用类型 定义结构的变量必须用new
不能在定义结构时给结构的成员设置初始值 结构中的整型成员被自动初始化为1
a) b) c) d)
在A中可以访问S3 在B中可以访问S1 在B中可以访问S2 在M1( ) 中可以访问S3
25) 关于如下C#代码的说法中,正确的是()。
public class Test //⑴ {
private static int Max = 100; //⑵ public Test(int max) {
Max = max; //⑶ }
public int GetMax() {
return Max; //⑷ } }
a) b) c) d)
26) 在C#中,下面是方法的重载的是()。
a) public string Test(int x, int y){ ?}和public string Test(int a, int b){ ?} b) public string Test1(int x, int y){ ?}和public string Test2(int x, int y){ ?} c) public string Test(int x, int y){ ?}和public string Test(int a){ ?} d) public string Test(int x, int y){ ?}和public int Test(int x, int y){ ?}
27) 下面C#代码执行的结果是()。
public class A { } public class B : A {
static void Main() {
A a = new A(); B b = a as B; if (b == null)
Console.WriteLine(\
在⑴行中必须将Test类定义为静态类
在⑵中不能将静态成员Max定义为private的 在⑶中不能给静态成员Max赋值 在⑷中可以使用静态成员Max
else
Console.WriteLine(b is A); } }
a) null b) True c) False d) 出现异常
28) 如下C#代码的执行结果是()。
public class Test {
public int i = 1; public Test(int i) {
this.i += i; }
static void Main() {
Test t = new Test(2); Console.WriteLine(t.i); } }
a) b) c) d)
29)有如下C# 代码,则下面选项中说法正确的是()。
public class A { } public class B : A { } A a = new A(); B b = new B();
a) b) c) d)
表达式a is B的值为true 表达式b is A的值为true 表达式a as B的值为null 表达式b as A的值为null 1 2 3 4
30) a) b) c) d) 在C#中,下面类型中是引用类型的是()。 DialogResult枚举 System.Int64 string
StringBuilder
二 简答题:
1.请简述泛型集合List
2.面向对象的三大特性是什么?并简述每个原则的基本功能。
《深入.NET平台和C#编程》内部测试题-笔试试卷答案
答案
一、选择题 1、c 6、a 11、d 16、d 21、a 26、c
2、a 7、c 12、c 17、c 22、d 27、a 3、c 8、b 13、d 18、c 23、c 28、c 4、b 9、bc 14、d 19、b 24、c 29、bc 5、d 10、d 15、c 20、c 25、d 30、cd
二 简答题 1、要点:
? List
? ArrayList与List
? ArrayList与List
? ArrayList获取元素时需要类型转换,List
? 同一个ArrayList可以保存不同类型的元素,List
2、要点:
? 封装:保证对象自身数据的完整性、安全性;
? 继承:建立类之间的关系,实现代码复用,方便系统的扩展; ? 多态:相同的方法调用可实现不同的实现方式。