Saturday, November 21, 2009

DOT NET FAQ4

101. What is difference between constants, readonly and, static ?
Constants: The value can’t be changed
Read-only: The value will be initialized only once from the constructor of the class.
Static: Value can be initialized once.

102. What is difference between shared and public? An assembly that can be referenced by more than one application. An assembly must be explicitly built to be shared by giving it a cryptographically strong name.

103. What is namespace used for loading assemblies at run time and name the methods? System.Reflection

104. What are the types of authentication in .net? We have three types of authentication:
1. Form authentication
2. Windows authentication
3. Passport This has to be declared in web.config file.

105. What is the difference between a Struct and a Class ? The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, a struct is more efficient in some scenarios. For example, if you declare an array of 1000 Point objects, you will allocate additional memory for referencing each object. In this case, the struct is less expensive. When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized. It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values.
It is an error to initialize an instance field in a struct.
There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do.
A struct is a value type, while a class is a reference type.


106. How big is the datatype int in .NET?
32 bits.

107. How big is the char?
16 bits (Unicode).

108. How do you initiate a string without escaping each backslash? Put an @ sign in front of the double-quoted string.

109. What's the access level of the visibility type internal?
Current application.

110. Explain encapsulation ? The implementation is hidden, the interface is exposed.

111. What data type should you use if you want an 8-bit value that's signed?
sbyte.

112. Speaking of Boolean data types, what's different between C# and C/C++? There's no conversion between 0 and false, as well as any other number and true, like in C/C++.

113. Where are the value-type variables allocated in the computer RAM?
Stack.

114. Where do the reference-type variables go in the RAM?
The references go on the stack, while the objects themselves go on the heap.

115. What is the difference between the value-type variables and reference-type variables in terms of garbage collection?
The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects
are picked up by GC when their references go null.

116. How do you convert a string into an integer in .NET?
Int32.Parse(string)

117. How do you box a primitive data type variable?
Assign it to the object, pass an object.

118. Why do you need to box a primitive variable?
To pass it by reference.

119. What's the difference between Java and .NET garbage collectors?
Sun left the implementation of a specific garbage collector up to the JRE developer, so their performance varies widely, depending on whose JRE you're using. Microsoft standardized on their garbage collection.

120. How do you enforce garbage collection in .NET?
System.GC.Collect();

121. What's different about namespace declaration when comparing that to package declaration in Java?
No semicolon.

122. What's the difference between const and readonly?
You can initialize readonly variables to some runtime values. Let's say your program uses current date and time as one of the values that won't change. This way you declare public readonly string DateT = new DateTime().ToString().

123. What happens when you encounter a continue statement inside the for loop? The code for the rest of the loop is ignored, the control is transferred back to the beginning of the loop.

124. What's the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it's being operated on, a new instance is created.

125. Can you store multiple data types in System.Array?
No.

No comments:

Post a Comment