C# MCQ Questions and Answers
1. Which of the following is used to maintain data across users?
Answer: a) LinkCounter
2. What object is used to store data that needs to be preserved across multiple sessions and users?
Answer: a) Application Object
3. Which property of validation control is used to set the control to validate?
Answer: b) ControlToValidate
4. Which directive is used to include assembly in ASP.NET page?
Answer: c) @Assembly
5. Which method is used to redraw the control?
Answer: c) Paint
6. Which control is used to display data in tabular format?
Answer: b) GridView
7. Which event is raised first during page life cycle?
Answer: b) Page_Init
8. Which attribute must be set to make a control server-side?
Answer: b) runat="server"
9. Which object is used to collect form data from client side?
Answer: b) Response.Form()
10. Which validator checks whether entered value matches a pattern?
Answer: c) CompareValidator
11. Which object is used to store data in-memory representation?
Answer: b) DataSet
12. Which is not a state management technique?
Answer: c) State
13. Which method returns a single value from the database?
Answer: a) ExecuteScalar()
14. ASP.NET page is derived from which class?
Answer: a) System.Web.UI.Page
15. Which of the following can be used for client-side state management?
Answer: d) All of these
16. Which validator is used to match pattern?
Answer: b) RegularExpressionValidator
17. Which control is used to display text?
Answer: b) asp:label
18. Which object is used to get the query string?
Answer: d) Request Object
19. How can you skip validation on a button click?
Answer: a) set CausesValidation=false
20. Which is true for Session?
Answer: c) Both (a) and (b)
21. Which property is used to manually define columns in GridView?
Answer: a) AutoGenerateColumns=false
22. Which method is used to populate a DataSet?
Answer: b) Fill()
23. What are basic building blocks of Web Forms?
Answer: a) HTML
24. Which directive is used to define a master page?
Answer: b) <%@ Master %>
25. Which is correct method to transfer control in ASP.NET?
Answer: c) Server.Redirect("SomePage.aspx");
26. Which namespace is used for SQL Server data access?
Answer: a) System.data.sqlclient
27. Which property is used to check if a page is loaded for first time or not?
Answer: d) IsPostBack
28. Which of the following is not a server-side control?
Answer: c) <input type='button'>
29. Which method is used to end the current user session?
Answer: b) Session.Abandon()
30. What is the extension of ASP.NET Web Forms?
Answer: a) .aspx
31. Which object is used to retrieve form values from a previous page?
Answer: a) PreviousPage
32. Which event occurs when a server control is loaded into the Page object?
Answer: c) Init
33. What is the default authentication mode in ASP.NET?
Answer: b) Windows
34. Which method is used to bind data to a GridView?
Answer: d) DataBind()
35. Which of the following is used to cache an entire page?
Answer: a) @OutputCache
36. How to apply themes in ASP.NET?
Answer: b) <pages theme='ThemeName' />
37. What are user controls?
Answer: a) Reusable page fragments
38. Which file contains configuration settings for the application?
Answer: c) Web.config
39. What is the purpose of Global.asax?
Answer: b) Handle application-level events
40. Which language is not supported by ASP.NET?
Answer: d) Java