Microsoft .NET Framework 2.0 Application Development Foundation

Microsoft .NET Framework 2.0 Applicatin Development Foundation Questions

Microsoft Certification Exams Faqs…

100 % changes to come every year …

Q7: You use Reflection to obtain information about a method named

MyMethod. You need to ascertain whether MyMethod is accessible to a

derived class. What should you do?

A. Call the IsAssembly property of the MethodInfo class.

 

B. Call the IsVirtual property of the MethodInfo class.

 

C. Call the IsStatic property of the MethodInfo class.

 

D. Call the IsFamily property of the MethodInfo class.

 

 

Answer: D

 

Q8: You write the following code segment to call a function from the

Win32 Application Programming Interface (API) by using platform invoke.

 

string personName = “N?el”;

string msg = “Welcome” + personName + “to club”!”;

bool rc = User32API.MessageBox(0, msg, personName, 0);

 

You need to define a method prototype that can best marshal the string

data. Which code segment should you use?

 

A. [DllImport("user32", CharSet = CharSet.Ansi)]

public static extern bool MessageBox(int hWnd, string text, string caption, uint type);

}

 

B. [DllImport("user32", EntryPoint = "MessageBoxA", CharSet = CharSet.Ansi)]

public static extern bool MessageBox(int hWnd,

[MarshalAs(UnmanagedType.LPWStr)]string text,

[MarshalAs(UnmanagedType.LPWStr)]string caption,

uint type);

}

C. [DllImport("user32", CharSet = CharSet.Unicode)]

public static extern bool MessageBox(int hWnd, string text, string caption, uint type);

}

 

D. [DllImport("user32", EntryPoint = "MessageBoxA", CharSet = CharSet.Unicode)]

public static extern bool MessageBox(int hWnd,

[MarshalAs(UnmanagedType.LPWStr)]string text,

[MarshalAs(UnmanagedType.LPWStr)]string caption,

uint type);

}

 

Answer: C

 

Q9: You need to create a class definition that is interoperable along with

COM. You need to ensure that COM applications can create instances of the

class and can call the GetAddress method. Which code segment should you

use?

 

A. public class Customer {

string addressString;

public Customer(string address) { addressString = address; }

public string GetAddress() { return addressString; }}

 

B. public class Customer {

static string addressString;

public Customer() { }

public static string GetAddress() { return addressString; }}

 

C. public class Customer {

string addressString;

public Customer() { }

public string GetAddress() { return addressString; }}

 

D. public class Customer {

string addressString;

public Customer() { }

internal string GetAddress() { return addressString; }}

 

Answer: C

 

Q10: You write the following code to call a function from the Win32

Application Programming Interface (API) by using platform invoke.

 

int rc = MessageBox(hWnd, text, caption, type);

 

You need to define a methon prototype. Which code segment should you

use?

 

A. [DllImport("user32")]

public static extern int MessageBox(int hWnd, String text, String caption, uint type);

 

B. [DllImport("user32")]

public static extern int MessageBoxA(int hWnd, String text, String caption, uint type);

 

C. [DllImport("user32")]

public static extern int Win32API_User32_MessageBox(int hWnd, String text, String caption, uint type);

 

D. [DllImport(@"C:\WINDOWS\system32\user32.dll")]

public static extern int MessageBox(int hWnd, String text, String caption, uint type);

 

Answer: A

 


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

 

–Nikhil Kumar
For all questions just visit my blog and leave comments please...
www.dotnetask.blog.co.in