Very Basic .Net Interview Questions Part 1

Q-1: What are primitive type in .net?

Ans: People often answer it like this “all basic data type are primitive type or numeric and string data types are primitive types” but this is not very correct answer.

Correct Answer is like this

“Certain data types are so commonly used that many compilers allow code to manipulate them using simplified syntax”. For example, you could allocate an integer by using the following
System.Int32 a = new System.Int32();

Fortunately, many compilers (including C#) allow us to use syntax similar to the following instead:
int a = 0;

For this after compilation compiler generates System.Int32 a = new System.Int32(); IL equivalent code.

So in short you can say that all types in .net which can be allocated without using new keyword are primitive types.

Q-2: What is Common Type System (CTS)?

Ans: Many people have impression that CTS is a software component of .net framework or in .net programming languages supported types are part of CTS.

Correct Answer is like this

“Types are the mechanism by which code written in one programming language can talk to code written in a different programming language. Because types are at the root of the CLR, Microsoft created a formal specification—the Common Type System (CTS)—that describes how types are defined and how they behave.”

So in short you can say CTS is a specification(Documentation) that describes how types are defined and how they will behave.

Q-3: What is Common Language Specification (CLS)?

Ans: Generally people reply that all dotnet programming language is CLS complaint which is true. But you should describe this in more details like this.

“CLR now integrates all languages and allows objects created in one language
to be treated as equal citizens by code written in a completely different language. This integration is possible because of the CLR’s standard set of types, metadata (self-describing type information), and common execution environment. But all programming languages are very different from one another. For example, some languages don’t treat symbols with case-sensitivity, and some don’t offer unsigned integers, operator overloading,or methods to support a variable number of arguments.

If you intend to create types that are easily accessible from other programming languages,you need to use only features of your programming language that are guaranteed to beavailable in all other languages. To help you with this, Microsoft has defined a Common Language Specification (CLS) that details for compiler vendors the minimum set of features their compilers must support if these compilers are to generate types compatible with other components written by other CLS-compliant languages on top of the CLR.”

So in shot you can say CLS is minimum set of programming language features which must be supported by all .Net programming language compilers.

Q-4: How many type of assembly dotnet supports?

Ans: Generally people reply this question as “Dot net support two types of assembly 1) Local 2) Global assemble”. This is incorrect.

Correct Answer is like this

“The CLR supports two kinds of assemblies: weakly named assemblies and strongly named assemblies.” While local and Global are deployment methods of assembly and for global deployment of assembly, it should be strong named.

Q-5: From which class all types are derived?

Ans: System.Object, Accoring to this

public class Person


public class Person : System.Object

Both are identical.

Q-6: What is namespaces ?

Ans: Namespaces allow for the logical grouping of related types, and developers typically use them to make it easier to locate a particular type. For example, the System.Text namespace defines a bunch of types for performing string manipulations, and the System.IO namespace defines a bunch of types for performing I/O operations. In a situation is two types have same name then by using name space as prefix you can make you types unique.

Or you can say namespaces are just like folders and files on a file system.

Q-7: What kinds of types supported by CLR?

Ans: CLR supports two kind of types.Reference type and value type. Reference type are the type which are initialize by new and allocated memory to managed heap and returns address to variable. While value types are type which are created directly on stack. In c# all classes are reference type and all classes are reference type and all structs are value type.

blog comments powered by Disqus