北航软院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) 二.总成绩计 ...
随机推荐
- RedHat 6 下配置网卡IP地址,Virtual Linux下配置网卡IP
经常用到,自己Mark一下,顺带给需要的人参考. 1.配置文件修改 $ vi /etc/sysconfig/network-scripts/ifcfg-eth0 内容: DEVICE="et ...
- python3--json反序列化
# Auther: Aaron Fan # 加载文件中的数据 import json with open('test.txt','r',encoding='utf-8') as f: info = j ...
- [SoapUI] 循环遍历某个Test Case下的所有Test Step,将Cookie传递给这些Test Step
import com.eviware.soapui.support.types.StringToStringMap //Get cookie's value from the project leve ...
- eclipse (android环境搭建)
如何安装java环境 http://jingyan.baidu.com/article/a24b33cd59b58e19fe002bb9.html eclipse安装教程 http://jingyan ...
- bootstrap导航条相关知识
在导航条(navbar)中有一个背景色.而且导航条可以是纯链接(类似导航),也可以是表单,还有就是表单和导航一起结合等多种形式. 为导航条添加标题.二级菜单及状态 <div class=&quo ...
- YII2 自动 created_at created_by updated_by updated_at
use yii\behaviors\TimestampBehavior; use yii\behaviors\BlameableBehavior; use yii\db\Expression; /** ...
- javascript总结44: DOM对象的dataset属性方式
1 DOM设置属性的特殊方式: DOM对象的dataset属性方式获取data-xxx方式定义的属性 由于我们经常需要在标签上自定义属性来存储数据或状态,但是如果用传统的方式操作起来比较繁琐,而且不熟 ...
- ubuntu 14.04常见问题
1. 改root密码 sudo passwd root 2. 显示登录框 sudo gedit /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf 添加 ...
- [转]ubuntu linux下DNS重启后丢失(不是Network-manager造成的情况)
从网上得知 /etc/resolv.conf中的DNS配置是从/etc/resolvconf/resolv.conf.d/head中加载而来,所以每回改resolv.conf都会失效,在此文件里面已经 ...
- 使用Word2016发布CSDN博客
目前大部分的博客作者在用Word写博客这件事情上都会遇到以下3个痛点: 1.所有博客平台关闭了文档发布接口,用户无法使用Word,Windows Live Writer等工具来发布博客.使用Word写 ...