西西河

主题:【求助】关在酒店里考试,急问三道C#和SQL题。多谢!! -- bourne

共:💬11 🌺2 新:
全看树展主题 · 分页首页 上页
/ 1
下页 末页
家园 【求助】关在酒店里考试,急问三道C#和SQL题。多谢!!

1. Which of the following is valid entry points to a Console application?

Select zero or more answers:

(A) static void Main()

(B) static int Main(string args)

(C) static int Main()

(D) static void Main(string[] args)

(E) static int Main(string[] args)

2. What will be the output for the following code fragment?

int a = 10;

if (a = 20) {a = 15; Console.WriteLine(a);}

Select one answer:

(A) 15

(B) 20

(C) 10

(D) The compiler will generate an error

3. What value does the SQL Server statement return?

select count(*) from a, b

where tale 'a' has 10 records and table 'b' has 10 records

Select one answer:

(A) 10

(B) 20

(C) 100

(D) 1000

家园 试一试

1 d

2 d

3 c

家园 我被if (a = 20)给蒙蔽过去了,看了你的答案才找出来

还是你行。

家园 这个算机经的实时版本了吧~
家园 哈,有时候简单的错误反而比较麻烦。

我也不是100%肯定,C#也忘差不多了。

不过java是这样。C#应该也是。呵呵

家园 果然是伏波将军,马上就提供了援助。

第一题是多选,所以不确定除了D以外还有没有。第二题错在(a = 20)。第三题是10 x 10。

多谢了!

想再问一道:

What will happen when the programs executes?

public abstract class Account

{

public int GetAccountBalance()

{

return 1000;

}

}

public class SavingAccount: Account

{

public new int GetAccountBalance()

{

return 2000;

}

}

public new int GetAccountBalance()

{

return 2000;

}

public class Driver

{

public static void Main (string[] args)

{

Account pa = new SavingAccount();

Console.Write(pa.GetAccountBalance().ToString());

}

}

Select one answer:

A.Throws an InvalidCastException

B.Throws an ArgumentException

C.Outputs “1000” and quits

D.Outputs “2000” and quits

家园 汗,这个有点复杂,我也吃不准了。手边没有环境。。。
家园 第二个,为什么不是A呢?

C我现在都忘了,不过感觉应该可以编译啊。

家园 我的答案

用过C,C++,对于C#的编译器不是很清楚

第一题:

应该是 D,E都是正确的。

第二题:

应该是A

不过也许c#的编译器有所改进?那就应该选D

第三题:

全关系的查询

10*10 = 100

选C

家园 C#与C有不同

在if的条件语句中,C允许出现赋值语句,而C#只允许布尔表达式,否则报告编译错误。

家园 解释一下

第一题是A,D, C#中MAIN函数是不返回值的,而命令行参数不是必须的。

第二题 C#和C++不同,bool类型和int类型是不能互相转换的,C#的判断相等的逻辑操作符是==,而a=20是赋值,返回的就是赋值后的a,因此编译就会出错。

第三题不用说了

后面补充的继承类的问题,如果子类中声明自己的GetAccountBalance方法时用的override关键字,那用基类声明的实例仍然会调用子类的函数。而给出的代码是用new关键字声明的,那么用基类声明的实例就会调用基类的函数。

全看树展主题 · 分页首页 上页
/ 1
下页 末页


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河