.NET70-536微软认证中文题库

2018-11-15 21:27

xmlns:xsd=\racer 15000

Excellent

C.

racer 15000

Excellent

D.

car racer 15000

Excellent Answer: B

解析:指出XML的类是CAR,声明一个XML的格式的语法.

81. 您正在创建一个执行复杂财务计算的类.该类包含一个用于检索当前利率的方法( 名为GetCurrentRate),以及一个用于存储当前利率的变量(名为currRate).

您编写该类的序列化表现形式. 您需要编写一个代码段,当对类的实例进行反序列化时,该代码段使用当前利率更新 currRate 变量.您应该使用哪个代码段?

A. [OnSerializing]

internal void UpdateValue (StreamingContext context) { currRate = GetCurrentRate(); } B. [OnSerializing]

internal void UpdateValue(SerializationInfo

info) { info.AddValue(\ C. [OnDeserializing]

internal void UpdateValue(SerializationInfo info) { info.AddValue(\ D. [OnDeserialized]

internal void UpdateValue(StreamingContext context) { currRate = GetCurrentRate(); }

46 / 52

Answer: D

解析:StreamingContext类描述给定的序列化流的源和目标,并提供一个由调用方定义的附加上下文.所以应选A和D中的某一个.序列化的关键字是OnSerializing,反序列化的关键字是OnDeserialized,所以应该选择D.

82. 您需要以二进制格式序列化List 类型的对象.该对象名为data 您应该使用哪个代码段?

A. BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); formatter.Serialize(stream, data);

B. BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); for (int i = 0; i < data.Count; i++) { formatter.Serialize(stream, data[i]); }

C. BinaryFormatter formatter = new BinaryFormatter(); byte[] buffer = new byte[data.Count];

MemoryStream stream = new MemoryStream(buffer, true); formatter.Serialize(stream, data);

D. BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); data.ForEach(delegate(int num) { formatter.Serialize(stream, num); } ); Answer: A

解析:二进制格式的序列化需要使用二进制格式类的对象.序列化的方法为:Serialize. 可以查看MSDN的方法示例:

Stream steam = File.Open(\

BinaryFormatter bf = new BinaryFormatter(); Response.Write(\bf.Serialize(steam,mp);

看这个示例,应该选A. 联系41道

83. 您需要编写一个代码段,该代码段使用名为netStream 的NetworkStream 对象传输 名为dataToSend的字节数组的内容.您需要使用大小为8,192 字节的缓存. 您应该使用哪个代码段?

A. MemoryStream memStream = new MemoryStream(8192); memStream.Write(dataToSend, 0, (int) netStream.Length);

47 / 52

B. MemoryStream memStream = new MemoryStream(8192); netStream.Write(dataToSend, 0, (int) memStream.Length);

C. BufferedStream bufStream =new BufferedStream(netStream, 8192); bufStream.Write(dataToSend, 0, dataToSend.Length);

D. BufferedStream bufStream =new BufferedStream(netStream); bufStream.Write(dataToSend, 0, 8192); Answer: C

解析:要使用缓存,则需要声明内存类的对象,构造函数的参数,需要知道缓存中存储的值为什么,大小为多大,所以应该选C.

84. 您需要读文件名为Message.txt的全部内容到一个单一的字符串变量.您应该使用哪个代码段?

A. string result = null;

StreamReader reader = new StreamReader(\result = reader.Read().ToString();

B. string result = null;

StreamReader reader = new StreamReader(\result = reader.ReadToEnd(); C. string result = string.Empty;

StreamReader reader = new StreamReader(\while (!reader.EndOfStream) {

D. string result = null;

StreamReader reader = new StreamReader(\result += reader.ToString();} result = reader.ReadLine();

Answer: B

解析:这是一个读取文本字符的方法,因为需要读取文本字符,所以使用streamReader类, 因为又要读取全部字符串,所以用ReadToEnd()方法来读取所有字符.联系第45道题

85. 您正在编写一个用于压缩字节数组的方法.将在名为document 的参数中将数组传递到此方法.您需要压缩传入的字节数组并以字节数组的形式返回结果.

您应该使用哪个代码段?

A. MemoryStream strm = new MemoryStream(document); DeflateStream deflate = new DeflateStream(strm, CompressionMode.Compress);

byte[] result = new byte[document.Length];

deflate.Write(result, 0, result.Length); return result;

48 / 52

B. MemoryStream strm = new MemoryStream(document); DeflateStream deflate = new DeflateStream(strm, CompressionMode.Compress);

deflate.Write(document, 0, document.Length); deflate.Close();

return strm.ToArray();

C. MemoryStream strm = new MemoryStream(); DeflateStream deflate = new DeflateStream(strm, CompressionMode.Compress);

deflate.Write(document, 0, document.Length); deflate.Close(); return strm.ToArray();

D. MemoryStream inStream = new MemoryStream(document); DeflateStream deflate = new DeflateStream(inStream, CompressionMode.Compress);

MemoryStream outStream = new MemoryStream(); int b;

while ((b = deflate.ReadByte()) != -1) { outStream.WriteByte((byte)b); }

return outStream.ToArray();

Answer: C

解析:这又是一个压缩字节数组的方法.

86. 您编写名为CustomException 的以下自定义异常类 public class CustomException :ApplicationException { public static int COR_E_ARGUMENT =

unchecked((int)0x80070057);

public CustomException(string msg) :base(msg) { HResult = COR_E_ARGUMENT; }

}

您需要编写代码段,该代码段将使用CustomException 类立即将控制返回给COM 调用方.您还需要确保调用方有权访问错误代码.您应该使用哪个代码段?

A. return Marshal.GetExceptionForHR(CustomException.COR_E_ARGUMENT); B. return CustomException.COR_E_ARGUMENT;

C. Marshal.ThrowExceptionForHR(CustomException.COR_E_ARGUMENT); D. throw new CustomException(\

Answer: D

解析:说白了,就是把异常抛出,目的是让调用方捕获.所以抛出异常的只有D.

49 / 52

87. 您使用反射获取有关名为MyMethod 的方法的信息.您需要确定派生类是否可以访问MyMethod.您应该怎么做?

A. 调用MethodInfo 类的IsAssembly 属性.

B. 调用MethodInfo 类的IsVirtual 属性. C. 调用MethodInfo 类的IsStatic 属性. D. 调用MethodInfo 类的IsFamily 属性.

Answer: D

解析: IsAssembly 属性获取一个值, 该值指示此方法是否可以由同一程序集中的其他类调用.

IsVirtual 属性获取一个值,该值指示该方法是否是 virtual(虚方法) 方法. IsStatic属性获取一个值,该值指示该方法是否是静态的.

IsFamily属性获取一个值该值指示此方法或构造函数的可见性是否由

MethodAttributes..::.Family 描述;也就是说,此方法或构造函数仅在其类和派生类内可见. 如果对此类的访问只限于此类本身的成员和它的派生类的成员,则为 true;否则为false.

88. 您编写以下代码来实现MyClass.MyMethod 函数. public class MyClass {

public int MyMethod(int arg) { return arg; } }

您需要从程序集中的某个无关类动态调用MyClass.MyMethod 函数. 您应该使用哪个代码段?

A. MyClass myClass = new MyClass(); Type t = typeof(MyClass);

MethodInfo m = t.GetMethod(\ int i = (int)m.Invoke(this, new object[] { 1 }); B. MyClass myClass = new MyClass();

Type t = typeof(MyClass);

MethodInfo m = t.GetMethod(\搜索指定类型(MyClass)的方法 int i = (int) m.Invoke(myClass, new object[] { 1 }); C. MyClass myClass = new MyClass();

Type t =typeof(MyClass);

MethodInfo m = t.GetMethod(\int i = (int)m.Invoke(myClass, new object[] { 1 });

50 / 52

MyDictionary

1. 您正在编写自定义字典.

该自定义字典类名为MyDictionary MyDictionary. 您需要确保该字典是类型安全的字典. 您应该使用哪个代码段?

1.You are instantiating a variable to store only strings. The variable is named

messageStore.

You need to ensure that string messages are read and processed in the order in which they are received.

Which code segment should you use? A. class MyDictionary :Dictionary B. class MyDictionary :HashTable

C. class MyDictionary :IDictionary

D. class MyDictionary { ……} Dictionary t = new Dictionary(); MyDictionary dictionary = (MyDictionary)t; Answer: A

解析:6115A 第二章泛型集合

因为要创建一个MyDictionary类, 又是要求类型安全的类. 则需要类继承一个类型安全的类, 即泛型.泛型的语法:Dictionary<类型,类型,…>.所以A正确.

2. 您正在创建名为Age 的类.

您需要确保编写的Age 类的对象所构成的集合能够被排序.

您应该使用哪个代码段?

2.You are creating a class named Age.

You need to ensure that the Age class is written such that collections of Age objects can be sorted.

Which code segment should you use?

A. public class Age {

public int Value;

public object CompareTo(object obj) { if (obj is Age) { Age _age = (Age) obj; return Value.CompareTo(obj); }

throw new ArgumentException(\ }

}

B. public class Age {

public int Value;

1 / 52

public object CompareTo(int iValue) {

try { return Value.CompareTo(iValue); } catch {

throw new ArgumentException (\ } } }

C. public class Age :IComparable {

public int Value;

public int CompareTo(object obj) {

if (obj is Age) {

Age _age = (Age) obj;

return Value.CompareTo(_age.Value); }

throw new ArgumentException(\ }

}

D. public class Age :IComparable {

public int Value;

public int CompareTo(object obj) { try {

return Value.CompareTo(((Age) obj).Value); } catch { return -1; } } }

Answer: C

解析:6115A P26页

因为需要创建的类的对象的集合可以排序,所以需要继承排序的类或者接口.排除法,可以排除A和B.从C和D中选择其一,C和D的区别是,C是判断两个对象是否相同,而D考虑的问题不全面,它没有考虑要比较的对象应该是Age,所以应该选择C.

3. 您正在创建一个类, 用于比较经过特殊格式设置的字符串. 默认的排序规则比较不适用.

IComparable

您需要实现IComparable 接口. 您应该使用哪个代码段?

A. public class Person :IComparable{

public int CompareTo(string other){

…… } }

2 / 52

B. public class Person :IComparable{

public int CompareTo(object other){ …… } }

C. public class Person :IComparable{

public bool CompareTo(string other){

…… } }

D. public class Person :IComparable{

public bool CompareTo(object other){ …… } }

Answer: A

6115A P26页

解析:因为题目要求是实现接口IComparable,都需要继承这个接口,这是毫无疑问的,就在于方法的实现了,这就需要知道这个接口中的方法是哪个,可以知道,此接口仅包含一个方法:CompareTo(),返回值小于0表示当前对象小于被比较的对象,返回值等于 0表示两个对象相等,返回值大于0表示当前对象大于被比较的对象.这个接口的方法,是返回的int值.所以A和B中选一个.又因为这个方法要求的是比较字符串类型的变量,所以参数应该是字符串类型.所以选A.

4. 您正在开发自定义集合类.

您需要在类中创建方法.

您需要确保在类中创建的方法返回与Foreach 语句兼容的类型. 该方法应满足哪个条件?

A. 该方法必须返回IEnumerator 或IEnumerable 类型. B. 该方法必须返回IComparable 类型. C. 该方法必须明确包含集合. D. 该方法必须是类中唯一的迭代器. Answer: A

解析:6115A 第二章 P4

因为需要返回一个与foreach语句兼容的类型,所以肯定要有一个返回值.而且返回值的类型一定是集合类型.上述答案中只有IEnumerator 或IEnumerable类型集合类型的返回值. 所以选A.

5. 您正在开发一个协助用户进行电子调查的应用程序.调查由25 个对错判断题组成.

您需要执行下列任务: 将每个答案预置为是.

3 / 52

最大程度地减少每次调查使用的内存量.

您应该选择哪个存储选项?

5.You are developing an application to assist the user in conducting electronic surveys. The survey

consists of 25 true-or-false questions. You need to perform the following tasks:

? Initialize each answer to true.

? Minimize the amount of memory used by each survey.

A. BitVector32 answers = new BitVector32(1); B. BitVector32 answers = new BitVector32(-1); C. BitArray answers = new BitArray (1); D. BitArray answers = new BitArray(-1); Answer: B

解析:第二章 P33

此题考察的是BitVector32 和 BitArray的区别.

对于内部使用的布尔值和小整数,BitVector32 比 BitArray 更有效.BitArray 可以按需要无限地扩大,但它有内存和性能方面的系统开销.

位向量bitVector32, 用默认构造函数创建了一个BitVector32,其中所有的32位都初始化为 false.构造函数传入的值如果为1,则结果会再加1,相当于结果没有变化,所以还是false, 即应传入-1来表示结果做了取反的变化.是数据结构中的内容.

6. 您需要确定满足下列条件的类型:

始终为数字.

不大于65,535 65,535. 您应选择哪种类型? A. System.UInt16 B. int

C. System.String D. System.IntPtr Answer: A

解析:第一章:P3

因为65535最接近的数字为2的16次方的.又因为是数字类型,所以是Uint16,主要考察类型的取值范围.

7. 您正在开发一个自定义事件处理程序,自动打印所有打开的文件.事件处理程序有助于指

定打印的份数.您需要开发一个自定义事件的参数类作为参数传递给事件处理程序.您应该使用哪个代码段?

4 / 52

A. public class PrintingArgs {

private int copies;

public PrintingArgs(int numberOfCopies) { this.copies = numberOfCopies; } public int Copies {

get { return this.copies; } } }

B. public class PrintingArgs : EventArgs { private int copies;

public PrintingArgs(int numberOfCopies) { this.copies = numberOfCopies; } public int Copies { get { return this.copies; } C. public class PrintingArgs { private EventArgs eventArgs; public PrintingArgs(EventArgs ea) { this.eventArgs = ea; }

public EventArgs Args {get { return eventArgs; }}} public class PrintingArgs : EventArgs { Answer: B

解析:课本第七章P23页

此题是在写一个自定义的事件处理程序,所以最先判断应该继承一个事件处理程序的类, 所以筛选法,把A和C去掉.看B和D,看题目要求,需要有一个参数传递功能,因为D没有参数,也就是没有构造函数的重载方法,所以应选B.

8. 您编写一个名为Employee 的类,该类包含以下代码段.

public class Employee {

string employeeId, employeeName, jobTitleName; public string GetName() { return employeeName; }

public string GetTitle() { return jobTitleName; }

您需要在类型库中向COM 公开此类. COM COM 接口还必须便于在Employee 类的新版本之间保持向前兼容.

您需要选择方法以生成COM 接口.

您应该怎么做?

A. 将以下属性添加到类定义. [ClassInterface(ClassInterfaceType.None)] public class Employee {

B. 将以下属性添加到类定义. [ClassInterface(ClassInterfaceType.AutoDual)] public class Employee {

C. 将以下属性添加到类定义. [ComVisible(true)] public class Employee {

D. 为类定义接口并将以下属性添加到类定义. [ClassInterface(ClassInterfaceType.None)] public class Employee :IEmployee { Answer: D

解析:使用 VS.Net 做.Net 组件 P5

5 / 52

C. 是控制访问加密数据和内存的能力

D. 为强名称定义标示权限,这里选择D最正确.

72. 您创建一个通过使用最终用户凭据运行的方法.您需要使用Microsoft Windows 组向用户授权.您必须添加代码段,该代码段确定用户是否在名为Clerk 的本地组中. 您应该使用哪个代码段?

A. WindowsIdentity currentUser = WindowsIdentity.GetCurrent();

For each (IdentityReference grp in currentUser.Groups)

{NTAccount grpAccount = ((NTAccount)grp.Translate(typeof(NTAccount))); isAuthorized = grpAccount.Value.Equals(Environment.MachineName + @\if (isAuthorized) break;}

B. WindowsPrincipal currentUser = (WindowsPrincipal)Thread.CurrentPrincipal; isAuthorized = currentUser.IsInRole(\

C. GenericPrincipal currentUser = (GenericPrincipal) Thread.CurrentPrincipal; isAuthorized = currentUser.IsInRole(\

D. WindowsPrincipal currentUser = (WindowsPrincipal)Thread.CurrentPrincipal; isAuthorized = currentUser.IsInRole(Environment.MachineName);

Answer: B

73. 您正在为应用程序域创建新的安全策略.您编写以下代码行. PolicyLevel policy = PolicyLevel.CreateAppDomainLevel(); PolicyStatement noTrustStatement =new

PolicyStatement(policy.GetNamedPermissionSet(\

PolicyStatement fullTrustStatement =new

PolicyStatement(policy.GetNamedPermissionSet(\

您需要为策略排列代码组, 以便加载的程序集默认为Nothing 权限集. 如果程序集源自受信任区域,则安全策略必须向程序集授予FullTrust 权限集.

您应该使用哪个代码段?

A. CodeGroup group1 = new FirstMatchCodeGroup(new ZoneMembershipCondition(SecurityZone.Trusted),

fullTrustStatement);

CodeGroupgroup2 = new UnionCoderoup(new AllMembershipCondition(), noTrustStatement);

group1.AddChild(group2);

B. CodeGroup group1 = new FirstMatchCodeGroup(new

AllMembershipCondition(),noTrustStatement);

CodeGroup group2 = new UnionCodeGroup(new fullTrustStatement); ZoneMembershipCondition(SecurityZone.Trusted), group1.AddChild(group2);

C. CodeGroup group = new UnionCodeGroup(new

41 / 52

ZoneMembershipCondition(SecurityZone.Trusted), fullTrustStatement);

D. CodeGroup group = new FirstMatchCodeGroup(new AllMembershipCondition(),noTrustStatement);

Answer: B

解析: 分析题目要求, 您需要为这个策略设置代码组, 以便本地的程序集没有任何许可设置. (默认)

如果程序集来源于一个受信任的区域,则授予它足够的信任.

所以

1)设置代码段没有任何许可设置 2)把受信任的代码段添加进来. 答案选 B

74.假设您在开发一个方法,它把使用三重DES加密的数据进行解密.这个方法接收以下参数:一个要被解密的的字节数组叫cipherMessage,一个叫做Key的密钥,一个叫iv的初始向量,您需要使用TripleDES相关的类来对信息进行解密,并且它结果放到一个字符串里. 那么您会使用那一个代码段呢?

A. TripleDES des = new TripleDESCryptoServiceProvider(); des.BlockSize = cipherMessage.Length;

ICryptoTransform crypto = des.CreateDecryptor(key, iv);

MemoryStream cipherStream = new MemoryStream(cipherMessage); CryptoStream cryptoStream =new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read);

string message;

message = new StreamReader(cryptoStream).ReadToEnd(); B. TripleDES des = new TripleDESCryptoServiceProvider(); des.FeedbackSize = cipherMessage.Length;

ICryptoTransform crypto = des.CreateDecryptor(key, iv);

MemoryStream cipherStream = new MemoryStream(cipherMessage); CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read);

string message; message = new StreamReader(cryptoStream).ReadToEnd(); C. TripleDES des = new TripleDESCryptoServiceProvider();

ICryptoTransform crypto = des.CreateDecryptor();

MemoryStream cipherStream = new MemoryStream(cipherMessage); CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read);

string message;

message = new StreamReader(cryptoStream).ReadToEnd(); D. TripleDES des = new TripleDESCryptoServiceProvider();

42 / 52

ICryptoTransform crypto = des.CreateDecryptor(key, iv); //创建一个解密算法 MemoryStream cipherStream = new MemoryStream(cipherMessage); CryptoStream cryptoStream =new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read); string message;

message = new StreamReader(cryptoStream).ReadToEnd();

Answer: D

解析:用于对一个字节数组进行解密操作.用一个叫 Key 的密钥和初始向量进行解密.

76.现在您在开发一个类库,其中某个代码片段需要访问系统的环境变量.

当调用堆栈中处于较高位置的调用方不具有当前实例所指定的权限时您需要强制使用 SecurityException SecurityException异常.您会调用下面哪个方法? A. set.Demand(); B. set.Assert();

C. set.PermitOnly();

D. set.Deny();

Answer: A

解析: SecurityException, 当前用户未通过对当前权限所指定的用户进行的安全检查.如果未引发 SecurityException,则 Demand 成功.如果引发则 Demand 失败. ASSERT(booleanExpression )语句一般用来检查一些必须符合的条件,如果不符合条件,则不让程序继续运行下去.

PermitOnly()防止调用堆栈中处于较高位置的调用方通过调用此方法的代码来访问除当前实例指定的资源外的所有资源.

PermitOnly 与 Deny 相似,因为两者在堆栈遍历本应成功时都会导致堆栈步失败.两者的差别在于:Deny 指定将导致堆栈遍历失败的权限,而 PermitOnly 仅指定不会导致堆栈遍历失败的权限.

77.假如您现在正在开发一个服务器应用程序.而这个应用程序需要在网络上传递一些敏感 X509Certificate certificate TcpClient 信息,您创建了一个X509Certificate X509Certificate类的对象叫做certificate certificate和一个TcpClient TcpClient的对象叫做 SslStream Transport client client.您需要创建一个SslStream SslStream流使用Transport Layer Security 1.0 protocol protocol协议进行通信.那么您会使用下面的哪个代码片段?

43 / 52

答案选 D.类似于第 24 道题,进行加密

A. SslStream ssl = new SslStream(client.GetStream());

ssl.AuthenticateAsServer(certificate, false, SslProtocols.None, true); B. SslStream ssl = new SslStream(client.GetStream());

ssl.AuthenticateAsServer(certificate, false, SslProtocols.Ssl3, true); C. SslStream ssl = new SslStream(client.GetStream());

ssl.AuthenticateAsServer(certificate, false, SslProtocols.Ssl2, true); D. SslStream ssl = new SslStream(client.GetStream());

ssl.AuthenticateAsServer(certificate, false, SslProtocols.Tls, true);

Answer: D

解析:SslStream 提供一个用于客户端-服务器通信的流,此流使用安全套接字层 (SSL) 安全协议对服务器及客户端(可选)进行身份验证.

SslStream 类在声明对象时,构造函数的重载方法,需要一个 TcpClient 对象的 GetStream 方法.构造函数如下所示:

public SslStream(Stream innerStream);

SslStream..::.AuthenticateAsServer 方法 (X509Certificate, Boolean, SslProtocols, Boolean) 而第三个参数按题目要求,使用 Transport Layer Security 1.0 protocol 协议进行通信,所以 答案应该选 D.

78.假设您现在在写一个方法用以压缩一个字节数组,这个方法定义了一个形式参数叫 document, document,您需要压缩他,那么下面的代码您会选择哪个?

A. MemoryStream inStream = new MemoryStream(document);

GZipStream zipStream = new GZipStream(inStream, CompressionMode.Compress); byte[] result = new byte[document.Length];

zipStream.Write(result, 0, result.Length); return result;

B. MemoryStream stream = new MemoryStream(document);

GZipStream zipStream = new GZipStream(stream, CompressionMode.Compress); zipStream.Write(document, 0, document.Length); zipStream.Close();

return stream.ToArray();

C. MemoryStream outStream = new MemoryStream(); //可以扩展大小的内存流 GZipStream zipStream = new GZipStream(outStream, CompressionMode.Compress); zipStream.Write(document, 0, document.Length); zipStream.Close();

return outStream.ToArray();

D. MemoryStream inStream = new MemoryStream(document);

GZipStream zipStream = new GZipStream(inStream, CompressionMode.Compress); MemoryStream outStream = new MemoryStream(); int b;

while ((b = zipStream.ReadByte()) != -1)

44 / 52

{ outStream.WriteByte((byte)b);}

return outStream.ToArray(); Answer: C

解析:压缩一个字节数组的方法,需要内存字节流的对象,查看 MSDN 中 MemoryStream 类的方法和构造函数,选择 C 答案作为压缩字节数组的方法.和第 85 道个类似

79. 拖拽问题.

You are developing an application to cerat a new file on the local file system.

You need to define specific secunty settings for the file.You must deny the file inheritance of any default security settings duning creatiom.

What should you do?

To answer,move the three appropriate actions from the list of actions to the answer area and arrange them in the correct order.

. 拖拽问题:将内容拖拽到适当位置. 回答: 拖第二、第四、第五到右边。

79(2) 79(2)拖拽问题

. 拖放问题:将内容拖放到适当的位置. 回答: 拖第二、第五、第六到右边。 .

80.您使用下面的代码片段来创建了一个汽车类.

您创建了一个汽车类的实例.

您需要填充车辆类实例中下表所示的公共的字段.

MemberValuevehicleTypecarmodelraceryear2002miles15000conditionAboveAvera ge 需要确定此车辆类实例序列化时产生的 XML 块. 哪些XML XML XML块能表示序列化车辆实例的输出?

A.

racer

15000AboveAverage

B.

45 / 52

50. //您的应用程序运用了两个线程,名分别为threadOne和threadTwo您需要修改代码防止从线程threadOne的执行到threadTwo的执行完成.您将如何去做?

A. 将threadOne 配置为以较低优先级运行.

B. 将threadTwo 配置为以较高优先级运行. C. 使用WaitCallback 委托同步这两个线程. D. 调用threadOne 的Sleep 方法. E. 调用threadOne 的SpinLock 方法. Answer: C

解析:显示 A,B,D 都不合适.A,B 不管优先级为什么,都早晚会执行完毕,题目要求是不允许执行完成,所以 AB 都不正确 ,D 是睡眠,肯定也不合适,睡眠结束之后还是要运行,看 C 和 E,C 是等待程序去回调,如果你不回调,就会一直不运行,看来 C 可以, 再看 E,SpinLock 功能是,是一种 Linux 内核中广泛运用的底层同步机制.是一种工作于多处理器环境的特殊的锁,在单处理环境中自旋锁的操作被替换为空操作.所以,E 也不合适.

51.您正在调试一个应该程序, 您需要找到抛出异常的代码. 异常类的哪一个属性能完成这一目的.

A. Data B. Message C. StackTrace D. Source Answer: C

解析:此程序是没有什么悬念的,data 是数据,Message 是消息.Source 是数据源,所以只能选择 C.栈跟踪

52.您需要写一个接收日期参数的多播委托,您应该使用哪一个代码片段 //委托就是一个方法,题目没有返回值

A. public delegate int PowerDeviceOn(bool result, DateTime autoPowerOff); B. public delegate bool PowerDeviceOn(object sender, EventArgs autoPowerOff); C. public delegate void PowerDeviceOn(DateTime autoPowerOff); D. public delegate bool PowerDeviceOn(DateTime autoPowerOff); Answer: C

31 / 52

解析:多播委托可以有返回值,但是本题中没要求有返回值,所以答案为 C.

53. 您正在创建一个撤消缓冲区存储数据的修改

您首先必须确保撤消功能复原大部分最近修改的数据 您还需要确保撤消缓冲区,只允许存储字符串. ? 您应该使用哪一个代码段?

A. Stack undoBuffer = new Stack(); B. Stack undoBuffer = new Stack(); C. Queue undoBuffer = new Queue(); D. Queue undoBuffer = new Queue();

Answer: A

解析:缓冲区是堆栈部分,所以要撤消缓冲区的数据修改,需要把缓冲区重新 new 出来, 而且是只允许存储字符串,所以应为 string 泛型类.

54.您正在创建一个使用非托管资源的类, 这个类保持在其它对象上的有管理代码

您应该确保这个类的使用者能在这个类不再使用时释放资源 ? 您应该执行哪三个动作? (每一个正确的答案提出解决办法的一部分 .) , 选择三个.)

答案翻译:

A. 定义类使得该类继承于WeakReference 类. B. 定义类使得该类实现IDisposable 接口.

C. 创建类析构函数,该函数在其他对象上调用方法来释放托管资源. D. 创建一个释放非托管资源的类析构函数.

E. 创建一个Dispose 方法,该方法调用System.GC.Collect来强制进行垃圾回收.

F. 创建一个Dispose 方法,该方法释放非托管资源,并在其他对象上调用方法来释放托管资源.

Answer: B, D, F

解析:实现需要有三步,第一步,需要声明一个类,实现 IDisposable 接口的方法. 第二步,创建一个类的析构函数释放非托管资源.

第三步, 创建一个 Dispose 方法时释放非托管资源, 并调用其他对象上的方法释放管

32 / 52

理资源. 这三步对应 BDF 选项.

55.

您需要创建一个方法,清除命名为q的Queue,您应该使用哪一个代码片段? A. foreach (object e in q) { q.Dequeue();} B. foreach (object e in q) { Enqueue(null);} C. q.Clear(); D. q.Dequeue();

Answer: C 解析:集合和队列的清除全是用 clear 方法.所以选 C.

56您写了下面这段代码

public delegate void FaxDocs (object sender, FaxArgs args);

您需要创建一个事件去调用FaxDocs, FaxDocs,您应该使用哪个代码片段 A. public static event FaxDocs Fax; event 声明事件的关键字. B. public static event Fax FaxDocs; C. public class FaxArgs : EventArgs { private string coverPageInfo; public FaxArgs(string coverInfo) { this.coverPageInfo = coverPageInfo; } public string CoverPageInformation { get {return this.coverPageInfo;} }} D. public class FaxArgs : EventArgs { private string coverPageInfo; public string CoverPageInformation { get {return this.coverPageInfo;}

Answer: A

解析:C 和 D 肯定是错误的,声明了委托,需要用委托作为数据类型去声明事件,所以 A 和 B 中的一个是正确的.A 是声明的委托类型,B 是 Fax 类型的.是错误的.所以选 A. }}

57. 您应该选择一个类,是从小的和大的集合中恢复关键项的最好的. ? 您应该选择哪一个类?

A. OrderedDictionary class表示根据键/索引排序的键/值对的集合. B. HybridDictionary class C. ListDictionary class小集合.

D. Hashtable class存储大集合时效率最高.

Answer: B

解析:看每一个类的解释,应该选用B,当集合数目大于10,小于10时,有所区别

33 / 52

58. 正确翻译:您正在创建一个名为Assembly1 的强名称程序集,该程序集将在多个应用 程序中使用.在开发周期中,

将会频繁重新建立Assembly1. 您需要确保该程序集在每次重新建立时都能与使用它的每个应用程序正常协同工作.

您需要配置在其中开发Assembly1 的计算机, 以使每个应用程序都使用Assembly1 的最新版本.

您应该执行哪两项操作?(每个正确答案都仅给出了部分解决方案.请选择两个答案.) A. 创建一个DEVPATH 环境变量,该环境变量指向强名称程序集的版本输出目录.

B. 将以下XML 元素添加到计算机配置文件:

C. 将以下XML 元素添加到计算机配置文件:

D. 将以下XML 元素添加到使用强名称程序集的每个应用程序的配置文件: E. 将以下XML 元素添加到使用强名称程序集的每个应用程序的配置文件:

Answer: AB

59.您正在使用Microsoft Visual Studio 2005 IDE 检查一个返回string的方法的输出信息, fName 您指定这个方法的输出给一个命名为fName的变量,您需要写一个代码片段打印下面这一 \行信息\如果fName的值不为\您应该确定这个应该程序的代码持续的执行,您应该使用哪一个代码片段

A. Debug.Assert(fName == \ B. Debug.WriteLineIf(fName != \

C. if (fName != \ Debug.Print(fName);

D. if (fName != \

Answer: B

60. 正确翻译:您创建一个由公司三个部门中的应用程序使用的类库.该库包含一个具有以下定义的Department 类.

34 / 52

public class Department {

public string name; public string manager; }

每个应用程序使用一个自定义配置节在应用程序配置文件中存储特定于部门的值, 如以下代码中所示.

Hardware Amy

您需要编写一个代码段,该代码段通过使用从应用程序配置文件中检索的字段值来创建 Department 对象实例.

您应该使用哪个代码段?

C. public class deptHandler :IConfigurationSectionHandler { public object Create(object parent, object configContext, System.Xml.XmlNode section) {

Department dept = new Department();

dept.name = section.SelectSingleNode(\ dept.manager =

section.SelectSingleNode(\ return dept;

} }

D. public class deptHandler :IConfigurationSectionHandler { public object Create(object parent, object configContext, System.Xml.XmlNode section) {

Department dept = new Department();

dept.name = section.Attributes[\

dept.manager = section.Attributes[\ return dept; } }

Answer: C

解析: 从题目中看需要返回一个对象值, 所以必须要声明一个有返回值且返回值类型为对象类型的方法,可以排除答案 A 和 B.C 和 D 的区别就在于使用 section 的哪个方法来取得值了.从 MSDN 上可以看到,XMLNode 就没有 Attributes[\的用法.所以应选 C. SelectSingleNode 方法的功能,选择匹配 XPath 表达式的第一个 XmlNode.

61. 您正在测试一个名为PersistToDB 的新开发的方法.此方法接受EventLogEntry 类型的参数.此方法不返回值.

您需要创建一个可帮助您测试该方法的代码段. 代码段必须从本地计算机的应用程序

35 / 52

日志中读取条目,然后将条目传递到PersistToDB 方法.代码块必须只将Error 或Warning 类型的事件从源\传递到PersistToDB 方法.

您应该使用哪个代码段

A. EventLog myLog = new EventLog(\ foreach (EventLogEntry entry in myLog.Entries) {

if (entry.Source == \ B. EventLog myLog = new EventLog(\ myLog.Source = \

foreach (EventLogEntry entry in myLog.Entries)

{ if (entry.EntryType == (EventLogEntryType.Error & EventLogEntryType.Warning)) { PersistToDB(entry); } } }

C. EventLog myLog = new EventLog(\ foreach (EventLogEntry entry in myLog.Entries) { if (entry.Source == \

{if (entry.EntryType == EventLogEntryType.Error | |entry.EntryType == EventLogEntryType.Warning)

{ PersistToDB(entry); } } }

D. EventLog myLog = new EventLog(\ myLog.Source = \

foreach (EventLogEntry entry in myLog.Entries) {if (entry.EntryType ==

EventLogEntryType.Error |entry.EntryType == EventLogEntryType.Warning) {PersistToDB(entry); 答案: C }

62.您正在开发的应用程序接收异步事件.您创建一个 WqlEventQuery WqlEventQuery实例指向 ManagementEventWatcher 特定的事件和事件条件,该申请必须作出反应.您也创建了ManagementEventWatcher 实例为了订阅查询相匹配的事件.您需要确定的其他行动之前,您必须执行的应用程序可以接收异步事件.这两项行动应您执行? (每正确回答提出解决办法的一部分.请选择两项. )

A. 通过调用 Start 方法的 ManagementEventWatcher 开始监听事件

B. 为事件设置一个监听者使用ManagementEventWatcher的EventArrived 事件 C. 使用ManagementEventWatcher事件的WaitForNextEvent 方法等待这个事件 D. 建立一个事件句柄类,其中的方法用来接收ObjectReadyEventArgs传递的参数 E.为事件设置一个监听者用ManagementEventWatcher来停止事件 答案: A, B C

36 / 52

63.您要测试的方法, 检查运行过程. 此方法返回一个被加载在C:\\TestApps\\Process1.exe ArrayList 进程中包含名称和全路径的所有模块的ArrayList ArrayList,.您需要加载进程的模块列表,您用下面的哪个代码?

A. ArrayList ar = new ArrayList();

Process[] procs; ProcessModuleCollection modules;

procs = Process.GetProcesses(@\

if (procs.Length > 0) {modules = procs[0].Modules;

foreach (ProcessModule mod in modules) {ar.Add(mod.ModuleName); B. ArrayList ar = new ArrayList(); Process[] procs;

ProcessModuleCollection modules;

procs = Process.GetProcesses(@\ if (procs.Length > 0) { modules = procs[0].Modules; }} }}

foreach (ProcessModule mod in modules) {ar.Add(mod.ModuleName); C. ArrayList ar = new ArrayList(); Process[] procs;

ProcessModuleCollection modules;

procs = Process.GetProcessesByName(@\ if (procs.Length > 0) { modules = procs[0].Modules; }} foreach (ProcessModule mod in modules) {ar.Add(mod.FileName); D. ArrayList ar = new ArrayList();

Process[] procs;

ProcessModuleCollection modules;

procs = Process.GetProcessesByName(@\ if (procs.Length > 0) { modules = procs[0].Modules;

foreach (ProcessModule mod in modules) {ar.Add(mod.FileName); 答案: C

解析:题目考察的是得到指定进程的进程资源,所以选择GetProcessesByName(). 排除答案AB.D的路径名写错了.所以选C

64. 您创建了一个应用程序, 存储信息为您的居住在不同区域的客户. 在您的应用程序中的作用是发展中的国家的工具.您需要收集您位于加拿大的客户的区域信息,该段代码应该如何使用:?

A. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { // Output the region information……}

B. CultureInfo cultureInfo = new CultureInfo(\ C. RegionInfo regionInfo = new RegionInfo(\ D. RegionInfo regionInfo = new RegionInfo(\ { // Output the region information……}

37 / 52

答案: C

65.您正在为一个客户进行财务报表.您的客户在美国墨西哥办事处有一个主要的办公室. 您必须确保当用户在办公室产生的报告,当前的日期显示在墨西哥西班牙语格式.该代码段应该使用?

A. DateTimeFormatInfo dtfi = new CultureInfo(\ DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);

string dateString = dt.ToString(dtfi.LongDatePattern);

B. Calendar cal = new CultureInfo(\ DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day); Strong dateString = dt.ToString();

C. string dateString = DateTimeFormatInfo.CurrentInfo GetMonthName(DateTime.Today.Month);

D. string dateString = DateTime.Today.Month.ToString(\

Answer: A

66.您需要生成一个报表,用于形成语言代码代码和区域代码的列表, 该代码段应该使用?

A. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { // Output the culture information……}

B. CultureInfo culture = new CultureInfo(\ CultureTypes types = culture.CultureTypes; //

Output the culture information……

C. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) { // Output the culture information……}

D. foreach (CultureInfo culture inCultureInfo.GetCultures(CultureTypes. ReplacementCultures))

{ // Output the culture information……} 答案: A

38 / 52

67. 您正在开发的一种方法,搜索一个字符串的子字符串.该方法将被于意大利本地化. searchListThe 您的方法接受下列参数:字符串被搜查,这是命名searchListThe searchListThe字符串来搜索,这是命名 searchValue searchValue您需要编写代码.该代码段应该使用?

A. return searchList.IndexOf(searchValue);

B. CompareInfo comparer = new CultureInfo(\

return comparer.Compare(searchList, searchValue); C. CultureInfo comparer = new CultureInfo(\if (searchList.IndexOf(searchValue) > 0) {return true;} else {return false;}

D. CompareInfo comparer = new CultureInfo(\if (comparer.IndexOf(searchList, searchValue) > 0) {return true;}

else {return false;}

Answer: D

68. 您正在为新的客户端应用程序开发一个实用程序.该实用程序在屏幕上显示一个温度计,该温度计显示应用程序正在执行的进程的当前状态.

您需要在屏幕上绘制一个矩形来充当温度计的背景, 如相关材料中所示. 此矩形必须使用渐变底纹进行填充.

(单击相关材料按钮.)

您应该选择哪个代码段?

A. Rectangle rectangle = new Rectangle(10, 10, 450, 25);

LinearGradientBrush rectangleBrush =new LinearGradientBrush(rectangle, Color.AliceBlue, Color.CornflowerBlue, LinearGradientMode.ForwardDiagonal); Pen rectanglePen = new Pen(rectangleBrush); Graphics g = this.CreateGraphics();

g.DrawRectangle(rectanglePen, rectangle);

B. Rectangle rectangle = new Rectangle(10, 10, 450, 25);

LinearGradientBrush rectangleBrush =new LinearGradientBrush(rectangle, Color.AliceBlue, Color.CornflowerBlue, LinearGradientMode.ForwardDiagonal); Pen rectanglePen = new Pen(rectangleBrush); Graphics g = this.CreateGraphics();

g.FillRectangle(rectangleBrush, rectangle);

C. RectangleF rectangle = new RectangleF(10f, 10f,450f, 25f);

Point[] points = new Point[] {new Point(0, 0), new Point(110, 145)};

LinearGradientBrush rectangleBrush =newLinearGradientBrush(rectangle, Color.AliceBlue, Color.CornflowerBlue, LinearGradientMode.ForwardDiagonal); PenrectanglePen = new Pen(rectangleBrush); Graphics

g = this.CreateGraphics(); g.DrawPolygon(rectanglePen, points);

39 / 52

D.RectangleF rectangle = new RectangleF(10f, 10f, 450f, 25f); SolidBrush rectangleBrush =new SolidBrush(Color.AliceBlue); Pen rectanglePen = new Pen(rectangleBrush); Graphics g = this.CreateGraphics();

g.DrawRectangle(rectangleBrush, rectangle);

答案: B

解析:题目要求填充长方形的颜色,只有B 答案,调用FillRectangle()方法填充

70. 您正在开发的一种方法散列数据的安全散列算法.这些数据传递给您的方法作为一个字节数组命名讯息.您需要计算的散列的传入参数使用 SHA1 .您还需要将结果到一个字节数组命名散列.该代码段应该使用?

A. SHA1 sha = new SHA1CryptoServiceProvider(); byte[] hash = null;

sha.TransformBlock(message, 0message.Length, hash, 0); B. SHA1 sha = new SHA1CryptoServiceProvider();

byte[] hash = BitConverter.GetBytes(sha.GetHashCode()); C. SHA1 sha = new SHA1CryptoServiceProvider(); byte[] hash = sha.ComputeHash(message);

D. SHA1 sha = new SHA1CryptoServiceProvider(); sha.GetHashCode(); byte[] hash = sha.Hash;

答案: C

解析:此题要求是在安全的情况下,计算一些数据的哈希值,所以用到 SHA1CryptoServiceProvider加密技术.计算哈希值,调用uterHash方法

71.如果您创建了一个名叫Assembly1的程序集,它包含了一个public方法.而在全局高速缓存里包含了另一个程序集叫Assembly2.如果您必须确定那个public方法只能在 Assembly2中被调用,则您应该使用下面的哪个权限类.

A. GacIdentityPermission

B. PublisherIdentityPermission C. DataProtectionPermission

D. StrongNameIdentityPermission

Answer: D

解析:分析题目要求,访问Public的方法具有一定的权限. A. 从全局缓冲中得到的文件的权限 B. 标示开发商的权限

40 / 52


.NET70-536微软认证中文题库.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:山东2019年中考地理第十二章中国的经济与文化复习练习33

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: