C# Interview Questions and Answers Part 13

121. What are Custom Exceptions?

Sometimes there are some errors that need to be handeled as per user
requirements.

Custom exceptions are used for them and are used defined exceptions.

122. How do you inherit a class into other class in C#?

Colon is used as inheritance operator in C#. Just place a colon and then the
class name.

public class DerivedClass : BaseClass

123. What are the ways to deploy an assembly?

An MSI installer, a CAB archive, and XCOPY command.

124. What is serialization?

When we want to transport an object through network then we have to convert
the object into a stream of bytes. The process of converting an object into a
stream of bytes is called Serialization.

For an object to be serializable, it should inherit ISerialize Interface.

De-serialization is the reverse process of creating an object from a stream
of bytes.

125. What is a delegate?

A delegate object encapsulates a reference to a method. In C++ they were
referred to as function pointers.

126. What is the difference between an interface and abstract class?

In the interface all methods must be abstract; in the abstract class some
methods can be concrete. In the interface no accessibility modifiers are
allowed, which is ok in abstract classes.

127. What is an abstract class?

A class that cannot be instantiated. A concept in C++ known as pure virtual
method. A class that must be inherited and have the methods over-ridden.
Essentially, it is a blueprint for a class without any implementation.

128.Does C# support multiple-inheritance?

No.

129. What is the use of using statement in C#?

The using block is used to obtain a resource and use it and then
automatically dispose of when the execution of block completed.

130. What is difference between constants and read-only?

Constant variables are declared and initialized at compile time. The value
canít be changed after wards.

Read-only variables will be initialized only from the Static constructor
of the class. Read only is used only when we want to assign the value at run
time.

Thank you for visiting www.cbtSAM.com. This site is dream of Samir Patel, when most people dream when in sleep, my dream doesn't let me sleep. cbtSAM Web site is provided as a service and learning tool to the public. While the information contained within the site is periodically updated,no guarantee is given that the iormation provided in this Web site is correct, complete, and up-to-date. We are not responsible for... Read More .