.NET Interview Questions - DOC

Document Sample
.NET Interview Questions - DOC Powered By Docstoc
					1. What is an assembly? Ans. Assemblies are the smallest units of versioning and deployment in .Net application.Assemblies are also building blocks for programs such as Web Services,Windows Services,Service Components and .Net Remoting Applications. Here are some general Concepts of an Assembly.  An Assembly is a logical unit of code  Assembly physically exist as DLLs or EXEs  One assembly can contain one or more files  The constituent files can include any file types like image files, text files etc. along with DLLs or EXEs  When you compile your source code by default the exe/dll generated is actually an assembly  Unless your code is bundled as assembly it can not be used in any other application  When you talk about version of a component you are actually talking about version of the assembly to which the component belongs.  Every assembly file contains information about itself. This information is called as Assembly Manifest. For more information about an Assembly please visit http://msdn2.microsoft.com/en-us/library/hk5f40ct.aspx 2.What is Satellite assembly? Ans. A .NET Framework assembly containing resources specific to a given language. Using satellite assemblies, you can place the resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user elects to view the application in that language. 3.What is MSIL? Ans. Microsoft Intermediate Language (MSIL) is a platform independent language that gets compiled into platform dependent executable file or dynamic link library.It means .NET Compiler can generate code written using any supported languages and finally convert it to the machine code depending on the target machine. 4.What is CLR?

Ans. CLR is Common Language Runtime that provides multi-language execution environment for .NET.It executes the MSIL code to the native machine code.It helps us to use classes which is created in another .NET language.For eg. You can use a class created using vb in c#. 5.What is CTS? Ans. CTS is the .NET Framework specification for defining, declaring, and managing types in .NET languages for the Common Language Runtime (CLR). All .NET components must comply with the CTS specification. 6.What is Managed Code? Ans. Managed code is code that has its execution managed by the .NET Framework Common Language Runtime. It refers to a contract of cooperation between natively executing code and the runtime. This contract specifies that at any point of execution, the runtime may stop an executing CPU and retrieve information specific to the current CPU instruction address. Information that must be query-able generally pertains to runtime state, such as register or stack memory contents. 7.What is NameSpace? Ans. Set of names accessible at a given point in a program. A namespace is a logical grouping of the names—identifiers—used within an application. Each name within a namespace is unique. A namespace contains only the name of a type, but not the type itself. A developer creates namespaces in order to organize classes into functional units. A namespace of names is analogous to a folder of files; but, unlike the Java system, namespaces do not correspond to folders (directories). For example, the System.IO namespace contains the .NET inputouput support classes. Also known as name scope. 8.What is the difference between Namespace and Assembly? Ans. Namespace: It is a Collection of names wherein each name is Unique. They form the logical boundary for a Group of classes. Namespace must be specified in Project-Properties. Assembly: It is an Output Unit. It is a unit of Deployment & a unit of versioning. Assemblies contain MSIL code. Assemblies are Self-Describing. [e.g. metadata,manifest] An assembly is the primary building block of a .NET Framework application. It is

a collection of functionality that is built, versioned, and deployed as a single implementation unit (as one or more files). All managed types and resources are marked either as accessible only within their implementation unit, or by code outside that unit. 9.What is Manifest? Ans. Detailed description of the assembly contents. A manifest contains metadata describing the name, resources, types, and version of the assembly as well as dependencies upon other assemblies. The manifest makes an assembly self-describing, easier to deploy, and not bound to a particular system because of storing data in the Windows registry. 10.What is the difference between private and shared assembly? Ans. A private assembly is a assembly that is available to perticular applications where they are kept.And can not be refrences outside the scope of the folder where they are kept. In contrast,Shared Assemblies are the assembly that are accessible globally/shared across the machine to all the applications.For using shared assemblies you need to register the assembly with a strong name in the global assembly cache(GAC) using gacutil.exe.GAC can be found on all the computers with .Net Framework installed. 11.What is strong name? Ans. Globally unique .NET assembly name. Uses a public key encryption scheme to create a digital signature to ensure a truely unique strong name. The digital signature is also useful for authenticating the assembly creator, encrypting the assembly, and validating that assembly integrity. Strong names are created using the Shared name utility. 12.How can you create strong name for a .Net Assembly? Ans. With the help of StrongNametool (sn.exe). 13.What is GAC? Ans. Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several

applications on the computer. You should share assemblies by installing them into the global assembly cache only when you need to. 14.Where are Shared Assembly stored? Ans. In Global Assembly Cache(GAC). 15.Where's the Global Assembly Cache(GAC) located on the system? Ans. Usually C:\Winnt\assembly or C:\windows\assembly. 16.Can you have two files with the same name in GAC? Ans. Yes. Remember that GAC is a very special folder,and while normally you would not be able to place two files with the same name into a windows folder,GAC differentiates by version number, so its possible for App1.dll and App1.dll to co-exist in GAC if the first one is version and second one is 17.How do you Add and remove Assembly from GAC? Ans. To add a shared assembly,from the command line enter: gacutil.exe /i myassembly.dll To Remove a shared assembly,from the command line enter : gacutil.exe/u myassembly.dll 18.What is Delay Signing? Ans. Delay signing allows you to place a shared assembly in GAC by signing the assembly with just the public key.This allows the assembly to be signed with the private key at a later stage,when the development process is complete and component or assembly is ready to be deplyed.This process enables developers to work with shared assemblies as if they were strongly named and it secures the private key of the signature from being accessed at different stages of development. 19.How can you debug failed assembly binds? Ans. Use the Assembly Binding Log Viewer(fuslogvw.exe) to find out the paths searched.

20.What is Garbage Collection? Ans. GC is the process whereby the Common Language Runtime (CLR) reclaims memory that is no longer in use—i.e., no longer referenced by an active object. Objects on the heap are garbage collected after the final reference to them is destroyed. The exact moment of collection is determined by the CLR. Memory for stack values is freed up immediately when the stack frame in which they are declared ends—e.g., when a method returns. 21.Can we force garbage collection to run? Ans. In applications with significant memory requirements, you can force garbage collection by invoking the GC.Collect method from the program. This is not recommended and should be used only in extreme cases.System.GC classThe System.GC class provides methods that control the system garbage collector. Use methods from this class in your application with extreme caution. 22.What is Reflection? Ans. System.Reflection enables an application to discover information about classes in order to access class members, create new types at runtime (System.Reflection.Emit ), or modify its own behavior by calling methods at runtime using late-binding and dynamic invocation techniques. 23.What are different type of JIT? Ans. Pre-JIT (Compiles entire code into native code at one search) Ecno-JIT(Compiles code part by part freeing when required) Normal JIT (Compiles only that part of code when called and places in cache) 24.What is CAS(Code Access Security)? Ans.CAS defines permissions sets—things that can be done by a set of code and membership conditions. To do this, CAS identifies and characterizes client code so the appropriate permissions for that code can be determined. So defining how you want code access security to work is all about defining what you want an application to be able to do—and not do—and then telling .NET how to figure out whether the code gets the permission set to work.

25.What are value types and refrence types? Ans. Value Types: Value types inherit from the System.ValueType class, which in turn, inherits from System.Object. However, you can not inherit directly from the System.ValueType class. If you try to inherit explicitly from System.Value, you'll get the C3838 compiler error. Value types have several special properties:
      

Value types are stored on the stack. (We'll discover that shortly.) Value type objects have two representations: an unboxed form and a boxed form. Value types are accessed directly which means you don't need to use the new operator. Value types are managed types, they are initialised to 0 when they are created. Value type instances are not under the control of the Garbage Collector. Value types are implicitly sealed, which means that no class can derive from them. In C#, structs are always value types and allocated on the stack. Refrence Types:

Reference types inherit directly from System.Object, they offer many advantages over Value types:
 

Reference types are stored on the managed heap, thus they are under the control of Garbage Collector. Two or more reference type variables can refer to a single object in the heap, allowing operations on one variable to affect the object referenced by the other variable.

26.What is the concepts of Boxing and Unboxing? Ans.The Conversion of value type to refrence type is known as boxing and converting refrence type back to value type is known as unboxing. 27.What is the concepts of Serialization and Deserialization in .Net? Ans. Serialization is the process of taking an object and converting it to a format in which it can be transported across a network or persisted to a storage location. The storage location could be as simple as using a file or a database. The

serialized format contains the object's state information. Deserialization is the process of using the serialized state information to reconstruct the object from the serialized state to its original state. In essence, the process of serialization allows an object to be serialized, shipped across the network for remoting or persisted in a storage location such as the ASP.NET cache, and then be reconstructed for use at a later point in time. 28.What is Delegates? Ans. A delegate can be defined as a type safe function pointer. It encapsulates the memory address of a function in your code. Whenever you create or use an event in code, you are using a delegate. When the event is thrown, the framework examines the delegate behind the event and then calls the function that the delegate points to. 29.What is Multicast Delegates? Ans. Multicast delegates allow you to chain together several functions or subs that are all called together when the delegate is invoked. For the current iteration of the framework, you can't designate the order that the functions are run, only that they are all run, one after another. 30.What is ILDASM? Ans. The MSIL Disassembler is a companion tool to the MSIL Assembler (Ilasm.exe). Ildasm.exe takes a portable executable (PE) file that contains Microsoft intermediate language (MSIL) code and creates a text file suitable as input to Ilasm.exe. for more information on Ildasm please visit http://msdn.microsoft.com/library/default.asp?url=/library/enus/cptools/html/cpconMSILDisassemblerIldasmexe.asp

Shared By: