536试题v2.docx
《536试题v2.docx》由会员分享,可在线阅读,更多相关《536试题v2.docx(54页珍藏版)》请在冰豆网上搜索。
536试题v2
1你正在写一个名为MyDictionary的自定义键/值对的集合(dictionary)。
你需要保证MyDictionary是类型安全的。
你应该使用下面哪段代码?
A.ClassMyDictionaryImplementsDictionary(OfString,String)
B.ClassMyDictionaryInheritsHashTable
C.ClassMyDictionaryImplementsIDictionary
D.ClassMyDictionary
EndClass
DimtAsNewDictionary(OfString,String)
DimdictAsMyDictionary=CType(t,MyDictionary)
2你是公司A的一个开发人员。
你创建了一个名为Company1的程序集。
Company1包含了一个public方法。
全局程序集中包含了另一个名为Company2的程序集。
你必须保证,public方法只能够被Company2调用。
你需要使用下面哪个权限类?
A.GacIdentityPermission
B.PublisherIdentityPermission
C.DataProtectionPermission
D.StrongNameIdentityPermission
3你写了如下代码去实现CompanyClass.MyMethod方法:
publicclassCompanyClass{
publicintMyMethod(intarg){
returnarg;
}}
你需要在你的程序集中使用一个和CompanyClass不相关的类动态的去调用CompanyClass.MyMethod方法。
你应该使用下面哪段代码?
A.CompanyClassmyClass=newCompanyClass();
Typet=typeof(CompanyClass);
MethodInfom=t.GetMethod(“MyMethod”);
inti=(int)m.Invoke(this,newobject[]{1});
B.CompanyClassmyClass=newCompanyClass();
Typet=typeof(CompanyClass);
MethodInfom=t.GetMethod(“MyMethod”);
inti=(int)m.Invoke(myClass,newobject[]{1});
C.CompanyClassmyClass=newCompanyClass();
Typet=typeof(CompanyClass);
MethodInfom=t.GetMethod(“CompanyClass.MyMethod”);
inti=(int)m.Invoke(myClass,newobject[]{1});
D.Typet=Type.GetType(“CompanyClass”);
MethodInfom=t.GetMethod(“MyMethod”);
inti=(int)m.Invoke(this,newobject[]{1});
4你需要读取文件Message.txt的完整内容到一个字符串变量中。
你应该使用哪段代码?
A.stringresult=null;StreamReaderreader=newStreamReader(“Message.txt”);result=
reader.Read().ToString();
B.stringresult=null;StreamReaderreader=newStreamReader(“Message.txt”);result=
reader.ReadToEnd();
C.stringresult=string.Empty;StreamReaderreader=newStreamReader(“Message.txt”);while
(!
reader.EndOfStream){
result+=reader.ToString();}
D.stringresult=null;StreamReaderreader=newStreamReader(“Message.txt”);result=
reader.ReadLine();
5你正在开发一个去解密数据的方法。
已知数据是使用TripleDES算法进行加密的。
你的方法接收如下参数:
将被解密的字节数组cipherMessage,密钥key,始化向量iv。
你需要使用TripleDES类去解密数据,并且把结果放入一个字符串中。
你应该使用那段代码?
A.TripleDESdes=newTripleDESCryptoServiceProvider();des.BlockSize=
cipherMessage.Length;ICryptoTransformcrypto=des.CreateDecryptor(key,
iv);MemoryStreamcipherStream=newMemoryStream(cipherMessage);CryptoStream
cryptoStream=
newCryptoStream(
cipherStream,crypto,CryptoStreamMode.Read);stringmessage;message=new
StreamReader(cryptoStream).ReadToEnd();
B.TripleDESdes=newTripleDESCryptoServiceProvider();des.FeedbackSize=
cipherMessage.Length;ICryptoTransformcrypto=des.CreateDecryptor(key,iv);MemoryStreamcipherStream=newMemoryStream(cipherMessage);CryptoStream
cryptoStream=
newCryptoStream(
cipherStream,crypto,CryptoStreamMode.Read);stringmessage;message=new
StreamReader(cryptoStream).ReadToEnd();
C.TripleDESdes=newTripleDESCryptoServiceProvider();ICryptoTransformcrypto=
des.CreateDecryptor();MemoryStreamcipherStream=new
MemoryStream(cipherMessage);CryptoStreamcryptoStream=
newCryptoStream(
cipherStream,crypto,CryptoStreamMode.Read);stringmessage;message=new
StreamReader(cryptoStream).ReadToEnd();
D.TripleDESdes=newTripleDESCryptoServiceProvider();ICryptoTransformcrypto=
des.CreateDecryptor(key,iv);MemoryStreamcipherStream=new
MemoryStream(cipherMessage);CryptoStreamcryptoStream=
newCryptoStream(
cipherStream,crypto,CryptoStreamMode.Read);stringmessage;message=new
StreamReader(cryptoStream).ReadToEnd();
6你正在创建一个类,它用于去比较指定格式的字符串。
为此,你需要实现IComparable接口。
你应该使用下面那个代码段?
A.publicclassPerson:
IComparable{
publicintCompareTo(stringother){
}}
B.publicclassPerson:
IComparable{
publicintCompareTo(objectother){
}}
C.publicclassPerson:
IComparable{
publicboolCompareTo(stringother){
}}
D.publicclassPerson:
IComparable{
publicboolCompareTo(objectother){
}}
7你正在使用MicrosoftVisualStudio2005IDE去检查一个返回字符串的方法。
你指定方法的返回值保存到字符串变量fName中。
你需要写一个代码段,如果fName的值不等于"Company"则打印如下的单行文本消息“TestFailed:
”fName。
你也同时需要保证,你的代码段并不影响或打断应用的执行。
你应该使用下面那个代码段?
A.Debug.Assert(fName==“Company”,“TestFailed:
”,fName);
B.Debug.WriteLineIf(fName!
=“Company”,fName,“TestFailed”);
C.if(fName!
="Company"){
Debug.Print(“TestFailed:
”);
Debug.Print(fName);
}
D.if(fName!
="Company"){
Debug.WriteLine(“TestFailed:
”);
Debug.WriteLine(fName);
}
8你正在开发一个自定义事件处理去自动打印所有打开的文档。
事件处理可以指定要打印的份数。
为此,你需要开发一个传递给事件处理程序的自定义事件参数类,你应该使用下面那个代码段?
A.publicclassPrintingArgs{
privateintcopies;
publicPrintingArgs(intnumberOfCopies){
this.copies=numberOfCopies;
}
publicintCopies{
get{returnthis.copies;}
}}
B.publicclassPrintingArgs:
EventArgs{
privateintcopies;
publicPrintingArgs(intnumberOfCopies){
this.copies=numberOfCopies;
}
publicintCopies{
get{returnthis.copies;}
}}
C.publicclassPrintingArgs{
privateEventArgseventArgs;
publicPrintingArgs(EventArgsea){
this.eventArgs=ea;
}publicEventArgsArgs{get{returneventArgs;}}}
D.publicclassPrintingArgs:
EventArgs{
privateintcopies;}
9你正在测试一个新开发的方法PersistToDB。
这个方法接收一个类型为EventLogEntry的参数,方法没有返回值。
你需要创建一段代码来帮助你测试这个方法。
这段代码必须从本地计算机的应用日志读取日志项然后传递日志项给PersistToDB方法。
要求,传递到PersistToDB方法的日志项必须是MySource源而且类型为错误或警告的日志。
你应该使用下面那个代码段?
A.EventLogmyLog=newEventLog(“Application”,“.”);
foreach(EventLogEntryentryinmyLog.Entries)
{
if(entry.Source=="MySource")
{
PersistToDB(entry);
}
}
B.EventLogmyLog=newEventLog(“Application”,“.”);
myLog.Source=“MySource”;
foreach(EventLogEntryentryinmyLog.Entries)
{
if(entry.EntryType==(EventLogEntryType.Error&
EventLogEntryType.Warning))
{
PersistToDB(entry);
}
}
C.EventLogmyLog=newEventLog(“Application”,“.”);
foreach(EventLogEntryentryinmyLog.Entries)
{
if(entry.Source=="MySource")
{
if(entry.EntryType==EventLogEntryType.Error||entry.EntryType==EventLogEntryType.Warning)
{
PersistToDB(entry);
}
}
}
D.EventLogmyLog=newEventLog(“Application”,“.”);
myLog.Source=“MySource”;
foreach(EventLogEntryentryinmyLog.Entries)
{
if(entry.EntryType==EventLogEntryType.Error||
entry.EntryType==EventLogEntryType.Warning)
{
PersistToDB(entry);
}
10你正在开发一个自定义集合类。
你需要在你的类里创建一个方法而且能够保证你的方法的返回值是一个能够适合Foreach语句使用的类型。
你应该如何实现你的方法?
A.方法必须返回一个IEnumerator或Ienumerable的类型。
B.方法必须返回一个IComparable的类型。
C.方法必须包含一个集合。
11你需要以字符串的形式返回isolatedstorage文件内容。
已知,文件名称为Settings.dat并且在机器范围内唯一。
你应该使用下面那个代码段?
A.IsolatedStorageFileStreamisoStream;isoStream=newIsolatedStorageFileStream(
“Settings.dat”,FileMode.Open);stringresult=newStreamReader(isoStream).ReadToEnd();
B.IsolatedStorageFileisoFile;isoFile=IsolatedStorageFile.GetMachineStoreForAssembly();
IsolatedStorageFileStreamisoStream;isoStream=newIsolatedStorageFileStream(
“Settings.dat”,FileMode.Open,isoFile);stringresult=new
StreamReader(isoStream).ReadToEnd();
C.IsolatedStorageFileStreamisoStream;isoStream=newIsolatedStorageFileStream(“Settings.dat”,FileMode.Open);stringresult=isoStream.ToString();
D.IsolatedStorageFileisoFile;isoFile=IsolatedStorageFile.GetMachineStoreForAssembly();
IsolatedStorageFileStreamisoStream;isoStream=newIsolatedStorageFileStream(
“Settings.dat”,FileMode.Open,isoFile);stringresult=isoStream.ToString();
12你需要写一个完成如下任务的代码段:
1)查找所有暂停的服务
2)把服务的显示名称增加到集合中
请问,你应该使用那个代码段?
A.DimsearcherAsManagementObjectSearcher=_NewManagementObjectSearcher(_
"Select*fromWin32_ServicewhereState='Paused'")
ForEachsvcAs
ManagementObjectInsearcher.Get()
Collection1.Add(svc("DisplayName"))
Next
B.DimsearcherAsManagementObjectSearcher=_NewManagementObjectSearcher(_
"Select*fromWin32_Service","State='Paused'")
ForEachsvcAsManagementObjectInsearcher.Get()
Collection1.Add(svc("DisplayName"))
Next
C.DimsearcherAsManagementObjectSearcher=_NewManagementObjectSearcher(_
"Select*fromWin32_Service")
ForEachsvcAsManagementObjectInsearcher.Get()
Ifsvc("State").ToString()="'Paused'"Then
Collection1.Add(svc("DisplayName"))
EndIf
Next
D.DimsearcherAsNewManagementObjectSearcher()searcher.Scope=New
ManagementScope("Win32_Service")
ForEachsvcAsManagementObjectInsearcher.Get()
Ifsvc("State").ToString()="Paused"Then
Collection1.Add(svc("DisplayName"))
EndIf
Next
13你正在开发一个类库。
你的代码需要访问系统环境变量。
对于未给调用堆栈中处于较高位置的所有调用方授予当前实例所指定的权限,则在运行时强制SecurityException。
你应该调用那个方法?
A.set.Demand();
B.set.Assert();
C.set.PermitOnly();
D.set.Deny();
14你正在开发一个使用安全哈希算法计算给定数据哈希值的方法。
传递给你方法的数据是一个名为message的字节数组。
你需要计算输入数据的SHA1哈希值,而且要把计算结果放入名为hash的字节数组。
你应该使用下面那一个代码段?
A.SHA1sha=newSHA1CryptoServiceProvider();byte[]hash=
null;sha.TransformBlock(message,0,message.Length,hash,0);
B.SHA1sha=newSHA1CryptoServiceProvider();byte[]hash=
BitConverter.GetBytes(sha.GetHashCode());
C.SHA1sha=newSHA1CryptoServiceProvider();
byte[]hash=sha.ComputeHash(message);
D.SHA1sha=newSHA1CryptoServiceProvider();sha.GetHashCode();
byte[]hash=sha.Hash;
15你正在定义一个名为CompanyClass的、包含几个子对象的类。
CompanyClass类包含一个操作子对象的方法ProcessChildren。
CompanyClass对像将被序列化。
你需要确保在CompanyClass对象和所有子对象被重新构造后ProcessChildren方法将被执行。
你应该通过下面那两个操作达到这个目的?
(每个答案代表解决方案的一部分)
A.在ProcessChildren方法上应用OnDeserializing属性。
B.让CompanyClass实现IDeserializationCallback接口。
C.让CompanyClass从ObjectManager类继承。
D.在ProcessChildren方法上应用OnSerialized属性。
E.创建一个调用ProcessChildren的GetObjectData方法。
F.创建一个调用ProcessChildren的OnDeserialization方法。
16你使用反射(Reflection)来获得方法MyMethod的信息。
你需要获取MyMethod方法是否在派生类中可以访问,你应该如何做?
A.访问MethodInfo的IsAssembly属性。
B.访问MethodInfo的IsVirtual属性。
C.访问MethodInfo的IsStatic属性。
D.访问Me