為大家收集整理了《2013微軟認(rèn)證考試練習(xí)題及答案(6)》供大家參考,希望對(duì)大家有所幫助?。?!
第 26 題
請(qǐng)使用下面的條件確定一個(gè)類型:
1) 是一個(gè)數(shù)字。
2) 不大于 65,535
請(qǐng)問(wèn),是哪一個(gè)類型?
A. System.UInt16
B. int
C. System.String
D. System.IntPtr
答案: A
第 27 題
你正在寫(xiě)用戶驗(yàn)證和授權(quán)的代碼。username, password, 和roles存儲(chǔ)在你的應(yīng)用數(shù)據(jù)存儲(chǔ)區(qū)。
你需要建立一個(gè)用于授權(quán)檢查的用戶安全上下文,例如IsInRole。你寫(xiě)如下的代碼段去驗(yàn)證用戶:
if (!TestPassword(userName, password))
throw new Exception("could not authenticate user");
String[] userRolesArray =LookupUserRoles(userName);
你需要完成這段代碼從而為用戶建立安全上下文。你應(yīng)該使用那個(gè)代碼段?
A. GenericIdentity ident = new GenericIdentity(userName);
GenericPrincipal currentUser = new GenericPrincipal(ident, userRolesArray);
Thread.CurrentPrincipal = currentUser;
B. WindowsIdentity ident = new WindowsIdentity(userName);WindowsPrincipal currentUser =
new WindowsPrincipal(ident);Thread.CurrentPrincipal = currentUser;
C. NTAccount userNTName = new NTAccount(userName);GenericIdentity ident = new
GenericIdentity(userNTName.Value);GenericPrincipal currentUser= new
GenericPrincipal(ident, userRolesArray);Thread.CurrentPrincipal = currentUser;
D. IntPtr token = IntPtr.Zero;token = LogonUserUsingInterop(username,
encryptedPassword);WindowsImpersonationContext ctx =
WindowsIdentity.Impersonate(token);
答案: A
第 28 題
你正在為一個(gè) Hong Kong 的客戶開(kāi)發(fā)一個(gè)應(yīng)用。你需要為本地的貨幣顯示一個(gè)符號(hào)。你應(yīng)該使
用那段代碼?
A. NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat;
culture.NumberNegativePattern = 1; return numberToPrint.ToString("C", culture);
B. NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat;
culture.CurrencyNegativePattern = 1; return numberToPrint.ToString("C", culture);
C. CultureInfo culture = new CultureInfo("zh-HK");return numberToPrint.ToString("-(0)",
culture);
D. CultureInfo culture = new CultureInfo("zh-HK"); return numberToPrint.ToString("()", culture);
答案: B
第 29 題
你正在開(kāi)發(fā)一個(gè)將執(zhí)行數(shù)學(xué)計(jì)算的應(yīng)用。你需要確保應(yīng)用能夠同時(shí)的執(zhí)行多個(gè)計(jì)算。你應(yīng)該
怎么做?
A. 設(shè)置ProcessThread對(duì)象的IdealProcessor屬性。
B. 設(shè)置ProcessThread對(duì)象的ProcessorAffinity屬性。
C. 使用for each進(jìn)行計(jì)算;調(diào)用ThreadPool的QueueUserWorkItem方法。
D. 設(shè)置Process.GetCurrentProcess().BasePriority為High.
答案: C
第 30 題
你正在開(kāi)發(fā)一個(gè)名為 PollingService 的服務(wù),這個(gè)服務(wù)定期的調(diào)用一些需要長(zhǎng)時(shí)間運(yùn)行的過(guò)程。
這些過(guò)程被 DoWork 方法調(diào)用。你的服務(wù)代碼如下:
ref class PollingService : public ServiceBase {
public :
static bool blnExit = false;
protected :
override void OnStart(String^ args) {
do {
DoWork();
} while (!blnExit);
}
override void OnStop() {
blnExit = true;
}
private :
void DoWork() {} };
當(dāng)你試圖去啟動(dòng)服務(wù)的時(shí)候,你收到一個(gè)錯(cuò)誤:在本地計(jì)算機(jī)上不能啟動(dòng)PollingService服務(wù)。
Error 1053:服務(wù)不響應(yīng)啟動(dòng)或控制。你需要去修改服務(wù)代碼,使服務(wù)能夠被正確啟動(dòng)。你應(yīng)該
如何做?
A. 把循環(huán)代碼從OnStart 方法移動(dòng)到服務(wù)類的構(gòu)造函數(shù)中。
B. 在服務(wù)的設(shè)計(jì)界面拖入一個(gè)timer組件。把調(diào)用長(zhǎng)運(yùn)行時(shí)間過(guò)程的代碼從OnStart方法移動(dòng)到
timer的Tick事件中。在OnStart方法中設(shè)置timer的Enabled屬性為T(mén)rue,并且調(diào)用timer的Start
方法。
C. 給服務(wù)類增加一個(gè)類級(jí)別的System.Timers.Timer 變量。然后在timer的Elapsed事件中調(diào)用
DoWork方法。在OnStart方法中設(shè)置timer的Enabled屬性為T(mén)rue,并且調(diào)用timer的Start方法。
D. 把循環(huán)代碼從OnStart 方法移動(dòng)到DoWork方法中。
答案: C
第 26 題
請(qǐng)使用下面的條件確定一個(gè)類型:
1) 是一個(gè)數(shù)字。
2) 不大于 65,535
請(qǐng)問(wèn),是哪一個(gè)類型?
A. System.UInt16
B. int
C. System.String
D. System.IntPtr
答案: A
第 27 題
你正在寫(xiě)用戶驗(yàn)證和授權(quán)的代碼。username, password, 和roles存儲(chǔ)在你的應(yīng)用數(shù)據(jù)存儲(chǔ)區(qū)。
你需要建立一個(gè)用于授權(quán)檢查的用戶安全上下文,例如IsInRole。你寫(xiě)如下的代碼段去驗(yàn)證用戶:
if (!TestPassword(userName, password))
throw new Exception("could not authenticate user");
String[] userRolesArray =LookupUserRoles(userName);
你需要完成這段代碼從而為用戶建立安全上下文。你應(yīng)該使用那個(gè)代碼段?
A. GenericIdentity ident = new GenericIdentity(userName);
GenericPrincipal currentUser = new GenericPrincipal(ident, userRolesArray);
Thread.CurrentPrincipal = currentUser;
B. WindowsIdentity ident = new WindowsIdentity(userName);WindowsPrincipal currentUser =
new WindowsPrincipal(ident);Thread.CurrentPrincipal = currentUser;
C. NTAccount userNTName = new NTAccount(userName);GenericIdentity ident = new
GenericIdentity(userNTName.Value);GenericPrincipal currentUser= new
GenericPrincipal(ident, userRolesArray);Thread.CurrentPrincipal = currentUser;
D. IntPtr token = IntPtr.Zero;token = LogonUserUsingInterop(username,
encryptedPassword);WindowsImpersonationContext ctx =
WindowsIdentity.Impersonate(token);
答案: A
第 28 題
你正在為一個(gè) Hong Kong 的客戶開(kāi)發(fā)一個(gè)應(yīng)用。你需要為本地的貨幣顯示一個(gè)符號(hào)。你應(yīng)該使
用那段代碼?
A. NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat;
culture.NumberNegativePattern = 1; return numberToPrint.ToString("C", culture);
B. NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat;
culture.CurrencyNegativePattern = 1; return numberToPrint.ToString("C", culture);
C. CultureInfo culture = new CultureInfo("zh-HK");return numberToPrint.ToString("-(0)",
culture);
D. CultureInfo culture = new CultureInfo("zh-HK"); return numberToPrint.ToString("()", culture);
答案: B
第 29 題
你正在開(kāi)發(fā)一個(gè)將執(zhí)行數(shù)學(xué)計(jì)算的應(yīng)用。你需要確保應(yīng)用能夠同時(shí)的執(zhí)行多個(gè)計(jì)算。你應(yīng)該
怎么做?
A. 設(shè)置ProcessThread對(duì)象的IdealProcessor屬性。
B. 設(shè)置ProcessThread對(duì)象的ProcessorAffinity屬性。
C. 使用for each進(jìn)行計(jì)算;調(diào)用ThreadPool的QueueUserWorkItem方法。
D. 設(shè)置Process.GetCurrentProcess().BasePriority為High.
答案: C
第 30 題
你正在開(kāi)發(fā)一個(gè)名為 PollingService 的服務(wù),這個(gè)服務(wù)定期的調(diào)用一些需要長(zhǎng)時(shí)間運(yùn)行的過(guò)程。
這些過(guò)程被 DoWork 方法調(diào)用。你的服務(wù)代碼如下:
ref class PollingService : public ServiceBase {
public :
static bool blnExit = false;
protected :
override void OnStart(String^ args) {
do {
DoWork();
} while (!blnExit);
}
override void OnStop() {
blnExit = true;
}
private :
void DoWork() {} };
當(dāng)你試圖去啟動(dòng)服務(wù)的時(shí)候,你收到一個(gè)錯(cuò)誤:在本地計(jì)算機(jī)上不能啟動(dòng)PollingService服務(wù)。
Error 1053:服務(wù)不響應(yīng)啟動(dòng)或控制。你需要去修改服務(wù)代碼,使服務(wù)能夠被正確啟動(dòng)。你應(yīng)該
如何做?
A. 把循環(huán)代碼從OnStart 方法移動(dòng)到服務(wù)類的構(gòu)造函數(shù)中。
B. 在服務(wù)的設(shè)計(jì)界面拖入一個(gè)timer組件。把調(diào)用長(zhǎng)運(yùn)行時(shí)間過(guò)程的代碼從OnStart方法移動(dòng)到
timer的Tick事件中。在OnStart方法中設(shè)置timer的Enabled屬性為T(mén)rue,并且調(diào)用timer的Start
方法。
C. 給服務(wù)類增加一個(gè)類級(jí)別的System.Timers.Timer 變量。然后在timer的Elapsed事件中調(diào)用
DoWork方法。在OnStart方法中設(shè)置timer的Enabled屬性為T(mén)rue,并且調(diào)用timer的Start方法。
D. 把循環(huán)代碼從OnStart 方法移動(dòng)到DoWork方法中。
答案: C