Thursday, January 3, 2008
41 How is the DLL Hell problem solved in .NET?
Assembly versioning allows the application to specify not only the library it needs to run (which
was available under Win32), but also the version of the assembly.
42 How is method overriding different from overloading?
When overriding, you change the method behavior for a derived class. Overloading simply
involves having a method with the same name within the class.
43 How do you inherit from a class in C#?
Place a colon and then the name of the base class. Notice that it is double colon in C++.
44 How do you generate documentation from the C# file commented properly with a commandline compiler?
Compile it with a /doc switch.
45 How do you debug an ASP.NET Web application?
Attach the aspnet_wp.exe process to the DbgClr debugger.
46 How can you sort the elements of the array in descending order?
By calling Sort() and then Reverse() methods.
47 How can you overload a method?
Different parameter data types, different number of parameters, different order of parameters.
48 Explain the three services model (three-tier application).
Presentation (UI), business (logic and underlying code) and data (from storage or other
sources).
49 Explain ACID rule of thumb for transactions.
Transaction must be Atomic (it is one unit of work and does not dependent on previous and
following transactions), Consistent (data is either committed or roll back, no in-between case
where something has been updated and something hasnot), Isolated (no transaction sees the
intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).
50 Does C# support multiple inheritance?
No, use interfaces instead.
51 Describe the accessibility modifier protected internal.
It is available to derived classes and classes within the same Assembly (and naturally from the
base class it is declared in).
52 Can you store multiple data types in System.Array?
No.
53 Can you prevent your class from being inherited and becoming a base class for some other
classes?
Yes, that is what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It is the same concept as final class in Java.
54 Can you override private virtual methods?
No, moreover, you cannot access private methods in inherited classes, have to be protected in
the base class to allow any sort of access.
55 Can you inherit multiple interfaces?
Yes.
56 Can you declare the override method static while the original method is non-static?
No, you cannot, the signature of the virtual method must remain the same, only the keyword
virtual is changed to keyword override.
57 Can you change the value of a variable while debugging a C# application?
Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.
58 Can you allow class to be inherited, but prevent the method from being over-ridden?
Yes, just leave the class public and make the method sealed.
59 Can multiple catch blocks be executed?
No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.
60 C# provides a default constructor for me. I write a constructor that takes a string as a
parameter, but want to keep the no parameter one. How many constructors should I write?
Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you
have to write one yourself, even if there is no implementation in it.
Labels: interview questions 3
0 comments:
Post a Comment