发布时间 : 星期三 文章C#试题库(全)附 参考答案更新完毕开始阅读
272、静态类和实例类的区别在于:静态类不需要初始化即可直接使用,实例类需要进行实例化,生成对象才可使用。√
273、菜单项标题中有含有带下划线的字符,这是快捷键。(×)
274、在C#中,子类不能继承父类中用private修饰的成员变量和成员方法。√ 275、.在C#中,所有类都是直接或间接地继承System.Object类而得来的。√ 276、函数是C#程序的基本单位。(×)
277、在类作用域中能够通过直接使用该类的任何成员名进行访问。√ 278、C#语言中,值类型包括:基本值类型、结构类型和枚举类型。√ 279、C#语言中,值类型包括:基本值类型、结构类型和整数类型。(×) 280、salary属于C#语言的关键字。(×) 281、在C#中,接口可以被多重继承而类不能。√
282、接口中的成员不可以有访问域修饰符,但可以有其它修饰符。× 283、在C#中,装箱操作是将值类型转化成引用类型√ 284、任何事物都是对象。√
285、析构函数是自动调用的,它也可以被显式调用。× 286、用ref修饰符声明的形参是引用形参。√ 287、用out修饰符声明的形参是输出形参。√
288、从用户的角度看,变量是存储信息的基本单元,在变量中可以存储各种类型事物信息√ 289、如果在try块之后没有任何catch块,那么finally块也是可选的。×
290、当创建派生类对象时,先执行基类的构造函数,后执行派生类的构造函数。√
291、如果基类没有默认的构造函数,那么其派生类构造函数必须通过base关键字来调用基类的构造函数。√
292、对象与对象之间的关系可以分为三类:包含、继承和关联。√
293、在C# 2005编程环境中,int32型变量可以直接隐式的转换成char型变量。× 294、“+,-,*,/,%”均属于三元运算符。×
295、属性就是实体特征的抽象,比如,对象猫可以有重量,身长等属性。√ 296、在同一行代码或同一段语句中,等于运算符的优先级别高于关系运算符。√
297、.NET Framework运行环境除了支持VB.net和C#两种编程语言,还支持Perl、C++.NET、J#、Jscript.NET、ActionScript。×
298、在C#中可以使用String作为变量名,但不能使用string作为变量名。√ 299、在C#中,每个方法都必须定义为类或结构的成员。√
300、在一个程序内,不可以包含2个及以上的Main方法。√ 四、读程序写结果和看程序填空 1、 class Program
{
static void Main(string[] args) {
Tiger t = new Tiger(); Console.Read(); } }
class Animal {
public Animal()
{ Console.Write (\基类\ } }
class Tiger : Animal {
public Tiger()
{ Console.Write (\派生类\ }
程序的运行结果是_____基类派生类______________
2、 class Program {
static void Main(string[] args) {
Elephant e = new Elephant(\ Console.ReadLine(); } }
public class Animal {
public Animal() {
Console.Write (\基类默认构造函数!\ }
public Animal(string s) {
Console.Write (\非默认构造函数\ } }
public class Elephant : Animal {
public Elephant() {
Console.Write (\派生类构造函数!\ }
public Elephant(string str) : base(str) {
Console.Write (str); } }
程序的运行结果是______非默认构造函数abc __________
3.在Main方法中需要调用Display方法,按照要求填空
class Program {
static void Main(string[] args) {
A1 a = new A1(); //创建A1类的对象a Console.WriteLine(a.Display()); Console.ReadLine(); }
} class A1 {
public string Display() {
return \ } }
4、
下列程序完成了调用静态方法和实例方法,补充空白处并写出运行结果class Program {
static void Main(string[] args) {
Example e1 = new Example(); e1.meth1();
Example.meth2(); //调用meth2() Console.WriteLine(\ Console.ReadLine(); } }
class Example {
public int a; static public int b; public void meth1() {
a = 10; b = 20; }
public static void meth2()
{
b = 30; }
程序的输出结果是_________a=10,b=30_______________
5、
class Program
{
static void Main(string[] args) {
s s1 = new s(); s t1 = new s(); Console.ReadLine(); } }
public class s {
public s()
{Console.Write (\构造函数!\ static s()
{Console .Write (\静态构造函数!\ }
程序的运行结果是_____静态构造函数!构造函数!构造函数!__________________
6、 class Program
{
static void Main(string[] args) {
Person p = new Person(); p.N = \
Console.WriteLine(p.N ); Console.ReadLine(); } }
public class Person {
private string p_name=\ public string N {
get { return p_name; } set { p_name = value; } } }
程序最终的输出结果是_www__ 7、class Program
{
static void Main(string[] args) {
B b = new B(); A a = b; a.G(); b.G();
Console.Read(); }
} class A {
public virtual void G() {
Console.Write (\ } } class B : A {
public override void G()
{
Console.Write (\ } }
程序的输出结果是___ B.G!B.G!__________________________
8、
下列程序完成了输出数组中的最大值和最小值,请补充程序中的空白处 class Program {
static void Main(string[] args) {
MyClass m = new MyClass(); int[] s ={ 1, 6, 4, 7, 3, 87, 5 }; int smax, smin;
m.MaxMin(s, out smax, out smin); Console.WriteLine(\ Console.ReadLine(); } }
class MyClass {
public void MaxMin(int[] a, out int max, out int min) {
max = min = a[0];
for (int i = 1; i < a.Length; i++) {
if (a[i] > max) max = a[i]; if (a[i] < min) min = a[i]; } } }
9、 下列程序完成了调用静态方法和实例方法,补充空白处并写出运行结果
class Program {
static void Main(string[] args) {
Example e1 = new Example(); e1.meth1(); Example.meth2();
Console.WriteLine(\ Console.ReadLine(); } }
class Example {
public int a; static public int b; public void meth1() {
a = 10; b = 20; }
public static void meth2() {
b = 30; }
程序的输出结果是____ a=10,b=30_________________
10、class Program
{
static void Main(string[] args) {
Triangle t = new Triangle(3, 4); double s = t.area();