.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!



Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share

 Subscribe to Code Snippets

Important questions about asp.net

Posted By :Nikhil Kumar      Posted Date :20/02/2010   Points :10   Category: ASP.NET Controls    URL: http://fast-get.com

Important Questions about asp.net
 


Q2: You create an application to send a message by e-mail. An SMTP
server is available on the local subnet. The SMTP server is named
smtp.Company.com. To test the application, you use a source address,
me@Company.com, and a target address, you@Company.com.
You need to transmit the e-mail message. Which code segment should you
use?

A. MailAddress addrFrom = new MailAddress("me@Company.com", "Me");
MailAddress addrTo = new MailAddress("you@Company.com", "You");
MailMessage message = new MailMessage(addrFrom, addrTo);
message.Subject = "Greetings!";
message.Body = "Test";

message.Dispose();

B. string strSmtpClient = "mstp.Company.com";
string strFrom = "me@Company.com";
string strTo = "you@Company.com";
string strSubject = "Greetings!";
string strBody = "Test";
MailMessage msg = new MailMessage(strFrom, strTo, strSubject, strSmtpClient);

C. MailAddress addrFrom = new MailAddress("me@Company.com");
MailAddress addrTo = new MailAddress("you@Company.com");
MailMessage message = new MailMessage(addrFrom, addrTo);
message.Subject = "Greetings!";
message.Body = "Test";
SmtpClient client = new SmtpClient("smtp.Company.com");

client.Send(message);

D. MailAddress addrFrom = new MailAddress("me@Company.com", "Me");
MailAddress addrTo = new MailAddress("you@Company.com", "You");
MailMessage message = new MailMessage(addrFrom, addrTo);
message.Subject = "Greetings!";
message.Body = "Test";
SocketInformation info = new SocketInformation();
Socket client = new Socket(info);

System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
byte[] msgBytes = enc.GetBytes(message.ToString());
client.Send(msgBytes);


Answer: C

Q3: You need to write a code segment that will create a common
language runtime (CLR) unit of isolation within an application. Which code
segment should you use?

A. AppDomainSetup mySetup = AppDomain.CurrentDomain.SetupInformation;
mySetup.ShadowCopyFiles = "true";


B. System.Diagnostics.Process myProcess;
myProcess = new System.Diagnostics.Process();


C. AppDomain domain;
domain = AppDomain.CreateDomain("CompanyDomain"):


D. System.ComponentModel.Component myComponent;
myComponent = new System.ComponentModel.Component();



Answer: C


Q4: You are developing an application that dynamically loads assemblies
from an application directory.
You need to write a code segment that loads an assembly named
Company1.dll into the current application domain. Which code segment
should you use?

A. AppDomain domain = AppDomain.CurrentDomain;
string myPath = Path.Combine(domain.BaseDirectory, "Company1.dll");
Assembly asm = Assembly.LoadFrom(myPath);


B. AppDomain domain = AppDomain.CurrentDomain;
string myPath = Path.Combine(domain.BaseDirectory, "Company1.dll");
Assembly asm = Assembly.Load(myPath);


C. AppDomain domain = AppDomain.CurrentDomain;
string myPath = Path.Combine(domain.DynamicDirectory, "Company1.dll");
Assembly asm = AppDomain.CurrentDomain.Load(myPath);


D. AppDomain domain = AppDomain.CurrentDomain;
Assembly asm = domain.GetData("Company1.dll");


Answer: A

Q5: You are creating a class that uses unmanaged resources. This class
maintains references to managed resources on other objects. You need to
ensure that users of this class can explicitly release resources when the
class instance ceases to be needed. Which three actions should you
perform? (Each correct answer presents part of the solution. Choose
three.)

A. Define the class such that it inherits from the WeakReference class.

B. Define the class such that it implements the IDisposable interface.

C. Create a class destructor that calls methods on other objects to release the managed resources.

D. Create a class destructor that releases the unmanaged resources.

E. Create a Dispose method that calls System.GC.Collect to force garbage collection.

F. Create a Dispose method that releases unmanaged resources and calls methods on other objects to release the managed resources.

Answer: B, D, F

Q6: You write a class named Employee that includes the following code
segment.

public class Employee
{
string employeeId, employeeName, jobTitleName;

public string GetName()
{

 return employeeName;
}

public string GetTitle()
{

 return jobTitleName;
}

}


You need to expose this class to COM in a type library. The COM interface must
also facilitate forward-compatibility across new versions of the Employee class.
You need to choose a method for generating the COM interface. What should you
do?


A. Add the following attribute to the class definition.
[ClassInterface(ClassInterfaceType.None)]
public class Employee {


B. Add the following attribute to the class definition.
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Employee {


C. Add the following attribute to the class definition.
[ComVisible(true)]
public class Employee {


D. Define an interface for the class and add the following attribute to the class
definition.
[ClassInterface(ClassInterfaceType.None)]

public class Employee : IEmployee {


Answer: D

-Nikhil Kumar

For all questions just visit my blog and try to leave your precios comment pleaseeee...
www.dotnetask.blog.co.in 



Featured Articles


Best Practices No 5: - Detecting .NET application memory leaks
Memory leaks in .NET application have always being programmer's nightmare. Memory leaks are biggest problems when it comes to production servers. Productions servers normally need to run with least down time. Memory leaks grow slowly and after sometime they bring down the server by consuming huge chunks of memory. Maximum time people reboot the system, make it work temporarily and send a sorry note to the customer for the downtime. ... Read More
.NET Best Practice No: 1:- Detecting High Memory consuming functions in .NET code
One of the important factors for performance degradation in .NET code is memory consumption. Many developers just concentrate on execution time to determine performance bottle necks in a .NET application. Only measuring execution time does not clearly give idea of where the performance issue resides. Ok, said and done one of the biggest task is to understand which function, assembly or class has consumed how much memory. In this tutorial we will see how we can find which functions consume how much memory. This article discusses the best practices involved using CLR profiler for studying memory allocation.... Read More
How to improve your LINQ query performance by 5 X times ?
LINQ has been criticized by many early adopters for its performance issues. Well if you are just going to drag and drop using DBML code generator I am sure you will land up in to mess. Try doing this make a simple LINQ to SQL project using DBML and see your SQL profiler, I am sure you will never like to touch DBML code generator again. ... Read More
Responses

No response found. Be the first to respond this post

Post Comment
You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend