新蛋科技.net工程方面的笔试题

时间:2021-01-15 18:36:53 笔试题目 我要投稿

新蛋科技.net工程方面的笔试题

  1、 DataSet和DataReader的区别和相同点,分别适合用于什么样的情况?

新蛋科技.net工程方面的笔试题

  答:

  2、 有基类如下:

  public class parent

  {

  public parent()

  {

  Console.Write(“Parent”);

  }

  }

  请写出一个子类Son,要求子类的构造函数实现如下的功能:(1)输出儿子的NAME、SEX、AGE、以及Parent,(2)要求在Son的构造函数里不能有任何的命令语句出现。

  public class parent

  {

  public parent()

  {

  Console.Write(“Parent”);

  }

  }

  public class Son:parent

  { static string name=null;

  static int sex=0;

  static int age=0;

  public parent(string name,int sex,int age):base()

  {

  name=name;

  sex=sex;

  age=age;

  display();

  }

  publci void display()

  {

  Console.WriteLine(“name=”+name);

  Console.WriteLine(“sex=”+sex);

  Console.WriteLine(“age=”+age);

  }

  }

  3、 请例举出三种以上进行页面重定向的方式(包括服务端和客户端)。

  答: 第一种: Response.Redirect,

  第二种: Server.Transfer

  第三种:

  function redirect(url) {

  document.theForm.action = url;

  document.theForm.submit();

  }

  第四种: StringBuilder sb=new StringBuilder();

  sb.Append(“ ”);

  Response.Write(sb.ToString());

  4、 写出禁用ViewState的语句。

  答: Control(具体的某个控件).EnableViewState=false;

  5、 请谈一谈.NET的code-behind模式和code_clude模式的区别,和各自的优点及缺点。

  6、 写出下列七个程序段的输出结果:

  (1)

  interface InFace

  {

  void fun();

  }

  class MyParent:InFace

  {

  public void fun()

  {

  Console.WriteLine(“Parent”);

  }

  }

  class MySon:MyParent

  {

  public void fun()

  {

  Console.WriteLine(“Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  InFace inf=new MySon();

  inf.fun();

  }

  }

  结果:Parent

  (2)

  interface InFace

  {

  void fun();

  }

  class MyParent:InFace

  {

  public new void fun()

  {

  Console.WriteLine(“Parent”);

  }

  }

  class MySon:MyParent

  {

  public void fun()

  {

  Console.WriteLine(“Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  InFace inf=new MySon();

  inf.fun();

  Console.Read();

  }

  }

  结果:Parent

  (3)

  interface InFace

  {

  void fun();

  }

  class MyParent:InFace

  {

  public new void fun()

  {

  Console.WriteLine(“Parent”);

  }

  }

  class MySon:MyParent

  {

  public new void fun()

  {

  Console.WriteLine(“Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  InFace inf=new MySon();

  inf.fun();

  Console.Read();

  }

  }

  结果:Parent

  (4)

  interface InFace

  {

  void fun();

  }

  class MyParent:InFace

  {

  public void fun()

  {

  Console.WriteLine(“Parent”);

  }

  }

  class MySon:MyParent

  {

  public override void fun()

  {

  Console.WriteLine(“Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  InFace inf=new MySon();

  inf.fun();

  Console.Read();

  }

  }

  结果:语法错误: 无法重写继承成员“ConsoleApplication6.MyParent.fun()”,因为它未标记为 virtual、abstract 或 override