C# Interview Questions and Answers (958) - Page 46

The CLR will not shutdown an application until all --------- threads has ended?

NOTE: This is objective type question, Please click question title for correct answer.
All processes have at least one thread of executions, which is called?

NOTE: This is objective type question, Please click question title for correct answer.
What is Code Coverage?

It is a verification metric of determining how many lines of code in a given binary are measured when we run test cases against it. By analyzing the result of the code coverage of the Test Methods, we can figure out how much code has been tested for the specified test method. It also provides valuable information to the developer(s) as if the code block is partially, completely or not at all tested which on the other hand helps them to include more test cases to solidify the various boundaries under measure.By knowing how many lines of code of a certain code block are touched, we can judge how well the code/function is tested.It also provides information about which lines of code have been executed and how long it took to execute them.
What not is Code Coverage for?

NOTE: This is objective type question, Please click question title for correct answer.
List out the advantages of Code Coverage

NOTE: This is objective type question, Please click question title for correct answer.
What are the various default coloring of Code Coverage?

- Light blue - Covered
- Light orange - Partially Covered
- Light red - Not covered
How to identity what portions of the code block has been covered fully, partially or not at all using Code Coverage?

We can use the Show Code Coverage Coloring option of Code Coverage Results window for identifying what portions of the code block has been covered fully, partially or not at all.
What is Optical character recognition (OCR)?

Optical character recognition (OCR) is a process for extracting textual data from an image. Apart from that, it finds it's applicability in the field of pattern recognition, artificial intelligence ,computer vision etc.
List out the advantages of Assert method

NOTE: This is objective type question, Please click question title for correct answer.
What is Partial Class and its uses?

With partial, we can physically separate a class into multiple files.

It is true that Partial Class is used in auto code generation, one use can be maintaining a large class file which might have thousand lines of code. The class might end up with 10 thousand lines and we don't want to create a new class with different name.

public partial class Product


{

// 20 business logic embedded in methods and properties..

}



public partial class Product

{

// another 30 business logic embedded in methods and properties..

}

//finally compile with product.class file.



Another possible use could be that more than one developer can work on the same class as they are stored at different places.
Explain with example Optional Parameter?

C#4.0 has bring the new Optional Parameter in its collection to give developers the flexibility passing parameters at their discretion.

Consider the below program written in C#4.0 with Optional Parameter

class Program

{
static void Main(string[] args)
{
MethodWithOptionalParameters();//Print default values

MethodWithOptionalParameters("Some Name");//Print only default age

MethodWithOptionalParameters(Age: 25);//Ask to print only Name

//Prints the values passed
MethodWithOptionalParameters("Some Other Name", 20);

Console.ReadKey(true);
}

private static void MethodWithOptionalParameters
(string Name = "Default Name", int Age = 18)
{
Console.WriteLine(string.Format("{0}, your age is {1}",Name,Age));
}
}



As can be observed that first of all in the new code we are no longer checking the Empty/Null values of the method parameters. Instead , we have assigned the default values to the method parameters.

Consider the First Calling Method. We are not at all passing any parameter. The compiler will happily compile though (which was not the case in the earlier example as it would have reported the error No overload for method 'WithoutOptionalParameter' takes '0' arguments.

Consider the third Method call

MethodWithOptionalParameters(Age: 25);//Ask to print only Name

Here we are specifying the Age only which is a Named Parameter in this case and the compiler will understand that and will do the favor.

In short, optional parameter help developers to avoid writing overloaded methods and rather helps in code re usability.
What is the base class in .net

NOTE: This is objective type question, Please click question title for correct answer.
What is difference between struct and class?

NOTE: This is objective type question, Please click question title for correct answer.
What is the full form of GAC?

NOTE: This is objective type question, Please click question title for correct answer.
C# language is managed or unmanaged code?

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories