Q11: You need to create a dynamic assembly named MyAssembly. You also
need to save the assembly to disk. Which code segment should you use?
A. AssemblyName myAssemblyName = new AssemblyName();
myAssemblyName.Name = “MyAssembly”;
AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly
(myAssemblyName, AssemblyBuilderAccess.Run);
myAssemblyBuilder.Save(”MyAssembly.dll”);
B. AssemblyName myAssemblyName = new AssemblyName();
myAssemblyName.Name = “MyAssembly”;
AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly
(myAssemblyName, AssemblyBulderAccess.Save);
myAssemblyBuilder.Save(”MyAssembly.dll”);
C. AssemblyName myAssemblyName = new AssemblyName();
AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly
(myAssemblyName, AssemblyBuilderAccess.RunAndSave);
myAssemblyBuilder.Save(”MyAssembly.dll”);
D. AssemblyName myAssemblyName = new AssemblyName(”MyAssembly”);
AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly
(myAssemblyName, AssemblyBuilderAccess.Save);
myAssemblyBuilder.Save(”c:\\MyAssembly.dll”);
Answer: B
Q12: You need to call an unmanaged function from your managed code by
using platform invoke services. What should you do?
A. Create a class to hold DLL functions and then create prototype methods by using managed code.
B. Register your assembly by using COM and then reference your managed code from COM.
C. Export a type library for your managed code.
D. Import a type library as an assembly and then create instances of COM object.
Answer: A
Q13: You are loading a new assembly into an application. You need to
override the default evidence for the assembly. You require the common
language runtime (CLR) to grant the assembly a permission set, as if the
assembly were loaded from the local intranet zone. You need to build the
evidence collection. Which code segment should you use?
A. Evidence evidence = new Evidence(Assembly.GetExecutingAssembly().Evidence);
B. Evidence evidence = new Evidence();
evidence.AddAssembly(new Zone(SecurityZone.Intranet));
C. Evidence evidence = new Evidence();
evidence.AddHost(new Zone(SecurityZone.Intranet));
D. Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
Answer: C
Q14: You write the following code to implement the CompanyClass.MyMethod
function.
public class CompanyClass {
public int MyMethod(int arg) {
return arg; }}
You need to call the CompanyClass.MyMethod function dynamically from an
unrelated class in your assembly. Which code segment should you use?
A. CompanyClass myClass = new CompanyClass();
Type t = typeof(CompanyClass);
MethodInfo m = t.GetMethod(”MyMethod”);
int i = (int)m.Invoke(this, new object[] { 1 });
B. CompanyClass myClass = new CompanyClass();
Type t = typeof(CompanyClass);
MethodInfo m = t.GetMethod(”MyMethod”);
int i = (int) m.Invoke(myClass, new object[] { 1 });
C. CompanyClass myClass = new CompanyClass();
Type t = typeof(CompanyClass);
MethodInfo m = t.GetMethod(”CompanyClass.MyMethod”);
int i = (int)m.Invoke(myClass, new object[] { 1 });
D. Type t = Type.GetType(”CompanyClass”);
MethodInfo m = t.GetMethod(”MyMethod”);
int i = (int)m.Invoke(this, new object[] { 1 });
Answer: B
Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application
Q1: You are developing an application for a client residing in Hong Kong.
You need to display negative currency values by using a minus sign. Which
code segment should you use?
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);
Answer: B
Q2: You are writing a method that accepts a string parameter named
message. Your method must break the message parameter into individual
lines of text and pass each line to a second method named Process.
Which code segment should you use?
A. StringReader reader = new StringReader(message);
Process(reader.ReadToEnd());
reader.Close();
B. StringReader reader = new StringReader(message);
while (reader.Peek() != -1) {
string line = reader.Read().ToString();
Process(line);}
reader.Close();
C. StringReader reader = new StringReader(message);
Process(reader.ToString());
reader.Close();
D. StringReader reader = new StringReader(message);
while (reader.Peek() != -1) {
Process(reader.ReadLine());}
reader.Close();
Answer: D
Q3: You are developing a fiscal report for a customer. Your customer has
a main office in the United States and a satellite office in Mexico.
You need to ensure that when users in the satellite office generate the
report, the current date is displayed in Mexican Spanish format. Which code
segment should you use?
A. DateTimeFormatInfo dtfi = new CultureInfo(”es-MX”, false).DateTimeFormat;
DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);
string dateString = dt.ToString(dtfi.LongDatePattern);
B. Calendar cal = new CultureInfo(”es-MX”, false).Calendar;
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(”es-MX”);
Answer: A
Q4: You create an application that stores information about your
customers who reside in various regions. You are developing internal
utilities for this application. You need to gather regional information about
your customers in Canada. Which code segment should you use?
A. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
// Output the region information…
}
B. CultureInfo cultureInfo = new CultureInfo(”CA”);
// Output the region information
C. RegionInfo regionInfo = new RegionInfo(”CA”);
// Output the region information
D. RegionInfo regionInfo = new RegionInfo(”");
if(regionInfo.Name == “CA”) {
// Output the region information
}
Answer: C
Q5: You need to generate a report that lists language codes and region
codes. Which code segment should you use?
A. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) {
// Output the culture information…
}
B. CultureInfo culture = new CultureInfo(”");
CultureTypes types = culture.Culture Types;
// Output the culture information…
C. foreach (CultureInfo culture in
CultureInfo.GetCultures(CultureTypes.NeutralCultures)) {
// Output the culture information…
}
D. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.ReplacementCultures)) {
// Output the culture information…
}
Answer: A
Q6: You are developing a method that searches a string for a substring.
The method will be localized to Italy.
Your method accepts the following parameters: The string to be searched,
which is named searchListThe string for which to search, which is named
searchValue You need to write the code. Which code segment should you
use?
A. return searchList.IndexOf(searchValue);
B. CompareInfo comparer = new CultureInfo(”it-IT”).CompareInfo;
return comparer.Compare(searchList, searchValue);
C. CultureInfo Comparer = new CultureInfo(”it-IT”);
if(searchList.IndexOf(searchValue) > 0) {
return true;
} else {
return false;}
D. CompareInfo comparer = new CultureInfo(”it-IT”).CompareInfo;
if (comparer.IndexOf(searchList, searchValue) > 0) {
return true;}
else {
return false;}
Answer: D
Q7: You are developing a utility screen for a new client application. The
utility screen displays a thermometer that conveys the current status of
processes being carried out by the application. You need to draw a
rectangle on the screen to serve as the background of the thermometer as
shown in the exhibit. The rectangle must be filled with gradient shading.
Which code segment should you choose?
Exhibit:
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 rectangelBrush = new LinearGradientBrush(rectangle, Color.AliceBlue, Color.CornflowerBlue, LinearGradientMode.ForwardDiagonal);
Pen rectanglePen = new Pen(rectangleBrush);
Graphics g = this.CreateGraphics();
g.DrawPolygon(rectanglePen, points);
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);
Answer: B
–Nikhil Kumar