主题:【求助】关在酒店里考试,急问三道C#和SQL题。多谢!! -- bourne
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
还是你行。
我也不是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
C我现在都忘了,不过感觉应该可以编译啊。
用过C,C++,对于C#的编译器不是很清楚
第一题:
应该是 D,E都是正确的。
第二题:
应该是A
不过也许c#的编译器有所改进?那就应该选D
第三题:
全关系的查询
10*10 = 100
选C
在if的条件语句中,C允许出现赋值语句,而C#只允许布尔表达式,否则报告编译错误。
第一题是A,D, C#中MAIN函数是不返回值的,而命令行参数不是必须的。
第二题 C#和C++不同,bool类型和int类型是不能互相转换的,C#的判断相等的逻辑操作符是==,而a=20是赋值,返回的就是赋值后的a,因此编译就会出错。
第三题不用说了
后面补充的继承类的问题,如果子类中声明自己的GetAccountBalance方法时用的override关键字,那用基类声明的实例仍然会调用子类的函数。而给出的代码是用new关键字声明的,那么用基类声明的实例就会调用基类的函数。