北航软院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) 二.总成绩计 ...
随机推荐
- Java设计模式(3)——抽象工厂模式
抽象工厂模式是所有形态的工厂模式中最为抽象和最其一般性的.抽象工厂模式可以向客户端提供一个接口,使得客户端在不必指定产品的具体类型的情况下,能够创建多个产品族的产品对象. 一.产品族和产品等级结构 为 ...
- 实践作业4:Web测试实践(小组作业)每日任务记录3
会议时间:2017年12月23日 会议地点:东九教学楼自习区 主 持 人:王晨懿 参会人员:王晨懿.余晨晨.郑锦波.杨潇.侯欢.汪元 记 录 人:王晨懿 会议议题:小组作业第二阶段 下面是今天 ...
- .NET开源MSSQL、Redis监控产品Opserver之Exception配置
异常日志的记录和监控主要依赖于StackExchange.Exceptional组件,默认已经被引进来了. 先看下config文件夹下的ExceptionsSettings.json.example文 ...
- mysql元数据查询
截图来自<深入浅出MySQL++数据库开发.优化与管理维护+第2版+唐汉明>一书
- 解决VS2010中工具箱里没有WPM
我前段时间要用到MS的WPM,但苦于找不到解决不了,无奈重装后一样的情况我的win7 旗舰版版+VS2010旗舰版.在控制面板里找到多媒体重新关闭并从新打开,就OK啦..记得要重启哦...
- Linq基础操作之Select,Where,OrderBy,ThenBy源码分析
Linq基础操作之Select,Where,OrderBy,ThenBy源码分析 二:Select 它是延迟执行.yield有得一拼,因为他们都是生成了一个枚举类. if (source is TSo ...
- 【原创翻译】ArcGis Android 10.2.4更新内容简介
翻译不当和错误之处敬请指出 更新内容官方描述 https://developers.arcgis.com/android/guide/release-notes-10-2-4.htm 10.2.4的版 ...
- MacOS安装使用Node.js
1. 到官网https://nodejs.org/zh-cn/download/下载,选择Macintosh Installer, 如下: 2. 按预设的下一步,Node.js版本为v6.10.0, ...
- Windows store app[Part 1]:读取U盘数据
Windows 8系统下开发App程序,对于.NET程序员来说,需要重新熟悉下类库. 关于WinRT,引用一张网上传的很多的结构图: 图1 针对App的开发,App工作在系统划定的安全沙箱内,所以通过 ...
- ZKEACMS 配置使用 HTTPS
在开始之前,请升级你的ZKEACMS到最新版本,旧版本使用HTTPS会有问题 https加密链接,在访问的过程中,可以保护你的隐私,保证你的敏感数据不会被别人偷窥,窃取.如果你的服务器在境外,使用ht ...