C# Programming Interview Questions and Answers Pdf - 1

Question: 1

Give the advantages of inheritance?

Reuses the existing code and extends the functionality.

Add new members to the derived class.

Can replace the implementation of existing methods by overriding the method.

Use of override and virtual methods helps to exhibit polymorphic behavior.

Question: 2

What are the features of namespace?

Namespace is not a type.

Namespace are implicitly public.

The classes, struts, interfaces, enums and delegates are allowed

Global namespace is available.

Namespaces may be nested.

The namespace body contains using directives and type declarations.

Question: 3

Define sealed class and sealed methods?

A class that cannot be sub classed is called a sealed class.

It is achieved by using the keyword sealed. When an instance method declaration includes the sealed modifier, the method is said to be a sealed method. It means a derived class cannot override this method.

Question: 4

What is the use of new keyword in C#?

The C# allows the concept of method hiding using the keyword new.

While using the new keyword in the derived class it tells  the compiler to hide the base class method.

The following program illustrates the use of new keyword and explains the method hiding.

Question: 5

Explain ACID rule of thumb for transactions?

A transaction must be:

Atomic- it is one unit of work and does not dependent on previous and following transactions.

Consistent-data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t.

Isolated – no transaction sees the intermediate results of the current transaction.

Durable- the values persist if the data had been committed even if the system crashes right after.

Related Questions