Recently I gave lot of interviews for Dot Net developer positions in various leading companies. I came across numerous good interview questions which sometimes confuse us. I would like to share with you all.
- What is Dependency Injection? Why is it required?
- Whether System.String class is a value type or reference type? Can we create an object of System.String class using new keyword?
- What is the difference between System.String class and string keyword. Similarly what is the difference between int and System.Int32 etc.
- Why System.String class is immutable? What is the purpose behind this design by CLR?
- Are there any other types apart from System.String that are immutable? If yes which ones. If no then why this special treatment for System.String?
- How is StringBuilder class implemented internally? What is the best approach to create a custom StringBuilder class?
- Why cant methods be overloaded based on return type in C#. Is it allowed by CLR? Is this feature available in any other .NET language?
- DateTime is reference type or value type?
- What are the advantages or disadvantges of using a value type over reference type?
- What are the advantages or disadvantges of using a reference type over value type?
- What is the main benefit of using Generic types?
- Explain how boxing process is done by CLR from memory standpoint.
- Explain how unboxing process is done by CLR from memory standpoint.
- How CLR assigns allocates memory to references types? What are the operations that happen in memory when a reference of a type is created. What operations get executed when a new instance is created using new keyword and assigned to the reference of a class?
- How/Where is memory allocated for Static variables?
- How does CLR calls virtual methods? How does it actually trace the address in memory of the overridden definition of a virtual method?
- If protected accessor means accessible in family and internal means assembly(accessible in same assembly) then protected internal means? “family or assembly” or “family and assembly?
- Why cant someone create an object of static class in dotnet?
- What is a Managed Module?
- What is Strongly Named assembly?How do we attach strong name to an assesmbly why should that be done?
- Is a strongly Named Assembly tamper proof? Consider someone opens the assembly in a notepad and changes the binary content of the assembly and saves the file. Will this corrupted assembly get loaded? If Not why?
- Can a assembly be unloaded? How can this be achieved?
- What is the main reason of introducing the concept of AppDomains?
- If there are 2 websites running under IIS and one of them crashes, will it imapct the other one?
- Suppose you have developed an assmbly and distributed to hundreds of clients. After one year you relese a new version of the assembly, then how would this new version be deployed in production at all applications?
- How Garbage Collector works internally? Briefly describe the generations approach used by GC.
- Can GC be called on demand? Will GC get called when GC.Collect() method is executed?
- How can you restrict types that are allowed to be used in a generic type? For example, can a List
be restricted so that T can only be Employee type?
Answer All core value types in framework like Byte, Int32, UInt32, Int64, UInt64, Single, Double, Decimal, BigInteger, Complex, all enums, and so on are immutable.
Answer:DateTime type in C#
Answer: Its “family or assembly”. Other one is not supported by C#. Refer more here: Access modifiers in C#.NET
Answer: This is because CLR does not emit a default constructor in IL for the static class. For more about static keyword please browse to What is Static keyword in C#.
Please hold your breath I will add the answers to these questions in coming days. Till then feedback and answers are welcome in comments but do provide the question number.
Also read SQL server interview questions.