第一范文网 - 专业文章范例文档资料分享平台

Net软件工程师面试题

来源:用户分享 时间:2025/5/31 7:50:36 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

} }

输出结果为: 2 5 1 6

(一个函数的执行必须在一个具体的对象中实现,如果函数明确告诉是哪个对象,则在改该对象下执行;如果没有,则在默认的对象下执行) 4. 在下面的例子里 using System; class A {

public A() {

PrintFields(); }

public virtual void PrintFields(){} }

class B:A {

int x=4; int y; public B() { y=-1; }

public override void PrintFields() {

x += 1;

Console.WriteLine(\ y += 1; }

当使用B b = new B()创建的实例时,产生什么输出?b. PrintFields();结果是什么?

X=5,y=0

b. PrintFields 结果是x=6;y=1

5. 下面的例子中

using System; class A {

public static int X; static A()

{

X=B.Y+1; }

} class B {

public static int Y=A.X+1; static B() { }

static void Main()

{

Console.WriteLine(\ } }

产生的输出结果是什么? X=2,Y=1

五.程序设计(每题7分,共28分) 1. 请编程实现一个冒泡排序算法?

//比较法 using System;

using System.Collections.Generic; using System.Text;

namespace test1 {

class Program

{

static void Main(string[] args) {

int[] Array ={ 6,18,12,23,19,28,30}; Console.WriteLine(\排序前的数组:\); foreach(int n in Array) {

Console.Write(n+\); }

Console.WriteLine();

for (int i = 1; i < Array.Length; i++) //控制趟数

{

for (int j = 0; j < Array.Length - i; j++)

{

if (Array[j] > Array[j + 1]) //交换

{

int temp = Array[j]; Array[j] = Array[j + 1]; Array[j + 1] = temp; } } } //排序后

Console.WriteLine(\排序后的数组:\); for (int n = 0; n < Array.Length; n++) {

Console.Write(Array[n] + \); }

Console.WriteLine(); } } }

2. 编程程序实现委托,事件。

using System;

using System.Collections.Generic; using System.Text;

namespace delegateDemo {

class Program {

static void Main(string[] args) {

Cat cat = new Cat(); Mouse mouse = new Mouse(); Master master = new Master(); cat.Calling += new EventHandler(mouse.Escape); cat.Calling += new EventHandler(master.Wakened); cat.Call(); } }

public sealed class Cat //猫类 {

public event EventHandler Calling; public void Call() {

Console.WriteLine(\猫开始叫了……\);

if(Calling!=null) //检查事件是否被注册

Calling(this,EventArgs.Empty);//调用事件注册的方法

} }

public sealed class Mouse //老鼠类 {

public void Escape(object sender, EventArgs e)

搜索更多关于: Net软件工程师面试题 的文档
Net软件工程师面试题.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c5gu6289szm0a6ri16ozy38gut0xsx2013t4_3.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top