web api Asp.Net C# interview Questions for freshers
Q. What are the three types of Generic delegates in C# ?
A. HERE are the three types of generic delegates in C#
Func
Action
Predicate
Q.Difference between an interface and abstract class ?
A. Interfaces have all the methods having only declaration but no definition. In an abstract class, we can have some concrete methods. In an interface class, all the methods are public. An abstract class may have private methods.
Q. What are generics in C#.NET?
A. Generics are used to make reusable code classes to decrease the code redundancy, increase type safety and performance. Using generics, we can create collection classes. To create generic collection, System.Collections.Generic namespace should be used instead of classes such as ArrayList in the System.Collections namespace. Generics promotes the usage of parameterized types.
Q. What is an object pool in .NET?
A. An object pool is a container having objects ready to be used. It tracks the object that is currently in use, total number of objects in the pool. This reduces the overhead of creating and re-creating objects.
Q. What are Custom Exceptions ?
A. Sometimes there are some errors that need to be handled as per user requirements. Custom exceptions are used for them and are user defined exceptions.
Q. What are the differences between events and delegates in C#?
A. Main difference between event and delegate is event will provide one more of encapsulation over delegates. So when you are using events destination will listen to it but delegates are naked, which works in subscriber/destination model.