您的位置:首页 > 职场人生

十个人有九个做错的面试题

2010-12-14 21:07 253 查看
今天一个朋友发来他们公司的面试题,是他出的;让我做做,结果呢,太粗心我也只答对了一半,不信你也来试试!

先说好,不要把代码弄到VS里面运行,你直接给出答案看能做对不!好了,直接上代码。

1 class Program
2 {
3 static void Main(string[] args)
4 {
5 int x = 1;
6 int y = 2;
7 MyClass test1 = new MyClass(x, y);
8 test1.Print();
9 x = 3;
y = 4;
MyClass test2 = new MyClass(x, y);
test2.Print();
}
}

class MyClass
{
private int x;
private int y;

public MyClass()
{

}

public MyClass(int x, int y)
{
x = x;
y = y;
}

public void Print()
{
Console.WriteLine(string.Format("X is: {0} Y is: {1}", x, y));
}
}这个题很麻人,但也考察了面试者的基本功哦^_^
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: