.NET Interview Questions

.NET Interview Questions

1 What is .NET Framework?

Ans: The .NET Framework has two main components: the common language runtime and the .NET Framework class library. You can think of the runtime as an agent that manages code at execution time,providing core services such as memory management, thread management, andremoting, while also enforcing strict type safety and other forms of code accuracy that ensure security and robustness.The? class library, is a comprehensive, object-oriented collection of reusable types that you can use to develop applications ranging from traditional command-line orgraphical user interface (GUI) applications to applications based on the latestinnovations provided by ASP.NET, such as Web Forms and XML Web services.

2 What are Name spaces?

Ans: The namespace keyword is used to declare a scope. This name space scope lets you organize code and gives you a way to create globally-unique types. Even if you do not explicitly declare one, a default namespace is created. This unnamed name space,sometimes called the global namespace, is present in every file. Any identifier in theglobal namespace is available for use in a named namespace. Namespaces implicitly have public access and this is not modifiable.

3 What is CLR?

Ans: The CLS is simply a specification that defines the rules to support language integrationin such a way that programs written in any language, yet can interoperate with one another, taking full advantage of inheritance, polymorphism, exceptions, and other features. These rules and the specification are documented in the ECMA proposed standard document, “Partition I Architecture”.

4 Is .NET a runtime service or a development platform?

Ans: It’s both and actually a lot more. Microsoft .NET includes a new way of delivering software and services to businesses and consumers. A part of Microsoft.NET is the .NET Frameworks. The .NET frameworks SDK consists of two parts: the .NET common language runtime and the .NET class library. In addition, the SDK also includes command-line compilers for C#, C++, JScript, and VB. You use these compilers to build applications and components. These components require the runtime to execute so this is a development platform.

5 What is MSIL, IL?

Ans: When compiling to managed code, the compiler translates your source code intoMicrosoft intermediate language (MSIL),which is a CPU-independent set of instructions that can be efficiently converted to native code. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations. Microsoft intermediate language (MSIL) is a language used as the output of a number of compilers and as the input to a just-in-time (JIT) compiler. The common language runtime includes a JIT compiler for converting MSIL to native code.

6 Can I write IL programs directly?

Ans: Assembly MyAssembly {}
.class MyApp {
.method static void Main() {
.entrypoint
ldstr “Hello, IL!”
call void System.Console::WriteLine(class System.Object)
ret
}
}.

7 What is CTS?

Ans: The common type system defines how types are declared, used, and managed in theruntime, and is also an important part of the runtime’s support for cross-language integration.The common type system supports two general categories of types,eachofwhich isfurther divided into subcategories:
? Value types
Value types directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure. Value types can be built-in (implemented by the runtime), user-defined, or enumerations.
? Reference types
Reference types store a reference to the value’s memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types. The type of a reference type can be determined from values of self-describing types. Self-describing types are further split into arrays and class types. The class types are user-defined classes, boxed value types, and delegates.

8 What is JIT (just in time)? how it works?

Ans: Before Microsoft intermediate language (MSIL) can be executed, it must beconverted by a .NET Framework just-in-time (JIT) compiler to native code, which is CPU-specific code that runs on the same computer architecture as the JIT compiler.

Rather than using time and memory to convert all the MSIL in a portable executable? (PE) file to native code, it converts the MSIL as it is needed during execution and? stores the resulting native code so that it is accessible for subsequent calls.The? runtime supplies another mode of compilation called install-time code generation.The install-time code generation mode converts MSIL to native code just as the regular? JIT compiler does, but it converts larger units of code at a time, storing the resulting? native code for use when the assembly is subsequently loaded and executed.

As part of compiling MSIL to native code, code must pass a verification process unless an administrator has established a security policy that allows code to bypass? verification. Verification examines MSIL and metadata to find out whether the code can? be determined to be type safe, which means that it is known to access only the memory locations it is authorized to access.

9? What is strong name?

Ans: A name that consists of an assembly’s identity?its simple text name, version number,and culture information (if provided)?strengthened by a public key and a digital signature generated over the assembly.

10 What is portable executable (PE)?

Ans: The file format defining the structure that all executable files (EXE) and? Dynamic LinkLibraries (DLL) must use to allow them to be loaded and executed by Windows. PE isderived from the Microsoft Common Object File Format (COFF). The EXE? and DLL filescreated using the .NET Framework obey the PE/COFF formats and also add additionalheader and data sections to the files that are only used by the CLR. The specificationfor the PE/COFF file formats is available.

11How is .NET able to support multiple languages?

Ans:language should comply?? with the Common Language Runtime standard to become a.NET language. In .NET, code is compiled to Microsoft Intermediate Language? (MSIL for short). This is called as Managed Code. This Managed code is run in .NET? environment. So after compilation to this IL the language is not a barrier. A code can? call or use a function written in another language.

12 Which name space is the base class for .net Class library?

Ans: system.object.

13 What is Event -Delegate? clear syntax for writing a event delegate?
Ans: The event keyword lets you specify a delegate that will be called upon the occurrence of some “event” in your code. The delegate can have one or more associated methods that will be called when your code indicates that the event has? occurred. An event in one program can be made available to other programs that? target the .NET Framework.

14 What are object pooling and connection pooling and difference? Where do 0we set the Min and Max Pool size for connection pooling?

Ans: Object pooling is a COM+ service that enables you to reduce the overhead of creating each object from scratch. When an object is activated, it is pulled from the? pool. When the object is deactivated, it is placed back into the pool to await the next? request. You can configure object pooling by applying the Object Pooling attribute to a? class that derives from the System.EnterpriseServices.ServicedComponent class.

Object pooling lets you control the number of connections you use, as opposed to connection pooling, where you control the maximum number reached. Following are important differences between object pooling and connection pooling:? Creation. When using connection pooling, creation is on the same thread, so if there? is nothing in the pool, a connection is created on your be half. With object pooling, the?? pool might decide to create a new object. However, if youhave already reached your? maximum, it instead gives you the next available object. This is crucial behavior when it? takes a long time to create an object.

15 How many languages .NET is supporting now?

Ans: When .NET was introduced it came with several languages. VB.NET, C#,? COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported.

16 How ASP .NET different from ASP?

Ans: Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs? can be executed on the server.

17 What is smart navigation?

Ans: The cursor position is maintained when the page gets refreshed due to the? server side validation and the page gets refreshed.

18 What is view state?

Ans: The web is stateless. But in ASP.NET, the state of a page is maintained in? the in the page itself automatically. How? The values are encrypted and saved in? hidden controls. this is done automatically by the ASP.NET. This can be switched off /? on for a single control.

19 How do you validate the controls in an ASP .NET page?

Ans: Using special validation controls that are meant for this. We have Range Validator, Email Validator.

20 Can the validation be done in the server side? Or this can be done only in the Client side?

Ans: Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.