Wednesday, July 2, 2008

C Sharp Interview Question: Basic Part 1

Basic Questions.

1. Does C# support multiple inheritance?
No.

2. Can a class implement more than one interface?
Yes

3. Outline three exception handling code blocks"
try{} catch(){}
try{} finally {}
try{} catch() {} finally {}

4. When is the finally block executed?
When there is an error and a catch block is present the catch block executes first.
Following that the finally block is executed.
When there is no error, the finally block executed immediately after the last line in the flow of the try block.

5. What is the most common use of a finally block?
Release resources acquired or used in the try block.

6. Explain immutable in relation to C#.
All primitive types are immutable which means that after the type is constructed (allocated) it's value will not change. Statements that appear to change the value, actually cause the type to be constructed (reallocated) again.

7. For class named BaseClass and a class named DerivedClass, how would you declare DerivedClass to indicate that it directly inherits from base class?
class DerivedClass : BaseClass

8. What is the implicit parameter of set method of a property?
Value

9. What are three types of comments used in C#?
Single line comments '//'
Multiline comments that start with '/*' and ends with '*/'
XML comments '///'

No comments: