.NET Windows Forms Interview Questions and Answers

  1. Write a simple Windows Forms MessageBox statement.
    System.Windows.Forms.MessageBox.Show
    ("Hello, Windows Forms");
  2. Can you write a class without specifying namespace? Which namespace does it belong to by default??
    Yes, you can, then the class belongs to global namespace which has no name. For commercial products, naturally, you wouldn’t want global namespace.
  3. You are designing a GUI application with a window and several widgets on it. The user then resizes the app window and sees a lot of grey space, while the widgets stay in place. What’s the problem?
    One should use anchoring for correct resizing. Otherwise the default property of a widget on a form is top-left, so it stays at the same location when resized.
  4. How can you save the desired properties of Windows Forms application?
    .config files in .NET are supported through the API to allow storing and retrieving information. They are nothing more than simple XML files, sort of like what .ini files were before for Win32 apps.
  5. So how do you retrieve the customized properties of a .NET application from XML .config file?
    Initialize an instance of AppSettingsReader class. Call the GetValue method of AppSettingsReader class, passing in the name of the property and the type expected. Assign the result to the appropriate variable.
  6. Can you automate this process?
    In Visual Studio yes, use Dynamic Properties for automatic .config creation, storage and retrieval.
  7. My progress bar freezes up and dialog window shows blank, when an intensive background process takes over.
    Yes, you should’ve multi-threaded your GUI, with taskbar and main form being one thread, and the background process being the other.
  8. What’s the safest way to deploy a Windows Forms app?
    Web deployment: the user always downloads the latest version of the code; the program runs within security sandbox, properly written app will not require additional security privileges.
  9. Why is it not a good idea to insert code into InitializeComponent method when working with Visual Studio?
    The designer will likely throw it away; most of the code inside InitializeComponent is auto-generated.
  10. What’s the difference between WindowsDefaultLocation and WindowsDefaultBounds? WindowsDefaultLocation tells the form to start up at a location selected by OS, but with internally specified size. WindowsDefaultBounds delegates both size and starting position choices to the OS.
  11. What’s the difference between Move and LocationChanged? Resize and SizeChanged?
    Both methods do the same, Move and Resize are the names adopted from VB to ease migration to C#.
  12. How would you create a non-rectangular window, let’s say an ellipse?
    Create a rectangular form, set the TransparencyKey property to the same value as BackColor, which will effectively make the background of the form transparent. Then set the FormBorderStyle to FormBorderStyle.None, which will remove the contour and contents of the form.
  13. How do you create a separator in the Menu Designer?
    A hyphen ‘-’ would do it. Also, an ampersand ‘&\’ would underline the next letter.
  14. How’s anchoring different from docking?
    Anchoring treats the component as having the absolute size and adjusts its location relative to the parent form. Docking treats the component location as absolute and disregards the component size. So if a status bar must always be at the bottom no matter what, use docking. If a button should be on the top right, but change its position with the form being resized, use anchoring.

Simple Questions:

  1. What is a static class?
  2. What is static member?
  3. What is static function?
  4. What is static constructor?
  5. How can we inherit a static variable?
  6. How can we inherit a static member?
  7. Can we use a static function with a non-static variable?
  8. How can we access static variable?
  9. Why main function is static?
  10.  

  11. How will you load dynamic assembly? How will create assesblies at run time?
  12. What is Reflection?
  13. If I have more than one version of one assemblies, then how will I use old version (how/where to specify version number?) in my application?
  14. How do you create threading in.NET? What is the namespace for that?
  15. What do you mean by Serialize and MarshalByRef?
  16. What is the difference between Array and LinkedList?
  17. What is Asynchronous call and how it can be implemented using delegates?
  18. How to create events for a control? What is custom events? How to create it?
  19. If you want to write your own dot net language, what steps you will you take care?
  20. Describe the diffeerence between inline and code behind - which is best in a loosely coupled solution?
  21. How dot net compiled code will become platform independent?
  22. Without modifying source code if we compile again, will it be generated MSIL again?
  23. How does you handle this COM components developed in other programming languages in.NET?
  24. How CCW (Com Callable Wrapper) and RCW (Runtime Callable Wrappers) works?
  25. What are the new thee features of COM+ services, which are not there in COM (MTS)?
  26. What are the differences between COM architecture and.NET architecture?
  27. Can we copy a COM dll to GAC folder?
  28. What is Shared and Repeatable Inheritance?
  29. Can you explain what inheritance is and an example of when you might use it?
  30. How can you write a class to restrict that only one object of this class can be created (Singleton class)?
  31. What are virtual destructures?
  32. What is close method? How its different from Finalize and Dispose?
  33. What is Boxing and UnBoxing?
  34. What is check/uncheck?
  35. What is the use of base keyword? Tell me a practical example for base keyword’s usage?
  36. What are the different.NET tools which you used in projects?
  37. What will do to avoid prior case?
  38. What happens when you try to update data in a dataset in.NET while the record is already deleted in SQL Server as backend?
  39. What is concurrency? How will you avoid concurrency when dealing with dataset?
  40. One user deleted one row after that another user through his dataset was trying to update same row. What will happen? How will you avoid this problem?
  41. How do you merge two datasets into the third dataset in a simple manner?
  42. If you are executing these statements in commandObject. “Select * from Table1; Select * from Table2″ How you will deal result set?
  43. How do you sort a dataset.
  44. If a dataset contains 100 rows, how to fetch rows between 5 and 15 only?
  45. What is the use of Parameter object?
  46. How to generateXML from a dataset and vice versa?
  47. How do you implement locking concept for dataset?
  48. How will you do Redo and Undo in TextBox control?
  49. How to implement DataGrid in.NET? How would you make a combo-box appear in one column of a DataGrid? What are the ways to show data grid inside a data grid for a master details type of tables? If we write any code for DataGrid methods. what is the access specifier used for that methods in the code behind file and why?
  50. How can we create Tree control in asp.NET?
  51. Write a program in C# to find the angle between the hours and minutes in a clock?
  52. Write a program to create a user control with name and surname as data members and login as method and also the code to call it.
  53. How can you read 3rd line from a text file?
  54. Explain the code behind wors and contrast that using the inline style.
  55. Explain different types of HTML, Web and server controls.
  56. What are the differences between user control and server control?
  57. How server form post-back works?
  58. Can the action attribute of a server-side
    tag be set to a value and if not how can you possibly pass data from a form page to a subsequent page?
  59. How would ASP and ASP.NET apps run at the same time on the same server?
  60. What are good ADO.NET object to replace to ADO Recordset object.
  61. Explain the differences between Server-side code and Client-side code.
  62. What type of code(server or client) is found in a Code-Behind class?
  63. Should validation (did the user enter a real date) occur server-side or client-side? Why?
  64. What does the “EnableViewState” property do? Why would I want it on or off?
  65. What is the difference between Server.Transfer and response.Redirect? Why?
  66. Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced.NET component?
  67. Let’s say I have an existing application written using VB6 and this application utilizes Windows 2000 COM+ transaction services. How would you approach migrating this application to.NET?
  68. If I am developing an application that must accomodate multiple security levels though secure login and my ASP.NET web application is spanned across three web-servers (using round-robin load balancing). What would be the best approach to maintain login-in state for the users?
  69. What are ASP.NET web forms? How is this technology different than what is available though ASP(1.0-3.0)?
  70. How does VB.NET achieve polymorphism?
  71. How does C# achieve polymorphism?
  72. Can you explain what is Inheritance and an example in VB.NET and C# of when you might use it?
  73. Describe difference between inline and code-behind?
  74. What is loosely coupled solution in.NET?
  75. What is diffgram?
  76. Where would you use an iHTTPModule and what are the limitations of any approach you might take in implementing one?
  77. What are the Advantages and DisAdvantages of viewstate?
  78. Describe session handling in a webform, how does it work and what are the limitations?
  79. How would you get ASP.NET running in Apache web servers? Explain it’s limitations.
  80. What is MSIL and why should my developers need an appreciation of it if at all?
  81. Which methos do you invoke on the DataAdapter control to load your generated dataset with data?
  82. Can you edit data in Repeater control? How?
  83. Which template must you provide, in order to display data in a Repeater control?
  84. How can you provide an alternating color scheme in a Repeater control?
  85. 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 repeater control?
  86. What base class do all web forms inherit from?
  87. What method do you use to explicitly kill a user’s session? How?
  88. How do you turn off cookies for one page in your site? Give an example.
  89. Which two properties are on every validation control?
  90. What tags do you need to add within the asp:datagrid tags to bind columns manually? Give an example.
  91. How do you create a permanent cookie?
  92. What tag do you use to add a hyperlink column to the dataGrid?
  93. What is the standard you use to wrap up a call to a Web Service?
  94. Which method do you use to redirect the user to another page without performing a round trip to the client? How?
  95. What is the transport protocol you use to call a Seb Service SOAP?
  96. What does WSDL stand for?
  97. What property do you have to set to tell the grid which page to go to when using the Pager object?
  98. Where on the Internet would you look for Web Services?
  99. What tags do you need to add within the asp:datagrid tags to bind columns manually? How?
  100. 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?
  101. How is a property designated as read-only?
  102. Which control would you use if you needed to make sure the values in two different controls matched?
Posted in: Interview Questions General | Tags: interview questions and answers questions interview answers q&a .net c# c sharp xml winform rectangular window menu designer docking anchor dock deploy specify namespace config