Exam 70-536 : .NET Framework Application Development Foundation Part – 7

Question: You create a class library that is used by applications in three departments of your company. The library contains a Department class with the following definition.
public class Department {
public string name;
public string manager;
}

Each application uses a custom configuration section to store departmentspecific values in the application configuration file as shown in the following code.
<Department>
<name>Hardware</name>
<manager>Company</manager>
</Department>

You need to write a code segment that creates a Department object instance by using the field values retrieved from the application configuration file. Which code segment should you use?

  1. public class deptElement : ConfigurationElement {
    protected override void DeserializeElement(
    XmlReader reader, bool serializeCollectionKey) {
    Department dept = new Department();
    dept.name = ConfigurationManager.AppSettings["name"];
    dept.manager = ConfigurationManager.AppSettings["manager"];
    return dept;
    } }
  2. public class deptElement: ConfigurationElement {
    protected override void DeserializeElement(
    XmlReader reader, bool serializeCollectionKey) {
    Department dept = new Department();
    dept.name = reader.GetAttribute("name");
    dept.manager = reader.GetAttribute("manager"); } }
  3. public class deptHandler : IConfigurationSectionHandler {
    public object Create(object parent, object configContext,
    System.Xml.XmlNode section) {
    Department dept = new Department();
    dept.name = section.SelectSingleNode("name").InnerText;
    dept.manager = section.SelectSingleNode("manager").InnerText;
    return dept;
    } }
  4. public class deptHandler : IConfigurationSectionHandler {
    public object Create(object parent, object configContext,
    System.Xml.XmlNode section) {
    Department dept = new Deprtment();
    dept.name = section.Attributes["name"].Value;
    dept.manager = section.Attributes["manager"].Value;
    return dept;
    } }

Correct Answer: 3


Question: Your company uses an application named Application1 that was compiled by using the .NET Framework version 1.0. The application currently runs on a shared computer on which the .NET Framework versions 1.0 and 1.1 are installed. You need to move the application to a new computer on which the .NET Framework versions 1.1 and 2.0 are installed. The application is compatible with the .NET Framework 1.1, but it is incompatible with the .NET Framework 2.0. You need to ensure that the application will use the .NET Framework version 1.1 on the new computer. What should you do?

  1. Add the following XML element to the application configuration file.
    <configuration>
    <startup> <supportedRuntime version="1.1.4322" />
    </startup> </configuration>
  2. Add the following XML element to the application configuration file.
    <configuration>
    <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="Application1" publicKeyToken="32ab4ba45e0a69a1" culture="neutral" />
    <bindingRedirect oldVersion="1.0.3075.0" newVersion="1.1.4322.0"/>
    </dependentAssembly>
    </assemblyBinding>
    </runtime>
    </configuration>
  3. Add the following XML element to the machine configuration file.
    <configuration>
    <startup>
    <requiredRuntime version="1.1.4322" />
    </startup>
    </configuration>
  4. Add the following XML element to the machine configuration file.
    <configuration>
    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="Application1" publicKeyToken="32ab4ba45e0a69a1" culture="neutral" />
    <bindingRedirect oldVersion="1.0.3075.0" newVersion="1.1.4322.0"/>
    </dependentAssembly>
    </assemblyBinding>
    </runtime>
    </configuration>

Correct Answer: 1


Question: You are creating an application that retrieves values from a custom section of the application configuration file. The custom section uses XML as shown in the following block.
<ProjectSection name="ProjectCompany">
<role name="administrator" />
<role name="manager" />
<role name="support" />
</ProjectSection>

You need to write a code segment to define a class named Role. You need to ensure that the Role class is initialized with values that are retrieved from the custom section of the configuration file. Which code segment should you use?

  1. public class Role : ConfigurationElement {
    internal string _ElementName = "name";
    [ConfigurationProperty("role")]
    public string Name {
    get {
    return ((string)base["role"]);
    }
    }
    }
  2. public class Role : ConfigurationElement {
    internal string _ElementName = "role";
    [ConfigurationProperty("name", RequiredValue = true)]
    public string Name {
    get {
    return ((string)base["name"]);
    } } }
  3. public class Role : ConfigurationElement {
    internal string _ElementName = "role";
    private string _name;
    [ConfigurationProperty("name")]
    public string Name {
    get {
    return _name;
    } } }
  4. public class Role : ConfigurationElement {
    internal string _ElementName = "name";
    private string _name;
    [ConfigurationProperty("role", RequiredValue = true)]
    public string Name {
    get {
    return _name;
    } } }

Correct Answer: 2


Question: You are creating an application that lists processes on remote computers. The application requires a method that performs the following tasks: Accept the remote computer name as a string parameter named strComputer.Return an ArrayList object that contains the names of all processes that are running on that computer. You need to write a code segment that retrieves the name of each process that is running on the remote computer and adds the name to the ArrayList object. Which code segment should you use?

  1. ArrayList al = new ArrayList();
    Process[] procs = Process.GetProcessesByName(strComputer);
    foreach (Process proc in procs) {
    al.Add(proc);}
  2. ArrayList al = new ArrayList();
    Process[] procs = Process.GetProcesses(strComputer);
    foreach(Process proc in procs) {
    al.Add(proc);}
  3. ArrayList al = new ArrayList();
    Process[] procs = Process.GetProcessesByName(strComputer);
    foreach (Process proc in procs) {
    al.Add(proc.ProcessName);}
  4. ArrayList al = new ArrayList();
    Process[] procs = Process.GetProcesses(strComputer);
    foreach(Process proc in procs) {
    al.Add(proc.ProcessName);}

Correct Answer: 4


Question: You need to write a code segment that transfers the first 80 bytes from a stream variable named stream1 into a new byte array named byteArray. You also need to ensure that the code segment assigns the number of bytes that are transferred to an integer variable named bytesTransferred. Which code segment should you use?

  1. bytesTransferred = stream1.Read(byteArray, 0, 80);
  2. for (int i = 0; i < 80; i++) {
    stream1.WriteByte(byteArray[i]);
    bytesTransferred = i;
    if (!stream1.CanWrite) {
    break;
    }}
  3. while (bytesTransferred < 80) {
    stream1.Seek(1, SeekOrigin.Current);
    byteArray[bytesTransferred++] = Convert.ToByte(stream1.ReadByte());
    }
  4. stream1.Write(byteArray, 0, 80);
    bytesTransferred = byteArray.Length;

Correct Answer: 1

Tagged . Bookmark the permalink.

Leave a Reply