Google
 

oops-77

1))What happens when you encounter a continue statement inside the for loop?
ans))The code for the rest of the loop is ignored, the control is transferred back to the beginning of the loop.

2))Is goto statement supported in C#? How about Java?
ans))Gotos are supported in C# to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality.

3))How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#?
ans))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);
}

4))How do I make a DLL in C#?
ans>>You need to use the /target:library compiler option

5))How do I simulate optional parameters to COM calls?
ans>>You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.

6))Does C# support try-catch-finally blocks?
ans>>
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(Argument7))Is there a way to force garbage collection?
Exception n1)
{
Console.WriteLine(”Catch Block”);
}
finally
{
Console.WriteLine(”Finally Block”);
}
}
}
Output: In Try Block
Catch Block
Finally Block
7))Is there a way to force garbage collection?
ans>>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().

8))Is XML case-sensitive?
ans>>Yes, so and are different elements.

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?
ans>>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))Can you allow class to be inherited, but prevent the method from being over-ridden?
Categories: C# Interview Questions ?
ans>>Yes, just leave the class public and make the method sealed

11))Can you change the value of a variable while debugging a C# application?
ans>>Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.

12))A DataSet transmits data through which one of the following?

ans>>XML file
Explanation : Transmitting an ADO.NET dataset between applications is much easier than transmitting an ADO disconnected recordset. To transmit an ADO disconnected recordset from one component to another, you use COM marshalling. To transmit data in ADO.NET, you use a dataset, which can transmit an XML stream.

13))Can abstract class be inherited?

ans>> Yes
14))What is the maximum number of columns allowed for an Index?

ans>>3. 16

15))What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The Clone() method returns a new array

No comments: