DotNet Interview Questions and Answers
Question - 141 : - What is the purpose of XML Namespaces?
Answer - 141 : -
An XML Namespace is a collection of element types and attribute names. It consists of 2 parts
1) The first part is the URI used to identify the namespace
2) The second part is the element type or attribute name itself.
Together they form a unique name. The various purpose of XML Namespace are
1. Combine fragments from different documents without any naming conflicts. (See example below.)
2. Write reusable code modules that can be invoked for specific elements and attributes. Universally unique names guarantee that
such modules are invoked only for the correct elements and attributes.
3. Define elements and attributes that can be reused in other schemas or instance documents without fear of name collisions. For
example, you might use XHTML elements in a parts catalog to provide part descriptions. Or you might use the nil attribute
defined in XML Schemas to indicate a missing value.
< Department >
< Name >DVS1< /Name >
< addr:Address xmlns:addr="http://www.tu-darmstadt.de/ito/addresses" >
< addr:Street >Wilhelminenstr. 7< /addr:Street >
< addr:City >Darmstadt< /addr:City >
< addr:State >Hessen< /addr:State >
< addr:Country >Germany< /addr:Country >
< addr:PostalCode >D-64285< /addr:PostalCode >
< /addr:Address >
< serv:Server xmlns:serv="http://www.tu-darmstadt.de/ito/servers" >
< serv:Name >OurWebServer< /serv:Name >
Question - 142 : - What is difference between MetaData and Manifest ?
Answer - 142 : -
Metadata and Manifest forms an integral part of an assembly( dll / exe ) in .net framework . Out of which Metadata is a mandatory component , which as the name suggests gives the details about various components of IL code viz : Methods , properties , fields , class etc.
Essentially Metadata maintains details in form of tables like Methods Metadata tables , Properties Metadata tables , which maintains the list of given type and other details like access specifier , return type etc.
Now Manifest is a part of metadata only , fully called as “manifest metadata tables” , it contains the details of the references needed by the assembly of any other external assembly / type , it could be a custom assembly or standard System namespace .
Now for an assembly that can independently exists and used in the .Net world both the things ( Metadata with Manifest ) are mandatory , so that it can be fully described assembly and can be ported anywhere without any system dependency . Essentially .Net framework can read all assembly related information from assembly itself at runtime .
But for .Net modules , that can’t be used independently , until they are being packaged as a part of an assembly , they don’t contain Manifest but their complete structure is defined by their respective metadata .
Ultimately . .Net modules use Manifest Metadata tables of parent assembly which contain them .
Question - 143 : - What is the use of Internal keyword?.
Answer - 143 : - Internal keyword is one of the access specifier available in .Net framework , that makes a type visible in a given assembly , for e.g : a single dll can contain multiple modules , essentially a multi file assembly , but it forms a single binary component , so any type with internal keyword will be visible throughout the assembly and can be used in any of the modules .
Question - 144 : - What actually happes when you add a something to arraylistcollection ?
Answer - 144 : - Following things will happen :
Arraylist is a dynamic array class in c# in System.Collections namespace derived from interfaces – ICollection , IList , ICloneable , IConvertible . It terms of in memory structure following is the implementation .
a. Check up the total space if there’s any free space on the declared list .
b. If yes add the new item and increase count by 1 .
c. If No Copy the whole thing to a temporary Array of Last Max. Size .
d. Create new Array with size ( Last Array Size + Increase Value )
e. Copy back values from temp and reference this new array as original array .
f. Must doing Method updates too , need to check it up .
Question - 145 : - What is Boxing and unboxing? Does it occure automaatically or u need to write code to box and unbox?
Answer - 145 : - Boxing – Process of converting a System.ValueType to Reference Type , Mostly base class System.Object type and allocating it memory on Heap .Reverse is unboxing , but can only be done with prior boxed variables.
Boxing is always implicit but Unboxing needs to be explicitly done via casting , thus ensuring the value type contained inside .
Question - 146 : - How Boxing and unboxing occures in memory?
Answer - 146 : - Boxing converts value type to reference type , thus allocating memory on Heap . Unboxing converts already boxed reference types to value types through explicit casting , thus allocating memory on stack .
Question - 147 : - Why only boxed types can be unboxed?.
Answer - 147 : - Unboxing is the process of converting a Reference type variable to Value type and thus allocating memory on the stack . It happens only to those Reference type variables that have been earlier created by Boxing of a Value Type , therefore internally they contain a value type , which can be obtained through explicit casting . For any other Reference type , they don’t internally contain a Value type to Unboxed via explicit casting . This is why only boxed types can be unboxed .
Question - 148 : - What is side-by-side execution? Can two application one using private assembly and other using Shared assembly be stated as a side-by-side executables?
Answer - 148 : - Side-by-side execution is the ability to run multiple versions of an application or component on the same computer. You can have multiple versions of the common language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time. Since versioning is only applied to shared assemblies, and not to private assemblies, two application one using private assembly and one using shared assembly cannot be stated as side-by-side executables.
Question - 149 : - Why string are called Immutable data Type ?
Answer - 149 : - The memory representation of string is an Array of Characters, So on re-assigning the new array of Char is formed & the start address is changed . Thus keeping the Old string in Memory for Garbage Collector to be disposed.
Question - 150 : - What does assert() method do?
Answer - 150 : - In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.