Wednesday, March 5, 2008

.Net Written Test Questoins for 1+ Experince

1. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

Answer :

The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.

2. How do I create a multilanguage, single-file assembly?

Answer :

This is currently not supported by Visual Studio .NET.

3. Where is the output of TextWriterTraceListener redirected?

Answer :

To the Console or a text file depending on the parameter passed to the constructor.

4. Explain ACID rule of thumb for transactions.

Answer :

Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasnot), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).

5. Which one is trusted and which one is untrusted?

Answer :

Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.

6. Are private class-level variables inherited?

Answer :

Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But from a versioning perspective, what are the drawbacks of extending an interface as opposed to extending a class With regard to versioning, interfaces are less flexible than classes. With a class, you can ship version 1 and then, in version 2, decide to add another method. As long as the method is not abstract (i.e., as long as you provide a default implementation of the method), any existing derived classes continue to function with no changes. Because interfaces do not support implementation inheritance, this same pattern does not hold for interfaces. Adding a method to an interface is like adding an abstract method to a base class–any class that implements the interface will break, because the class doesn’t implement the new interface method.

7. Can you change the value of a variable while debugging a C# application?

Answer :

Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.

8. Can you allow class to be inherited, but prevent the method from being over-ridden?

Answer :

Yes, just leave the class public and make the method sealed

9. If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?

Answer :

Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

10. Is XML case-sensitive?

Answer :

Yes, so and are different elements.

Example:

With XML, the tag is different from the tag .

Opening and closing tags must therefore be written with the same case:

This is incorrect

This is correct

11. Is there a way to force garbage collection?

Answer :

Yes. Set all references to null and then call System.GC.Collect(). If you need to have some objects destructed, and System.GC.Collect() doesn’t seem to be doing it for you, you can force finalizers to be run by setting all the references to the object to null and then calling System.GC.RunFinalizers().

12. Does C# support try-catch-finally blocks?

Answer :

Yes. Try-catch-finally blocks are supported by the C# compiler.Here’s an example of a try-catch-finally block: using System;
public class TryTest
{
static void Main()
{
try
{
Console.WriteLine(”In Try block”);
throw new ArgumentException();
}
catch(ArgumentException n1)
{
Console.WriteLine(”Catch Block”);
}
finally
{
Console.WriteLine(”Finally Block”);
}
}
}
Output: In Try Block
Catch Block
Finally Block

13. How do I simulate optional parameters to COM calls?

Answer :

You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.

14. How do I make a DLL in C#?

Answer :

You need to use the /target:library compiler option

15. How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#?

Answer:

You want the lock statement, which is the same as Monitor Enter/Exit:
lock(obj)
{
// code
}
translates to: try
{
CriticalSection.Enter(obj);
// code
}
finally
{
CriticalSection.Exit(obj);
}

No comments :

Post a Comment