C#面试题

在2011年左右的时候,整理的一份面试题目,基本上在单位上面试的时候,能够做到60分以上的,就属于可用之才了偷笑

C#软件开发工程师

                                考试时间为60分钟

1. 填空: (每题2分,共10分)

 

(1)面向对象的语言具___________性、__________性、__________性。

(2)能用foreach遍历访问的对象需要实现___________接口或声明____________方法的类型。

(3)列举ADO.net中的五个主要对象__________、__________、_________、_________、
__________。

(4)传入某个属性set方法的隐含参数名的名称是____________,它的类型和___________相同。

(5) 分析以下代码,完成填空:

string strTmp = “abcdefg你好吗”;

int i =System.Text.Encoding.Default.GetBytes(strTmp).length;

int j = strTmp.length;

以上代码执行完成后,i = ______,j =_______

 

2. 不定项选择(每题2分,共10分)

(1) 以下叙述正确的是:        )

A. 接口中可以有虚方法。                          B. 一个类可以实现多个接口。
C. 接口不能被实例化。                            D.接口中可以包含已实现的方法。

(2) 从数据库读取记录,你可能用到的方法有:(         )

A. ExecuteNonQuery                                  B. ExecuteScalar

C.Fill                                                D. ExecuteReader

(3) C#中利用Socket进行网络通信编程的服务器端一般步骤是:建立Socket侦听、()、利用Socket接收和发送数据。(         )

A. 建立Socket连接                               B. 获得端口号;
C. 获得IP地址;                                   D.获得主机名;
(4)以下哪些可以作为接口成员(           )

A.方法              B.属性              C.字段         D.事件             

E.索引器            F.构造函数         G.析构函数

(5)以下拆箱转换语句中,正确的有(         )

A.object o; int i = (int)o;

B.object = 10.5;      int i = (int)o;

C.object = 10.5; float i =(float)o;

D.object = 10.5; float i =(float)(double)o;

 

3. 写出程序的输出结果(每题5分,共15分)

(1)class Class1 {
private string str = "Class1.str";
private int i = 0;
static void StringConvert(string str) {
      str = "string beingconverted.";
}

 

static void StringConvert(Class1 c) {

c.str = "string beingconverted.";

}

 

static void Add(int i) {

i++;

}

static void AddWithRef(ref int i) {

i++;

}

static void Main() {

int i1 = 10;

int i2 = 20;

string str = "str";
               Class1 c = new Class1();
               Add(i1);
               AddWithRef(ref i2);
               Add(c.i);
               StringConvert(str);
               StringConvert(c);
               Console.WriteLine(i1);
               Console.WriteLine(i2);
               Console.WriteLine(c.i);
               Console.WriteLine(str);
               Console.WriteLine(c.str);
      }

 

(2)public abstract class A
{
      public A()
      {
            Console.WriteLine('A');
         }
         public virtual void Fun()
         {
               Console.WriteLine("A.Fun()");
          }
}

 

public class B: A
{
      public B()
      {
               Console.WriteLine('B');
      }

         publicnew void Fun()
         {
               Console.WriteLine("B.Fun()");
      }

         publicstatic void Main()
         {
               A a = new B();
            a.Fun();
         }
}

 

(3)public class A
{
      public virtual void Fun1(int i)
      {
                 Console.WriteLine(i);
      }

public void Fun2(A a)
{
      a.Fun1(1);
      Fun1(5);
}

}


public class B : A
{
      public override void Fun1(int i)
      {
            base.Fun1 (i + 1);
      }

public static void Main()
{
      B b = new B();
      A a = new A();
      a.Fun2(b);
      b.Fun2(a);
}

} 

 

4. 简答题(每题5分,共25分)

(1)简述 private protected public internal修饰符的访问权限 

 

(2)C#中的值类型有哪些?引用类型又有哪些? 

 

(3)什么是GC?为什么要有GC? 

 

(4)C#中的委托是什么?事件是不是一种委托? 

 

(5)try{}里有一个return语句,那么紧跟在这个try后的finally{}里的code会不会被执行,什么时候执行? 

 

5.编程题(每题8分,共32分)

(1)请用控制台程序编写一个求1000内的素数的程序

 

(2)一列数的规则如下:1、1、2、3、5、8、13、21、34......用递归算法实现,求第30位数是多少。 

 

(3)写出一条sql语句: 取出表A中第31到第40记录(SQLServer, 以自动增长的ID作为主键,注意:ID可能不是连续的。) 

 

(4)请用代码实现Singleton模式

 

6.译翻文英(每题8分,共8分)

You knowthat a database is a collection of logically related data elements that may bestructured in various ways to meet the multiple processing and retrieval needsof organizations and individualsThere’s nothing new about databases—early ones were chiseled in stonepenned on scrollsand written on index cardsBut now databases are commonly recorded onmagnetizable mediaandcomputer programs are required to perform the necessary storage and retrievaloperations

[本段选作]You’llsee in the following pages that complex data relationships and linkages may befound in all but the simplest databasesThesystem software package that handles the difficult tasks associated withcreatingaccessingand maintaining database records is called adatabase management systemDBMS).The programs in a DBMS package establish aninterface between the database itself and the users of the database.(These users may be applications programmersmanagers and others with information needsand various OS programs.)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值