General Questions 1.
Does C# support multiple-inheritance? No.
2.
Who is a protected class-level variable available to? It is available to any sub-class (a class inheriting this class).
3.
Are private class-level variables inherited? Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.
4.
Describe the accessibility modifier “protected internal”. It is available to classes that are within the same assembly and derived from the specified base class.
5.
What’s the top .NET class that everything is derived from? System.Object.
6.
What does the term immutable mean? The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.
7.
What’s the difference between System.String and System.Text.StringBuilder classes? System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
8.
What’s the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.
9.
Can you store multiple data types in System.Array? No.
10. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.
11. How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods.
12. What’s the .NET collection class that allows an element to be accessed using a unique key? HashTable.
13. What class is underneath the SortedList class? A sorted HashTable.
14. Will the finally block get executed if an exception has not occurred? Yes.
15. What’s the C# syntax to catch any possible exception? A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
16. Can multiple catch blocks be executed for a single try statement?
No. Once the proper catch block processed, control is transferred to the finally block (if there are any).
17. Explain the three services model commonly know as a three-tier application. Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).
Class Questions 1.
What is the syntax to inherit from a class in C#? Place a colon and then the name of the base class. Example: class MyNewClass : MyBaseClass
2.
Can you prevent your class from being inherited by another class? Yes. The keyword “sealed” will prevent the class from being inherited.
3.
Can you allow a class to be inherited, but prevent the method from being over-ridden? Yes. Just leave the class public and make the method sealed.
4.
What’s an abstract class? A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.
5.
When do you absolutely have to declare a class as abstract? 1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden. 2. When at least one of the methods in the class is abstract.
6.
What is an interface class? Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.
7.
Why can’t you specify the accessibility modifier for methods inside the interface? They all must be public, and are therefore public by default.
8.
Can you inherit multiple interfaces? Yes. .NET does support multiple interfaces.
9.
What happens if you inherit multiple interfaces and they have conflicting method names? It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay. To Do: Investigate
10. What’s the difference between an interface and abstract class?
In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers.
11. What is the difference between a Struct and a Class?
Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit.
Method and Property Questions 1.
What’s the implicit name of the parameter that gets passed into the set method/property of a class? Value. The data type of the value parameter is defined by whatever data type the property is declared as.
2.
What does the keyword “virtual” declare for a method or property? The method or property can be overridden.
3.
How is method overriding different from method overloading? When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.
4.
Can you declare an override method to be static if the original method is not static? No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override)
5.
What are the different ways a method can be overloaded? Different parameter data types, different number of parameters, different order of parameters.
6.
If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor? Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.
Events and Delegates
1.
What’s a delegate? A delegate object encapsulates a reference to a method.
2.
What’s a multicast delegate? A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.
XML Documentation Questions 1.
Is XML case-sensitive? Yes.
2.
What’s the difference between // comments, /* */ comments and /// comments? Single-line comments, multi-line comments, and XML documentation comments.
3.
How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with the /doc switch.
Debugging and Testing Questions 1.
What debugging tools come with the .NET SDK? 1. CorDBG – command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch. 2. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR.
2.
What does assert() method do? In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
3.
What’s the difference between the Debug class and Trace class? Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
4.
Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.
5.
Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor.
6.
How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger.
7.
What are three test cases you should go through in unit testing? 1. Positive test cases (correct data, correct output). 2. Negative test cases (broken or missing data, proper handling).
3.
8.
Exception test cases (exceptions are thrown and caught properly).
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.
ADO.NET and Database Questions 1.
What is the role of the DataReader class in ADO.NET connections? It returns a read-only, forward-only rowset from the data source. A DataReader provides fast access when a forward-only sequential read is needed.
2.
What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix. OLE-DB.NET is a .NET layer on top of the OLE layer, so it’s not as fastest and efficient as SqlServer.NET.
3.
What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.
4.
Explain ACID rule of thumb for transactions. A transaction must be: 1. Atomic - it is one unit of work and does not dependent on previous and following transactions. 2. Consistent - data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t. 3. Isolated - no transaction sees the intermediate results of the current transaction). 4. Durable - the values persist if the data had been committed even if the system crashes right after.
5.
What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and password).
6.
Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted? Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.
7.
What does the Initial Catalog parameter define in the connection string? The database name to connect to.
8.
What does the Dispose method do with the connection object? Deletes it from the memory. To Do: answer better. The current answer is not entirely correct.
9.
What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings. The connection string must be
identical.
Assembly Questions 1.
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.
2.
What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command.
3.
What is a satellite assembly? When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.
4.
What namespaces are necessary to create a localized application? System.Globalization and System.Resources.
5.
What is the smallest unit of execution in .NET? an Assembly.
6.
When should you call the garbage collector in .NET? As a good rule, you should not call the garbage collector. However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory. However, this is usually not a good practice.
7.
How do you convert a value-type to a reference-type? Use Boxing.
8.
What happens in memory when you Box and Unbox a value-type? Boxing converts a value-type to a reference-type, thus storing the object on the heap. Unboxing converts a reference-type to a value-type, thus storing the value on the stack.
Question: 1) Can we have private constructor? when can I use them? Answer: private constructors can be used when u donot want the class's object to be created. Since the constructor cannot be accessed, an object of the class cannot be created. A possible scenario would be , a class with static methods.. which dont need object instance to be called. 1.
Explain the differences between Server-side and Client-side code? ANS: Server side code will execute at server end all the business logic will execute at server end where as client side code will execute at client side at browser end. 2. What type of code (server or client) is found in a Code-Behind class? ANS : Server side. 3. Should validation (did the user enter a real date) occur server-side or client-side?
Why? ANS : client side . there is no need to go to validate user input. If it relates to data base validation we need to validate at server side. 4. What does the "EnableViewState" property do? Why would I want it on or off? ANS: IT keeps the data of the control during post backs. if we turn off the values should not populate during server round trip. 5. What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? ANS: Server.Trnasfer will prevent round trip. it will redirect pages which or in the same directory. NO way to pass the query strings . Thru http context we can able to get the previous page control values. Response.Redirect : There is a round trip to process the request. We can redirect to any page external / internal other than aspx. We can pass the query string thru which we can manage sessions. 6. Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced .NET component ANS : Web services are best suite for Hetrogenious environment. Remoting is best suite for Homogenious environment. The systems that under CLR. 7. Let's say I have an existing application written using Visual Studio 6 (VB 6, InterDev 6) and this application utilizes Windows 2000 COM+ transaction services. How would you approach migrating this application to .NET We need to have Wrapper to communicate COM components in .net. and vis versa CCW : Com Callable wrapper. RCW : RUN time callable wrapper. 8. Can you explain the difference between an ADO.NET Dataset and anADO Recordset?\ ANS : DIsconnected architechure . Maintainace relation schemas. MUtilple table grouping. Connected one . 9. Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines? ANS: APplication_start need for global variable which are available over the application. Sesssion_Start : login dependent ( user dependent) 10. If I'm developing an application that must accomodate multiple security levels though secure login and my ASP.NET web appplication is spanned across three web-servers (using round-robbin load balancing) what would be the best approach to maintain login-in state for the users? ANS : Database Support. or Thru state service.
11. What are ASP.NET Web Forms? How is this technology different than what is available though ASP (1.0-3.0)? ANS : ASP . Interprepter.. use the script engine. ASP.Net Compiled. 12. How does VB.NET/C# achieve polymorphism? ANS : Function overloading. Operator overloading. 11. Can you explain what inheritance is and an example of when you might use it? ANS : Heridity. Use the existing functionality along with its own properities. 13. How would you implement inheritance using VB.NET/C#? ANS: Derived Class : Basecalss VB.NEt : Derived Class Inherits Baseclass 14. Whats an assembly ANS : A Basic unit of executable code > Which contains : Manifest - Meta data versioning , Calture , IL, Reference 15. Describe the difference between inline and code behind - which is best in a loosely coupled solution Tightly coupled - INLINE ANS: inline function bind at compile time can write in aspx page with in <% %> . 17. Explain what a diffgram is, and a good use for one ANS : is an xml grammer. it talk about state of node in xml file. 18. Where would you use an iHTTPModule, and what are the limitations of any approach you might take in implementing one ANS: Preprocessing before going to IIS. 20. What are the disadvantages of viewstate/what are the benefits ANS : IT can be hacked . page is size is heavy. 21 Describe session handling in a webfarm, how does it work and what are the limits ANS: Session - mode State sever OUtprocess sql 22. How would you get ASP.NET running in Apache web servers - why would you even do this? ANS: ---- Install Mod_AspDotNet Add at the end of C:\Program Files\Apache Group\Apache2\conf\httpd.conf the following lines 23. Whats MSIL, and why should my developers need an appreciation of it if at all? ANS : Microsoft Intermeidate lanaguage. which is the out put for all the .net supported languages after comiplation will produce.
Appreciation for cross language support. 24. In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events? ANS : INIT, PageLoad, Prerender , UNload. 25. Which method do you invoke on the DataAdapter control to load your generated dataset with data? Fill() 26. Can you edit data in the Repeater control? NO 27. Which template must you provide, in order to display data in a Repeater control? ITemtemplate 28. How can you provide an alternating color scheme in a Repeatercontrol? AlternateItemTemplate 29. What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeatercontrol? Datasource, DataBind 30. What base class do all Web Forms inherit from? System.Web.UI.Page 31. What method do you use to explicitly kill a user s session? abondon() 32 How do you turn off cookies for one page in your site? disablecookies. 33. Which two properties are on every validation control? control to validate, error message 34. What tags do you need to add within the asp:datagrid tags to bind columns manually? autogenerated columns is set to false 35. How do you create a permanent cookie? Cooke = ne cookee(). cooke.adddate. 36. What tag do you use to add a hyperlink column to the DataGrid? hyper link column 37. What is the standard you use to wrap up a call to a Web service -----------38. Which method do you use to redirect the user to another page without performing a round trip to the client? server.transfer 39. What is the transport protocol you use to call a Web service SOAP http 40. True or False: A Web service can only be written in .NET false
41. What does WSDL stand for? webservice discription language. it is used to generate for proxy( server object) 42. What property do you have to set to tell the grid which page to go to when using the Pager object? Page Index. 43. Where on the Internet would you look for Web services? UDDI 44. What tags do you need to add within the asp:datagrid tags to bind columns manually. Autogenerate columns 45. Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box? datatext datavalue 46. How is a property designated as read-only? get 47. Which control would you use if you needed to make sure the values in two different controls matched? compare filed validator 48. True or False: To test a Web service you must create a windows application or Web application to consume this service? no 49. How many classes can a single .NET DLL contain? as many as u want..
37. What is the standard you use to wrap up a call to a Web service Ans:SOAP 4.
Describe the accessibility modifier “protected internal”. It is available to classes that are within the same assembly and derived from the specified base class. - THIS IS WRONG. The correct statement is: It is available to classes that are within the same assembly OR derived from the specified base class.
To find difference between days DateTime t1 = new DateTime(2008, 5, 13); DateTime t2 = new DateTime(2004, 2, 22); TimeSpan span = (t1 > t2 ? t1 - t2 : t2 - t1); Console.WriteLine(span.TotalDays);
1. Is it possible to inline assembly or IL in C# code? - No.
2. Is it possible to have different access modifiers on the get/set methods of a property? - No. The access modifier on a property applies to both its get and set accessors. What you need to do if you want them to be different is make the property read-only (by only providing a get accessor) and create a private/internal set method that is separate from the property. 3. Is it possible to have a static indexer in C#? - No. Static indexers are not allowed in C#. 4. If I return out of a try/finally in C#, does the code in the finally-clause run? Yes. The code in the finally always runs. If you return out of the try block, or even if you do a “goto” out of the try, the finally block always runs: 5. using System; 6. 7. class main 8. { 9. public static void Main() 10. { 11. try 12. { 13. Console.WriteLine("In Try block"); 14. return; 15. } 16. finally 17. { 18. Console.WriteLine("In Finally block"); 19. } 20. } }
Both “In Try block” and “In Finally block” will be displayed. Whether the return is in the try block or after the try-finally block, performance is not affected either way. The compiler treats it as if the return were outside the try block anyway. If it’s a return without an expression (as it is above), the IL emitted is identical whether the return is inside or outside of the try. If the return has an expression, there’s an extra store/load of the value of the expression (since it has to be computed within the try block). 21. I was trying to use an “out int” parameter in one of my functions. How should I declare the variable that I am passing to it? - You should declare the variable as an int, but when you pass it in you must specify it as ‘out’, like the following: int i; foo(out i); where foo is declared as follows: [return-type] foo(out int o) { } 22. How does one compare strings in C#? - In the past, you had to call .ToString() on the strings when using the == or != operators to compare the strings’ values. That will still work, but the C# compiler now automatically compares the values instead of the references when the == or != operators are used on string types. If you actually do want to compare references, it can be done as follows: if ((object) str1 == (object) str2) { … } Here’s an example showing how string compares work: 23.using System; 24.public class StringTest
25.{ 26. public static void Main(string[] args) 27. { 28. Object nullObj = null; Object realObj = new StringTest(); 29. int i = 10; 30. Console.WriteLine("Null Object is [" + nullObj + "]\n" 31. + "Real Object is [" + realObj + "]\n" 32. + "i is [" + i + "]\n"); 33. // Show string equality operators 34. string str1 = "foo"; 35. string str2 = "bar"; 36. string str3 = "bar"; 37. Console.WriteLine("{0} == {1} ? {2}", str1, str2, str1 == str2 ); 38. Console.WriteLine("{0} == {1} ? {2}", str2, str3, str2 == str3 ); 39. } 40.}
Output: Null Object is [] Real Object is [StringTest] i is [10] foo == bar ? False bar == bar ? True
41. How do you specify a custom attribute for the entire assembly (rather than for a class)? - Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows: 42.using System; 43.[assembly : MyAttributeClass] class X {}
Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs. 44. How do you mark a method obsolete? [Obsolete] public int Foo() {...}
or [Obsolete("This is a message describing why this method is obsolete")] public int Foo() {...}
Note: The O in Obsolete is always capitalized. 45. How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#? - You want the lock statement, which is the same as Monitor Enter/Exit: 46.lock(obj) { // code }
translates to try { CriticalSection.Enter(obj); // code } finally { CriticalSection.Exit(obj); }
47. How do you directly call a native function exported from a DLL? - Here’s a quick example of the DllImport attribute in action: 48.using System.Runtime.InteropServices; \ 49.class C 50.{ 51. [DllImport("user32.dll")] 52. public static extern int MessageBoxA(int h, string m, string c, int type); 53. public static int Main() 54. { 55. return MessageBoxA(0, "Hello World!", "Caption", 0); 56. } 57.}
This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA. For more information, look at the Platform Invoke tutorial in the documentation. 58. How do I simulate optional parameters to COM calls? - You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters. 59. 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. 60. Can you store multiple data types in System.Array? No. 61. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? The first one performs a deep copy of the array, the second one is shallow. 62. How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods. 63. What’s the .NET datatype that allows the retrieval of data by a unique key? HashTable. 64. What’s class SortedList underneath? A sorted HashTable. 65. Will finally block get executed if the exception had not occurred? Yes.
66. What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception? A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}. 67. 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. 68. Why is it a bad idea to throw your own exceptions? Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project. 69. What’s a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers. 70. What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods. 71. How’s 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. 72. What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command. 73. What’s a satellite assembly? When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies. 74. What namespaces are necessary to create a localized application? System.Globalization, System.Resources. 75. What’s the difference between // comments, /* */ comments and /// comments? Single-line, multi-line and XML documentation comments. 76. How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with a /doc switch. 77. What’s the difference between and XML documentation tag? Single line code example and multiple-line code example. 78. Is XML case-sensitive? Yes, so <Student> and <student> are different elements. 79. What debugging tools come with the .NET SDK? CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch. 80. What does the This window show in the debugger? It points to the object that’s pointed to by this reference. Object’s instance data is shown. 81. What does assert() do? In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true. 82. What’s the difference between the Debug class and Trace class? Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
83. Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities. 84. Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor. 85. How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger. 86. What are three test cases you should go through in unit testing? Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly). 87. 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. 88. Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources). 89. What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines. 90. What’s the role of the DataReader class in ADO.NET connections? It returns a read-only dataset from the data source when the command is executed. 91. What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’. 92. 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 hasn’t), 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). 93. What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords). 94. Which one is trusted and which one is untrusted? Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction. 95. Why would you use untrusted verificaion? Web Services might use it, as well as non-Windows applications. 96. What does the parameter Initial Catalog define inside Connection String? The database name to connect to.
97. What’s the data provider name to connect to Access database? Microsoft.Access. 98. What does Dispose method do with the connection object? Deletes it from the memory. 99. What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings. 1. What is indexer? Where it is used explain 2. What is .NET Framework? 3. How we handle sql exceptions? What is the class that handles SqlServer exceptions? 4. What is the advantage of serialization? 5. how to fill datalist usinf XML file and how to bind it,code behind language is c# 6. What is the difference between const and static read-only? 7. Is it mandatory to implement all the methods which are there in abstract class if we inherit that abstract 8. Why do I get a "CS5001: does not have an entry point defined" error when compiling? 9. What's the implicit name of the parameter that gets passed into the class' set method? 10. How do you inherit from a class in C#? 11. Does C# support multiple inheritance? 12. When you inherit a protected class-level variable, who is it available to? 13. Are private class-level variables inherited? 14. Describe the accessibility modifier protected internal. 15. What is the implicit name of the parameter that gets passed into the class set method? 16. What's the top .NET class that everything is derived from? 17. How's method overriding different from overloading? 18. What does the keyword virtual mean in the method definition? 19. What is an abstract class? 20. What is the data provider name to connect to Access database?
Which type is inherited by Class by default? Posted by: SheoNarayan | Show/Hide Answer
NOTE: This is objective type question, Please click question title for correct answer.
Which type is inherited by Structs by default? Posted by: SheoNarayan | Show/Hide Answer
NOTE: This is objective type question, Please click question title for correct answer.
What is partial class? Posted by: Poster | Show/Hide Answer
Partial class is a new functionality added in since .NET Framework 2.0 version. It allows to split
us to split the definition of once class, struct, interface into multiple source files. Each source file contains a section of definition, and all parts are combined when the application is compiled. For more detail see http://msdn.microsoft.com/en-us/library/wa80x488(VS.80).aspx
What is nested class? Posted by: Poster | Show/Hide Answer
A Nested classes are classes within classes. OR A nested class is any class whose declaration occurs within the body of another class or interface. For more details see http://www.codeproject.com/KB/cs/nested_csclasses.aspx
What is top-level class? Posted by: Poster | Show/Hide Answer
A top level class is a class that is not a nested class. See what is nested class http://www.dotnetfunda.com/interview/exam281-what-is-nestedclass.aspx
Which namespace is required to use Generic List? Posted by: Raja | Show/Hide Answer
NOTE: This is objective type question, Please click question title for correct answer.
What is garbage collection? Posted by: Rohitshah | Show/Hide Answer
Garbage collection is a mechanism that allows the computer to detect when an object can no longer be accessed. It then automatically releases the memory used by that object (as well as calling a clean-up routine, called a "finalizer," which is written by the user). Some garbage collectors, like the one used by .NET, compact memory and therefore decrease your program's working set.
What is an application domain? Posted by: Rohitshah | Show/Hide Answer
An application domain (often AppDomain) is a virtual process that serves to isolate an application. All objects created within the same application scope (in other words, anywhere along the sequence of object activations beginning with the application entry point) are created within the same application domain. Multiple application domains can exist in a single operating system process, making them a lightweight means of application isolation. An OS process provides isolation by having a distinct memory address space. While this is effective, it is also expensive, and does not scale to the numbers required for large web servers. The Common Language Runtime, on the other hand, enforces application isolation by managing the memory use of code running within the application domain. This ensures that it does not access memory outside the boundaries of the domain. It is important to note that only type-safe code can be managed in this way (the runtime cannot guarantee isolation when unsafe code is loaded in an application domain).
If I want to build a shared assembly, does that require the overhead of signing and managing key pairs? Posted by: Rohitshah | Show/Hide Answer
Building a shared assembly does involve working with cryptographic keys. Only the public key is strictly needed when the assembly is being built. Compilers targeting the .NET Framework provide command line options (or use custom attributes) for supplying the public key when building the assembly. It is common to keep a copy of a common public key in a source database and point build scripts to this key. Before the assembly is shipped, the assembly must be fully signed with the corresponding private key. This is done using an SDK tool called SN.exe (Strong Name). Strong name signing does not involve certificates like Authenticode does. There are no third party organizations involved, no fees to pay, and no certificate chains. In addition, the overhead for verifying a strong name is much less than it is for Authenticode. However, strong names do not make any statements about trusting a particular publisher. Strong names allow you to ensure that the contents of a given assembly haven't been tampered with, and that the assembly loaded on your behalf at run time comes from the same publisher as the one you developed against. But it makes no statement about whether you can trust the identity of that publisher.
What is the difference between Data Reader & Dataset? Posted by: Rohitshah | Show/Hide Answer
Data Reader is connected, read only forward only record set. Dataset is in memory database that can store multiple tables, relations and constraints; moreover dataset is disconnected and is not aware of the data source.
What is Attribute Programming? What are attributes? Where are they used? Posted by: Rohitshah | Show/Hide Answer
Attributes are a mechanism for adding metadata, such as compiler instructions and other data about your data, methods, and classes, to the program itself. Attributes are inserted into the metadata and are visible through ILDasm and other metadata-reading tools. Attributes can be used to identify or use the data at runtime execution using .NET Reflection.
Is String is Value Type or Reference Type in C#? Posted by: Rohitshah | Show/Hide Answer
String is an object (Reference Type).
Q1: Can DateTime variables be null? A1: No, because it is a value type (Struct) Q2: Describe the Asp.net Page Life Cycle? A2: http://msdn2.microsoft.com/en-us/library/ms178472.aspx Q3: Describe the Asp.net pipeline ? Give an Example when you need to extend it? How do you do so? A3: http://msdn.microsoft.com/msdnmag/issues/02/09/HTTPPipelines/ Q4: Describe the accessibility modifier protected internal A4: Members are accessible to derived classes and classes within the same Assembly
Q5: Difference between an interface and abstract class? A5: In the interface all methods must be abstract, in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes. Q6: How do you perform pre- and post-processing to extend a WebMethod ? A6: Use SOAP extensions ...http://msdn.microsoft.com/msdnmag/issues/04/03/ASPColumn/ Q7: What are Design Patterns? A7: It is a big topic in Object Oriented, so for more information see this, http://dofactory.com/Patterns/Patterns.aspx
Q8: What do you know about .net framework 3.0 ? A8: any answer that introduces Windows Communication Foundation (WCF), Windows Workflow Foundation (WF), Windows Presentation Foundation (WPF) and Windows Card Space (WCS) is right, also you can mention that it was originally called WinFX Q9: What do you know about ATLAS (Microsoft ASP.net AJAX Extensions) ? A9: for more information check here, http://ajax.asp.net Q10: What do you know about Agile software methodologies? A10: http://en.wikipedia.org/wiki/Agile_software_development Q11: What do you know about Web Services Enhancements (WSE)? A11: http://msdn.microsoft.com/webservices/webservices/building/wse/default.aspx Q12: What is AJAX ? A12: Asynchronous Javascript And XML Q13:What is NUnit, or What is Unit testing? A13: Unit testing: is a procedure used to validate that a particular module of source code is working properly from each modification to the next. The procedure is to write test cases for all functions and methods so that whenever a change causes a regression, it can be quickly identified and fixed. Ideally, each test case is separate from the others; constructs such as mock objects can assist in separating unit tests. This type of testing is mostly done by the developers, NUnit is a famous tool for Unit Testing in .net Q14: What is an Asp.net Http Handler & Http Module? A14: http://www.15seconds.com/issue/020417.htm Q15: What is mutable type ? immutable type ? A15: Immutable type are types whose instance data, fields and properties, does not change after the instance is created. Most value types are immutable, but the mutable type are A type whose instance data, fields and properties, can be changed after the instance is created. Most Reference Types are mutable.
Q16: What is the HttpContext Object? Where is it accessible? A16: It's is an Object that Encapsulates all HTTP-specific information about an individual HTTP request. it is avaliable through out the Asp.net request pipline. Q17: What is the difference between String & StringBuilder classes? A17: String is an immutable type while StringBuilder is a mutable type Q18: What's the difference between C# 1.0 & C# 2.0? A18: Any answer that introduces stuff like, Generics, Anonymous Methods, Nullable types, Iterators ... etc, is correct Q19: Without using the multiplication or addition operations, how can you multiply a number x by 8? A19: Shift x to the left 3 times, x << 3, because every shift left multiplies the number by 2
Q20: What is the difference between ASP.net 1.x & ASP.net 2.0 ? A20: Any answer that include stuff like Provider model (membership provider, role provider ... etc) and Master Pages, Code Beside model, new web controls will be ok. If you have more questions feel free to join the user group and add them directly to the database. Published Monday, February 26, 2007 5:38 PM by Mohammed Hossam Filed Under: C# Language
Comments # re: .Net & C# Interview question, along with general programming questions Tuesday, February 27, 2007 9:11 AM by Mohamed Tanna
More Interview question 1-Does C# support multiple-inheritance? -No. 2-Who is a protected class-level variable available to? -It is available to any sub-class (a class inheriting this class). 3-Are private class-level variables inherited? -Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited. 4-Describe the accessibility modifier “protected internal”. -It is available to classes that are within the same assembly and derived from the specified base class.
5-What’s the top .NET class that everything is derived from? -System.Object. 6-What does the term immutable mean? -The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory. 7-What’s the difference between System.String and System.Text.StringBuilder classes? -System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed. 8-What’s the advantage of using System.Text.StringBuilder over System.String? -StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created. 9-Can you store multiple data types in System.Array? -No. 10-What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? -The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object. 11-How can you sort the elements of the array in descending order? -By calling Sort() and then Reverse() methods. 12-What happens if you inherit multiple interfaces and they have conflicting method names? -It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay. To Do: Investigate 13-If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor
to a specific base constructor? -Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class. 14-What’s a multicast delegate? -A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called. 15-How do you debug an ASP.NET Web application? -Attach the aspnet_wp.exe process to the DbgClr debugger. 16-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.
C# Interview Questions | C Sharp Interview Questions 1) Explain about C#? C # is also known as c sharp. It is a programming language introduced by Microsoft. C# contains features similar to Java and C++. It is specially designed to work with Microsoft .NET platform. 2) Explain about the rules for naming classes in C#? These are the rules for naming classes in c sharp. • Must begin with a letter. This letter may be followed by a sequence of letters, digits (0-9), or ‘_’. The first character in a class name cannot be a digit. • Must not contain any embedded space or symbol like ? - + ! @ # % & * ( ) { } [ ] , : ; ‘ “ \ and/. However an underscore _ can be used wherever a space is required. • Must not use a keyword for a class name. 3) What are the rules to be followed while naming variables in C#. The following rules are used for naming variables in C#. * Must begin with a letter or an underscore _ which may be followed by a sequence of letters, digits (0-9), or ‘_’. The first character in a variable name cannot be a digit. * Must not contain any embedded space or symbol like ? - + ! @ # % & * ( ) { } [ ] , : ; ‘ “ \ and/. However an underscore _ can be used wherever a space is required. • Must be unique • Can have any number of characters • Keywords cannot be used as variable names. 4) What are the different types of Data? There are two different types of data supported by C#. They are 1) Value types: -They directly contain data. When you declare an int variable, the system allocates memory to store the value. 2) Reference type: -The reference types do not maintain data but they contain a reference to the variables, which are stored in memory. This means that if the value in the memory
location is modified by one of the variables, the other variables automatically reflect the changes value 5) Explain about member functions? A function is a set of statements that perform a specific task in response to a message. The functions of a class are called member functions in Csharp. Member functions are declared inside the class. The function declaration introduces the function in the class and the function definition contains the function code. 6) Explain about comment entry? Comments are a part of the program and are used to explain the code. Compilers ignore comment entries. If a comment entry spans more than one line, it has to be enclosed within ‘/*’ and ‘*/’. The symbol ‘//’ treats the rest of code within the same line as a comment. 7) What are operators? Applications use operators to process the data entered by a user. Operators like + and – are used to process variables and return a value. An operator is a set of one or more characters that is used for computations or comparisons. Operators can transform one or more data values, called operands into a new data value. 8) Explain about the break statement? A break statement is used to exit the switch statement. This prevents the execution of the remaining case structures by ending the execution of the switch case construct. Each break statement terminates the enclosing switch statement and the flow of control. If none of the cases match the default case is invoked. 9) Define encapsulation? Encapsulation literally means to enclose in or as if in a capsule. Encapsulation is defined as the process of enclosing one or more items within a physical or logical package. It involves preventing access to nonessential details. 10) Define access specifier with reference to class? An access specifier defines the scope of a class member. A class member refers to the variables and functions in a class. A program can have one or more classes. You may want some members of a class to be accessible to other classes. But, you may not want some other members of the class to be accessible outside the class. 11) Describe about private access specifier? The private access specifier allows a class to hide its member variables and member functions from other class objects and functions. Therefore, the private member of a class is not visible outside a class. If a member is declared private, only the functions of that class can access the member. Even the instance of the class cannot access its members 12) Explain about protected internal access specifier? This specifier allows a class to hide its member variables and member functions to be accessed from other class objects and functions, except the child class, within the application. The protected internal access specifier becomes important while implementing inheritance. 13) Define parameter by value? Pass by value is the default mechanism for passing parameters to a method. The simplest definition of a value parameter is a data type name followed by a variable name. When a method is called, a new storage location is created for each value parameter. The values of the corresponding expressions are copied into them. The expression supplied for each value parameter must be similar to the declaration of the value parameter. 14) State the methods through which parameters can be passed? Parameters can be passed by using any one of the following mechanism. Value: -They are sometimes called in or out parameters; therefore, the data can be transferred into the method but cannot be transferred out. Reference: -Are sometimes called in or out parameters, therefore, the data can be transferred
into the method and out again. Output: -Are sometimes called out parameters, data can be transferred out of the method. 15) Explain about reference parameter? A reference parameter is a reference to a memory location of a data member. Unlike a value parameter, a reference parameter does not create a new storage location. Instead a reference parameter represents the same location in memory as the variable that is supplied in the method call. 16) How do you use a structure? A structure is a value type data type. When you want a single variable to hold related data of various data types, you can create a structure. To create a structure you use the struct keyword. 17) What is an enumerator? Enumeration is a value data type, which means that enumeration contains its own values and cannot inherit or pass inheritance. Enumerator allows you to assign symbolic names or integral constants.