C# Questions1
C# Questions1
C# Questions1
1. 2. 3.
Does C# support multiple-inheritance? No. Who is a protected class-level variable available to? It is available to any sub-class (a class inheriting this class). 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. Describe the accessibility modifier protected internal. It is available to classes that are within the same assembly and derived from the specified base class. Whats the top .NET class that everything is derived from? System.Object. 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. Whats 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. Whats 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. Can you store multiple data types in System.Array? No.
4.
5. 6.
7.
8.
9.
11. How can you sort the elements of the array in descending order?
By calling Sort() and then Reverse() methods.
12. Whats the .NET collection class that allows an element to be accessed using
a unique key? HashTable.
14. Will the finally block get executed if an exception has not occurred?
Yes.
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 Can you prevent your class from being inherited by another class? Yes. The keyword sealed will prevent the class from being inherited. 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. Whats 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. 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. 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. Why cant you specify the accessibility modifier for methods inside the interface? They all must be public, and are therefore public by default. Can you inherit multiple interfaces? Yes. .NET does support multiple interfaces.
2. 3.
4.
5.
6.
7.
8.
9.
What happens if you inherit multiple interfaces and they have conflicting method names? Its 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 youre okay. To Do: Investigate
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.
Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit.
2. 3.
4.
5.
6.
2.
Whats a multicast delegate? A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.
3.
2.
3.
4.
5. 6. 7.
8.
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.
2.
3.
4.
5.
6.
7. 8.
9.
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. 3.
What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command. 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. What namespaces are necessary to create a localized application? System.Globalization and System.Resources. What is the smallest unit of execution in .NET? an Assembly. 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. How do you convert a value-type to a reference-type? Use Boxing. What happens in memory when you Box and Unbox a value-type?
4. 5. 6.
7. 8.
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. 9. 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. 10. What does the term immutable mean? 11. Difference between DataReader and DataAdapter / DataSet and DataAdapter? 12. wHAT IS THE DIFFERENCE BETWEEN THE CONSTRUCTOR AND DISTRUCTOR
13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. Use of Enable view state ? if turn off what happen ? Response.write,server.transfer difference which one is used when ? server.transfer limitation ? how can i kill user session ? wild card character in sql ? can aspx page contains two pager tags ? can aspx page have multi language declarations ? readonly syntax ? which control is used to compare two controls? two common propertys for any validation contro ? what is an assembly ? what is inheritancy where u required ? polymorphism and advantage ? what is the method while we are using adapter and dataset ? what are the things we generally declare in session_start , application_start ? .net class library to find unique key?
can Array contains different datatypes ? ACID properties ? which tag i need to use manually to bind columns in a datagrid ? throw exception and rethrowing difference. ? when garbage collector come into picture. ? what is code behined and an aspx files are for? how u maintain data while navigating one page to another What does the Dispose method do with the connection object?
The dispose method will release all the resources owned by the object. And then it calls the dispose() of its parent class. This is probagated through the base type hierarchy. 37. Can we have private constructor? when can I use them? 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. 38. what is an internal specifier? what happens internally when I use access specifier Internal ? 39. DO we have inline function in C#? ohterwise what is equivalent inline function in C#? 40. when we inherit from HttpApplication to create a class for Global.asax, Why do we NOT have to override Application_Start or any other event handler methods ?? Or, How is that eventhandler linked with the event? 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.. 41. When is CLR loaded in the memory? Is there only one instance of CLR running when we are running multiple applications? How is CLR first loaded? How is an assembly loaded in CLR and executed? 42. What is serialization, how it works in .NET? 2. What should one do to make class serializable? 3. What exactly is being serialized when you perform serialization? 4. scope in C# 43. How Web service create Proxy Using WSDL. 2)How to call .NET Web service from Java Appl. & Why ? 3)Is .NET really support fully OOP Concept? 44. 1. What is web garden? 2. What is object pooling? 3. Tell some thing about IIS isolation levels. 45. What are design patterns in c#?