为private的
c) 在⑶中不能给静态成员Max赋值
d) 在⑷中可以使用静态成员Max
26) 在C#中,下面是方法的重载的是(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#代码执行的结果是(A)。
public class A{ }
public class B : A
{
static void Main()
{
A a = new A();
B b = a as B;
if (b == null)
Console.WriteLine("null");
else
Console.WriteLine(b is A);
}
}
a) null
b) True
c) False
d) 出现异常
28) 如下C#代码的执行结果是(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) 1
b) 2
c) 3
d) 4
29)有如下C# 代码,则下面选项中说法正确的是(BC)。
public class A { }
public class B : A { }
A a = new A();
B b = new B();
a) 表达式a is B的值为true
b) 表达式b is A的值为true
c) 表达式a as B的值为null
d) 表达式b as A的值为null
30) 在C#中,下面类型中是引用类型的是(CD)。
a) DialogResult枚举
b) System.Int64
c) string
d) StringBuilder
二 简答题:
1.请简述泛型集合List<T>中“T”的含义和作用。并说明List<T>与ArrayList的异同。
List<T>中的T可以对集合中的元素类型进行约束;
T表明集合中管理的元素类型;
ArrayList与List<T>都使用索引访问元素;
ArrayList与List<T>可以通过索引删除、也可以直接删除对象;
ArrayList与List<T>遍历时直接遍历元素对象;
ArrayList获取元素时需要类型转换,List<T>不需要类型转换;
同一个ArrayList可以保存不同类型的元素,List<T>只能保存T允许的类型。
2.面向对象的三大特性是什么?并简述每个原则的基本功能。
封装:保证对象自身数据的完整性、安全性;
继承:建立类之间的关系,实现代码复用,方便系统的扩展;
多态:相同的方法调用可实现不同的实现方式。