需要注意的 MCSD 题目 316, 1

Question

You use Visual Studio .NET to create a control that will be used on several forms in your application.
It is a custom label control that retrieves and displays your company’s current stock price.
 
The control will be displayed on many forms that have different backgrounds. You want the control
to show as much of the underlying form as possible. You want to ensure that only the stock price is
visible. The rectangular control itself should not be visible.
 
You need to add code to the Load event of the control to fulfill these requirements. Which two code
segments should you use? (Each correct answer presents part of the solution. Choose two)
 
A.  this.BackColor = Color.Transparent;
B.  this.ForeColor = Color.Transparent;
C.  this.BackImage = null;
D.  this.SetStyle(ControlStyles.UserPaint, false);
E.  this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
 
 
Answer: A, E
Explanation: 
To give your control a transparent backcolor:
1.  Call the SetStyle method of your form in the constructor. 
 
this.setStyle(ControlStyles.SupportsTransparentBackColor, true);
This will enable your control to support a transparent backcolor. 
2.  Beneath the line of code you added in step 1, add the following line. This will set your control's
BackColor to Transparent. :
 
this.BackColor = Color.Transparent;

Question

You use Visual Studio .NET to develop an application that contains 50 forms. You create a procedure
named PerformCalculations, which writes the results of several internal calculations to the Debug
window. These calculations take more than one minute to execute.
 
You want to be able to compile two versions of the application, one for debugging and the other for
release. The debugging version should execute the calculations. The release version should not include
or compile the calculations. You want to accomplish this goal by using the minimum amount of code.
 
Which two actions should you take? (Each correct answer presents part of the solution. Choose two)
 
A.  Use the following code segment:
#if DEBUG
// Insert code to perform calculations.
#endif
B.  Use the following code segment:
if (DEBUG) {
// Insert code to perform calculations.
}
C.  Use the following code segment at the top of the module:
#define DEBUG
D.  Add DEBUG = true to the Command Line Arguments box on the Debugging pane of the Project
Properties dialog box.
E.  Ensure that the Conditional Compilation Constants option in the Build pane of the Project
Properties dialog box contains the value DEBUG.
F.  Ensure that the Conditional Compilation Constants options in the Build pane of the Project
Properties dialog box includes the value TRACE.
 
 
Answer: A, E
Explanation: 
A: We should use the #if DEBUG conditionally statement wherever we want to use code that print debug
information. 
E: We enable debugging by entering DEBUG to the Conditional Compilation Constants option.
 
Reference: 
Visual Basic and Visual C# Concepts, Compiling Conditionally with Trace and Debug
C# Language Specification, Conditional compilation directives
 
Incorrect Answers
B: Incorrect syntax.
C: This would achieve the goal as well. But compared to E) it would not minimize code.
D: This is not how it is done in C#. In Visual Basic .NET you could use #CONST DEBUG = true. In
Visual C# however, you must use the DEBUG = true statement.
F:  Traces are used to trace program execution, not to print debug information.
 

Question

You develop a Windows-based application by using Visual Studio .NET. The application includes
numerous method calls at startup. After optimizing your application code, you test the application on
a variety of client computers. However, the startup time is too slow.
 
You must ensure that your application starts as quickly as possible the first time it runs. What should
you do?
 
A.  Precompile your application by using the Native Image Generator (Ngen.exe):
Install the precompiled application on the client computers.
B.  Install your application on the client computers.
Precompile your application by using the Native Image Generator (Ngen.exe).
C.  Precompile your application by using the JIT compiler.
Install the precompiled application on the client computers.
D.  Install your application on the client computers.
Precompile your application by using the JIT compiler.
 
 
Answer: B
Explanation: The Native Image Generator creates a native image from a managed assembly and installs it
into the native image cache on the local computer. Running Ngen.exe on an assembly allows the assembly
to load and execute faster, because it restores code and data structures from the native image cache rather
than generating them dynamically.
The native image contains processor-specific machine code and in this scenario a variety of client computers
are used. We must therefore use the Ngen.exe utility at the client computers after the installation, not at the
Development computer..
 
Reference: 
.NET Framework Tools, Native Image Generator (Ngen.exe)
70-306/70-316 Training kit, Installing a Native Assembly Image, Page 495
.NET Framework Developer's Guide, Compiling MSIL to Native Code
 
Incorrect Answers
A: The Native Image produced by Ngen.exe is machine-specific and in this scenario a variety of client
computers are used. We cannot use the a single Native Image from once computer on all the other
computers..
C, D: JIT (just-in-time) compilation occurs at run-time, and cannot be precompiled.
Note: When you compile a .NET application, it is not compiled to binary machine code; rather, it is
converted to IL, which is a low-level set of instructions understood by the common language run time.

When execution starts, the first bit of code that needs to be executed is loaded into memory and
compiled into native binary code from IL by the common language run time's Just-In-Time (JIT)
compiler.
 

展开阅读全文

四条MCSD题目

03-11

You write a Wondows-based application by using MFC.You create a scrolling view class by deriving from the MFC library class CScorollView. The source code that implements your class includes the following code fragment:rnCMyView::OnLButtonDown(UNIT,CPoint point)rnrn CCLientDC dc(this);rn OnPrepareDC(&dc);rnrnWhat is the most likely result of the call to the OnPrepareDC function?rnA.The clipping region of the view is adjusted to the containing framernB.The device Contest object is enabled for GDI calls.rnC.The view will disable scrolling while drawing takes place.rnD.The viewport origin and viewport extents are adjusted to the containing frame.rnrnrnYou create an application for your company.The company has a network connecting several work locations across the country.Computers at all locations have access to a central several work locations across the country.Computers at all locations have access to a central server on this network.The server is located at the read office.You want to package the application files in a single.cab filernWhat must you have to create the .cab file (Chose all that apply.)rnA.the application filesrnB.the .inf file describing files to be packaged in the .cab filernC.a Software Publisher CertificaternD.the Cabarc utility programrnE.the Cabivew utility programrnF.the Signcode utility programrnrnrnYou write a Windows-based application by using Platform SDK.In your application,you want to initiate an action whenever the user presses the F2 key.rnWhich Microsoft Windows message should you respond to?rnA.WM_CHARrnB.WM_HOTKEYrnC.WM_SYSKEYDOWNrnD.WM_KEYDOWNrnE.WM_SETHOTKEYrnF.WM_GETHOTKEYrnrnrnrnYou design a Windows-based application by using MFC.Users can enable or disable error logging by clicking the Log Errors command on the Tools menu of Your application.Error logging is indicated by a check mark displayed next to the log Errors command on the Tools menu.The state of the menu item is stored in a Boolean class member variable named m_bLogErrors.rnHow should you manage the menu item?rnA.Write an ON_UPDATE_COMMAND_UI handler function,and add it to the message map.rn Call the CCmdUI::SetRadio function from within the handlerrnB.Write an ON_COMMAND handler function,and add it to the message map.rn Call the CcmdUI::Enable function from within the handler.rnC.Write an ON_UPDATE_COMMAND_UI handler function,and add it to the message map.rn Call the CCmdUI::Enable function from within the handler.rnD.Write an ON_COMMAND handler function,and add it to the message map.rn Call the CCmdUI::SetCheck function from within the handler.rnE.Write an ON_UPDATE_COMMAND_UI handler function,and add it to the message map.rn Call the CCmdUI::SetCheck Function from within the handler.rnF.Write an ON_COMMAND handler function,and add it to the message map.rn Call the CCmdUI::SetRadio function from within the handler.rnrn分别该怎么做啊,再写一下为什么,谢谢 论坛

没有更多推荐了,返回首页