27 August, 2009

C# Interview Questions - Part 9

81. why we use the ref keyword?
a ) If you want to pass a parameter by reference you should use the keyword ref

82. If an out parameter is not assigned a value with in the body of the function does that method complile?
a ) No. it won't compile

83. How can you make write a read only property?
a ) A property can made a read only by omitting the set accessor from the property defination.

84. When a static constructor is executed?
a ) It is executed when the class is loaded.

85. How many preprocessor directives exists in c#?
a ) They are #define, #undef, #if, #elif, #else, #endif, #error, #warning, #region, #endregion, #pragma etc

86. When an instance constructor is executed?
a ) It is executed when an instance is created.

87. Where you can assign values to a read only field?
a ) We can assign inside a constructor

88. Why we use the sixeof operator?
a ) If we want to know the size of any data type you can use sizeof operator.

89. What are the disadvantages of distructors in c#?
a ) 1. They are non deterministic. means there is no way to know when an object's destructor will actually execute.
2. Implementation of destructor delays the final removal of an object from memory. means objects that have destructors are removed in 2 passes. in the 1st pass only the destructor will be called with out removing object and then the 2nd pass removes the object, which is time taking and which may effect the performance.

90. What is the default access modifier of an interface members?
a) public

No comments: