北航软院2014级C#期末考试部分考题解答
博主注:本渣渣水平有限,文中若有不对的地方敬请指出,谢谢。
本文中大部分图片来自老师的PPT,感谢邵老师,想要的可以点击右边QQ联系我:)
一、选择
6.Which of the following is wrong?
①Abstract class could contain non abstract method//抽象类可能没有抽象方法
②A class containing abstract method must be a abstract class.//含有抽象方法的类一定是抽象类
③An abstract class cannot be instantiated.//不能实例化
④An abstract class can be sealed class.
解答:基础知识
7. Which of the following is right use of generic?
①List<int> f = new List<int>()
②List<int> f = new List()
③List f = new List()
④List<int> f = new List<int>
解答:通用类的使用方法

8.Which of the statements is correct to declare a two-dimensional array in C#?
①int[][] a
②int a[][]
③int[2]a
④int a[2]
解答:创建数组
//一维
int[] a = new int[];
int[] b = new int[] { , , };
int[] c = { , , }; //非矩阵二维数组
//int wrong1[1][2];//错误 int[][] aa = new int[][];// array of references to other arrays
aa[] = new int[] { , , };// cannot be initialized directly
aa[] = new int[] { , , }; //矩阵二维数组
int[,] aaa = new int[, ];// block matrix
int[,] bbb = { { , , }, { , , } };// can be initialized directly
int[,,] ccc = new int[, , ];
9.A property’s ______ accessor enable a client to modify the value of the instance variable associated with the property.
①base ②this ③get ④set
10. Only the methods that are declared as ______ can be overridden in subclass.
①abstract ②virtual ③new ④override
15. In .NET Framework class library, all multithread application related classes are in which following namespace?
①System.SysThread
②System.Thread
③System.Threading
④NetException
17. In C# variables confined by which of the following modifies can only be accessed by the current assembly?
①public ②protected ③internal ④private
解答:

17.Which of the following is the right output?
using System;
class A
{
struct Student
{
public int age;
public string name;
public Student(int age,string name)
{
this.age = age;
this.name = name;
}
}; static void Main(string[] args)
{
Student stu1 = new Student(, " Tom");
Student stu2 = new Student(, " Jerry");
stu2 = stu1;
stu1.age = ;
stu1.name = "Jerry";
Console.Write(stu2.age);
Console.Write(stu2.name); Console.ReadKey();
}
}
①18 Tom ②18 Jerry ③30 Jerry ④30 Tom
解答:结构体实值类型,赋值之后就把<18,Tom>给了stu2,不管你stu1怎么变,与stu2无关。
18. Which of the following results is the right output?
ArrayList arr = new ArrayList();
int[] num = { 1, 3, 5 };
for (int i = 0; i < num.Length; i++)
{
arr.Add(num[i]);
}
arr.Insert(1, 4);
Console.WriteLine(arr[2]);
①1 ②3 ③4 ④5
解答:了解insert函数的定义就知道啦。

19.Which of the following description is true about the keyword “ref”?
①”ref” only passes values from caller(调用者)to callee(被调者)
②”ref” only passes values from the callee to caller
③”ref” must be initialized before its method is called.//方法被调用之前,必须初始化
④None of above
解答:VS爸爸最厉害~

20.Which of the following description about constants is true?
①Declare the constants with the keyword “static”
②The constants must be initialized when declaring.
③Constants can be assigned repeatedly.
④Constants can be declared first and assigned later.
解答:常量的基本知识

二、判断
1.Only one method can be called using a delegate.
解答:(F)

2.If no constructor was declared in a class, the compiler generates default constructor which has no parameter.
解答:(T)可能类不是亲生的吧。(PPT115页)

3.All methods in an abstract class must be declared as abstract methods.
解答:(F)没这个道理!道理在下面(PPT146页):

4.If a base class declares an abstract method, a derived class must implement that method.
解答:(F)派生类确实要实现所有抽象方法,但是派生类也可以继续是抽象的呀!,这样就不用管实不实现了。
5.Sizeof can be applied to reference types.
解答:(F)

6.One file could have multiple namespaces.
解答:(T)PPT197页

7.Nested types can be interfaces and delegates.
解答:(T)PPT131页

8.If a method is marked as Protected, it will be able to access in the derived class.
解答:(T)

9.Sizeof can be applied to reference types.(重复了啊啊啊)
10.If a base declares an abstract method, a derived class should implement that method.(握草一个should一个must,搞什么鬼!)
三、填空
1.In C#, the type System.Int32 map to keyword _____int______
解答:这个还真没仔细看过,万一考个偏的怎么办。

2.In C#, if you want to change a thread’s state from suspended into running, what method you should call? Resume

3.The following class is often called _____Generic______
class Buffer<Element> {
private Element[] data;
public Buffer( int size ) {…}
public void Put(Element x) {…}
public Element Get() {…}
}

4.Every interface member must be __implemented___ or ___inherited____ from a base class.
解答:接口的成员要么自己定义要么继承自父类。
接口不能包含常量、字段、操作符、构造函数、析构函数、任何静态成员、方法的实现;

5.??????
6.Write the output.
static void Main()
{
String[] cities = {"London","Vienna","Paris","Linz", "Brussels"};
//using Linq to Objects
IEnumerable<string> result = from c in cities
where c.StartsWith("L")
orderby c
select c.ToUpper(); foreach (string s in result)
Console.WriteLine(s);
Console.ReadKey();
}
解答:原题目好像并不能输出什么啊,改了一下题目,他的意思应该是是要输出result内容。结果如下:
LINZ
LONDON
7. Fill in the blank
using System; class Program
{
static void Main()
{
Myclass m = new Myclass();
int[] s = new int[] { , , , , };
int smax, smin;
m.MaxMin(s, out smax, out smin); Console.WriteLine("{0} {1}", smax, smin);
Console.ReadKey();
}
}
class Myclass
{
public void MaxMin(int[] a, out int max, out int min)
{
max = min = a[];
for (int i = ; i < a.Length; i++)
{
if (a[i] > max) max = a[i];
if (a[i] < min) min = a[i];
}
}
}
解答:out的用法(默默在MaxMin前面加了一个public)。
8.Write the output.
delegate void Notifier (string sender); void SayHello(string sender)
{
Console.WriteLine("Hello from " + sender);
}
void SayGoodBye(string sender)
{
Console.WriteLine("Goodbye from " + sender);
} Notifier greetings;
greetings = SayHello;
greetings += SayGoodBye;
greetings("John");
greetings -= SayHello;
greetings("John");
解答:代理的基本用法。输出结果:
Hello from John
Goodbye from John
Goodbye from John
9.Write the result of array A.
static void Main()
{
int[] A = new int[] { , , , , };
Object[] B = new Object[] { , , , , }; Array.Copy(A, B, ); foreach (int x in A)
Console.WriteLine(x);
foreach (int x in B)
Console.WriteLine(x); Console.ReadKey();
}
解答:考察Copy的用法。这里面A没有变哦,反倒是B变成了{1,2,8,9,10}

输出结果(数组A内容):

10.Please fill in the blanks.
namespace test
{
public delegate void OnDBOperate();
public class UserControlBase : System.Windows.Forms.UserControl
{
public event OnDBOperate OnNew;
private void toolbar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if (e.Button.Equals(BtnNew))
{
//Please write code to call OnNew events
if (OnNew != null)
OnNew();
}
}
}
}
四、简答
1.What is the difference between virtual method and the abstract method?
解答:抽象方法是只有定义、没有实际方法体的函数,它只能在抽象类中出现,并且在子类中必须重写;抽象方法是一种强制派生类覆盖的方法,必须被派生类覆写的方法,否则派生类将不能被实例化。抽象方法是可以看成是没有实现体的虚方法,如果类中包含抽象方法,那么类就必须定义为抽象类,不论是否还包含其它一般方法。
虚方法则有自己的函数体,已经提供了函数实现,而且允许在子类中重写或覆盖。虚方法可以不在派生类中重写。

2.C# uses different modifiers to confine the data security. There are 5 different modifiers. Please list out each of them and explain their security level.
解答:简单叙述了一下。
public 公有访问。不受任何限制。
private 私有访问。只限于本类成员访问,子类,实例都不能访问。
protected 保护访问。只限于本类和子类访问,实例不能访问。
internal 内部访问。只限于本项目内访问,其他不能访问。
protected internal 内部保护访问。只限于本项目或是子类访问,其他不能访问。

3.What are the difference between the value type and the reference type.
|
Value Type |
Reference Type |
解答:去年原题,看他这意思是要写三个对比QAQ。
值类型直接存储其值,值类型部署在栈上,初始化为0,false,'\0'等。
而引用类型存储对其值的引用,引用类型部署在托管堆上,初始化为null。
具体详解:http://blog.csdn.net/qiaoquan3/article/details/51202926

4. Write down the differences between Overloading and Overriding?
解答:陈年老题了。

5.Please give a brief description about the difference and connection between the class and interface.
|
Class |
Interface |
解答:前年原题qwq

对了,看到一篇讲了C#各种对比的帖子,分享给你们,可以参考:http://www.jb51.net/article/37971.htm
最后,大家加油呀,祝下午考试顺利~
作者: AlvinZH
出处: http://www.cnblogs.com/AlvinZH/
本文版权归作者AlvinZH和博客园所有,欢迎转载和商用,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
北航软院2014级C#期末考试部分考题解答的更多相关文章
- 北航软院2013级C#期末考试部分考题解答
博主注:本渣渣水平有限,文中若有不对的地方敬请指出,谢谢. 本文中大部分图片来自老师的PPT,感谢邵老师,想要的可以点击右边QQ联系我:) 一.选择题 2.Wrong statement? A.dou ...
- 北航软院2012级C#期末考试部分考题解答
博主注:本渣渣水平有限,文中若有不对的地方敬请指出,谢谢. 本文中大部分图片来自老师的PPT,感谢邵老师,想要的可以点击右边QQ联系我:) 一.选择题(2*15=30) 1.In C# what is ...
- 北航软院2015级C#期末考试部分考题讲解
洗洗睡了吧,我怎么知道明天的考试题目! 或者 你明年补考可以过来看看:) 晚安.
- 复旦大学2014--2015学年第二学期(14级)高等代数II期末考试第八大题解答
八.(本题10分) 设 $A,B$ 为 $n$ 阶半正定实对称阵, 求证: $AB$ 可对角化. 分析 证明分成两个步骤: 第一步, 将 $A,B$ 中的某一个简化为合同标准形来考虑问题, 这是矩 ...
- BUPT复试专题—数据库检索(2014软院)
题目描述 在数据库的操作过程中,我们进场会遇到检索操作.这个题目的任务是完成一些特定格式的检索,并输出符合条件的数据库中的所有结果. 我们现在有一个数据库,维护了学生的姓名(Name),性别(Sex) ...
- BUPT复试专题—最近公共祖先(2014软院)
题目描述 给出一棵有N个节点的有根树TREE(根的编号为1),对于每组查询,请输出树上节点u和v的最近公共祖先. 最近公共祖先:对于有向树TREE的两个结点u,v.最近公共祖先LCA(TREE u,v ...
- BUPT复试专题—最长连续等差子数列(2014软院)
题目描述 给定-个长度为N的整数数列,你需要在其中找到最长的连续子数列的长度, 并满足这个子数列是等差的.注意公差小于或等于0的情况也是允许的. 输入 第一行为数据组数T(1~100),表示测试数 ...
- 复旦大学2014--2015学年第一学期高等代数I期末考试情况分析
一.期末考试成绩班级前几名 金羽佳(92).包振航(91).陈品翰(91).孙浩然(90).李卓凡(85).张钧瑞(84).郭昱君(84).董麒麟(84).张诚纯(84).叶瑜(84) 二.总成绩计算 ...
- 复旦大学2016--2017学年第一学期高等代数I期末考试情况分析
一.期末考试成绩班级前十名 宁盛臻(100).朱民哲(92).徐钰伦(86).范凌虎(85).沈伊南(84).何陶然(84).丁知愚(83).焦思邈(83).董瀚泽(82).钱信(81) 二.总成绩计 ...
随机推荐
- 79. Word Search在字母矩阵中查找单词
[抄题]: Given a 2D board and a word, find if the word exists in the grid. The word can be constructed ...
- eclipse基础环境配置和svn、maven的配置以及maven的安装
安装eclipse和基础配置 第一步:解压eclipse安装包,直接解压就可以,绿色版安装 第二步:启动eclipse,注意这里的eclipse需要依赖jdk,并且版本需要匹配,否则启动会出 现问题. ...
- 面向对象 继承 抽象类 接口 static 权限修饰符
Day01 面向对象 继承 抽象类 接口 static 1.匿名对象是指创建对象时,只有创建对象的语句,却没有把对象地址值赋值给某个变量. 2.类的继承是指在一个现有类的基础上去构建一个新的类,构建出 ...
- loadrunner12-添加集合点
1.首先添加集合点之前要插入事务,集合点和事务通常是一起使用的,单独使用集合点,基本上可以说是没有意义的. 2.在开始事务之前 ,插入一个“集合点”,那么在多用户执行时,就可以将用户请求停下来,直到用 ...
- Python代码规范利器Flake8
写代码其实是需要规范的,团队中更是如此:不然 Google 也不会发布各种编码规范,耳熟能详的有Google C++ 风格指南,Google Python 风格指南,等等. 这些规范有用吗?有用也没用 ...
- zigbee广播通信原理
广播:可以理解成,发送模块发出数据,这个网络里的所有节点模块都可以拿到这个数据. 实验:终端模块以广播的形式发送出去,让协调器和路由器模块作为接收器收到数据并显示出来! 协调器模块作为接收模块: 和单 ...
- ORM对象/关系模型
1 ORM 对象关系映射(ORM)提供了概念性的.易于理解的模型化数据的方法.ORM方法论基于三个核心原则: 简单:以最基本的形式建模数据. 传达性:数据库结构被任何人都能理解的语言文档化. 精确性: ...
- 手工创建Oracle数据库
数据库版本: SQL> select * from v$version; BANNER ----------------------------------------------------- ...
- 05 Computing GC Content
Problem The GC-content of a DNA string is given by the percentage of symbols in the string that are ...
- ServiceStack.Redis.RedisNativeClient的方法“get_Db”没有实现。
项目中用到redis,用nuget导入,但是运行时遇到问题 Exception: “Com.JinYiWei.Cache.RedisHelper”的类型初始值设定项引发异常.System.TypeIn ...