Saturday, November 26, 2005

Technical Interview Questions - Part 2

Q.1 Is it possible to have a private constructor?
Yes, it is possible if you want to prevent its instantiation or if you want to have a singleton class.

Q.2 What is the purpose of singleton pattern?
To manage accesses to a shared resource.

Q.3 Is it possible that we can inherit singleton class?
A singleton class cannot be inherited i.e. a class having its ocnstructors private including the default constructor cannot be inherited. It will generate a compile time error.

Q.4 Can we implement inheritence (polymorphism) using delegates?
Yes we can implement polymorphism using delegates i.e. inheritance. A delegate can be attached to any function having same signature.

Q.5 Can we use delegates in place of inheritence (polymorphism)?
Nops, we cannot do this as delegates can be attached to any function having same signature but in case of inheritance only methods of the same class or its parent class can be called.

Q.6 Which is faster, stored procedures or embedded SQL?
Stored procedures as they are pre-compiled, optimized and stored with the database. On the other hand embeded SQL is compiled every-time when it is executed.

No comments: