Dot Net Interview Questions – Set 08

What are ASP.NET security controls?

  • <asp: Login>: Provides a login capability that enables the users to enter their credentials.
  • <asp: LoginName>: Allows you to display the name of the logged-in user.
  • <asp: LoginStatus>:Displays if the user is authenticated or not.
  • <asp: LoginView>: provides various login views depending on the template that has been selected.
  • <asp: PasswordRecovery>: Emails the users the lost passwords.

What is a base class and derived class?

The base class is a class whose members and functions can be inherited, and the derived class is the class that inherits those members and may also have additional properties.

What are the important components of .Net?

The components of .Net are Common language run-time, .Net Class library, Application domain, Common Type System, .Net framework, Profiling, etc. However, the two important components are the Class library and the Common Language Runtime.

CLR provides building blocks for a wide variety of applications. The class library consists of a set of classes that are used to access common functionality. The functionality can be shared among different applications.

If you want to replace multiple if-else statements in code, which statement will you use?

In Visual basic, we can use Select-Case statement to replace multiple If-Else statement. In C#, we should use Switch-Case statement to replace multiple If-Else statement.

What is a garbage collector?

Garbage collector feature in .NET frees the unused code objects in the memory. The memory head is divided into 3 generations:

  • Generation 0: It stores short-lived objects.
  • Generation 1: This is for medium-lived objects.
  • Generation 2: It stores long-lived objects.
    Collection of garbage refers to the collection of objects stored in the generations.

What are the different types of JIT Compilers?

There are 3 types of JIT Compilers:

i. Pre-JIT compiler: It compiles all the source code into the machine code in a single compilation cycle, i.e. at the application deployment time.

ii. Normal JIT Compiler: The source code methods required at run-time are compiled into machine code and stored in the cache to be called later.

iii. Econo JIT Compiler: The methods required only at run-time are compiled using this compiler and they are not stored for future use.

Do we have multiple inheritance in .NET? Why?

No, .NET supports only single inheritance due to the diamond problem. Also, it would add complexity when used in different languages. However, multiple interfaces can solve the purpose.

What is managed and unmanaged codes?

Managed code runs inside CLR and installing the .NET Framework is necessary to execute it. Unmanaged code does not depend on CLR for execution and is developed using languages outside the .NET framework.

Can you set the session out time manually?

Yes. Session out time can be set manually in web.config.

What is a delegate in .NET?

A delegate in .NET is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked. In addition, we could use delegate to create custom event within a class. For example,

public delegate void FooDelegate();

class FooClass
{
// custom event
public event FooDelegate FooEvent;
}

FooClass FooObj = new FooClass()
FooObj.FooEvent += new FooDelegate();