.NET MCQs

.NET MCQs

These .NET multiple-choice questions and their answers will help you strengthen your grip on the subject of .NET. You can prepare for an upcoming exam or job interview with these .NET MCQs.
So scroll down and start answering.

1: Your Web application lets users upload files and is hosted in Microsoft IIS 6.0 on a server named ABC-SR01. The application uses the default application pool with Windows Authentication. You cannot upload a file from your workstation using the application; instead, you see an access denied message. To fix this problem, you enable debugging. Next, you should _______.

A.   Create a Debugger Users group on your workstation and add your Windows user account to it

B.   Add your Windows user account to the Administrators group on ABC-SR01

C.   Stop and restart the application pool on ABC-SR01

D.   Add the following configuration to the Web.config file <identity impersonate="true" />

2: Which of the following kick in the Garbage Collector (GC) process?

A.   All of the given options are correct

B.   When GC.Collect method is invoked

C.   The total memory being used on the managed heap exceeds the acceptable threshold

D.   The system has low physical memory

3: Which of the following keywords is used to include existing namespace in a C# program?

A.   import

B.   using

C.   package

D.   namespace

4: True or false? In C#, a class can inherit from multiple interfaces.

A.   True

B.   False

5: Can you prevent your class from being inherited and become a base class for some other classes?

A.   No

B.   Yes

6: To configure authentication for your Web application so clients cannot access it anonymously, but access is allowed for users from untrusted domains, where should the following code be added to?

A.   The app.config file

B.   The web.config file

C.   The project's property pages

D.   The workstation's machine.config file

7: In ASP.NET, does EnableViewState allow the page to save user input on a form?

A.   Yes

B.   No

8: In ASP.NET, postback occurs in which of the following forms?

A.   Winforms

B.   HTMLForms

C.   Webforms

9: How do you manage states in an ASP.NET application?

A.   Viewstate

B.   Application objects

C.   All of these

D.   Session objects

10: Which C# code will output an element's value from a multidimensional array?

A.   Console.WriteLine( myArray(1),(3) );

B.   Console.WriteLine( myArray[1][3] );

C.   Console.WriteLine( myArray{1}{3} );

D.   Console.WriteLine( myArray[1.3] );

11: Which of the following is not a VALID C# access specifier ?

A.   Public

B.   Static

C.   Private

D.   Protected

12: A class declared with the sealed keyword cannot be a base class.

A.   False

B.   True

13: Which of the following are part of ASP.NET?

A.   Web Forms, MVC, and Web API

B.   All answers are correct.

C.   Web Forms and MVC.

D.   ASP.NET and MVC

E.   SignalR

14: What type of processing model does ASP.NET simulate?

A.   Top-down

B.   Linear

C.   Static

D.   Event-driven

15: Which of the following reasons make C# a widely used professional language?

A.   Structured language

B.   Object oriented

C.   All of the given options are correct

D.   Component oriented

16: Which of the following namespaces contain types that enable interaction with system processes, event logs, and performance counters?

A.   System.AddIn

B.   System.Diagnostics

C.   System.ComponentModel

D.   System.Data

17: Which namespace contain the types necessary to build Windows Communication Foundation (WCF) service and client applications?

A.   System.Web

B.   System.ServiceModel

C.   System.Net

D.   System.Messaging

18: Which of the following would force an immediate garbage collection of all generations?

A.   GCCollect()

B.   GC.Garbage()

C.   GC.Force()

D.   GC.Collect()

19: In ASP.NET, why is Global.asax used?

A.   To implement application and session level events

B.   Neither of these

C.   To declare Global variables

20: Which caching type is supported by ASP.NET?

A.   Output caching

B.   Data caching

C.   Output caching and data caching

D.   None of these

21: In ASP.NET, which method do you invoke on the Data Adapter control to load your generated dataset?

A.   Read( )

B.   Fill()

C.   ExecuteQuery( )

22: In C#, what does the following code do: class Test: Form { }

A.   Creates the class Test : Form and creates the class Test that inherits the class Form

B.   Creates the class Form that inherits the class Test

C.   Creates the class Test : Form

D.   Creates the class Test that inherits the class Form

23: Which of the following represents a thread-safe map of key/value pair and can be used in a multi-threaded environment?

A.   ConcurrentBag

B.   BlockingCollection

C.   ConcurrentDictionary

D.   ConcurrentQueue

24: How is ASP.NET different from classic ASP?

A.   Scripting is separated from the HTML, and code is interpreted separately

B.   Scripting is separated from the HTML, code is compiled as a DLL, and DLLs can be executed on the server

C.   Code is separated from the HTML, and interpreted code is interpreted separately

25: How many generations does Garbage Collector use for Small Objects in .Net?

A.   6

B.   4

C.   5

D.   3

26: Which of the following "type" of members are accessible only within files in the same DLL ?

A.   Private

B.   Internal

C.   Protected

27: When do you have to declare a class abstract?

A.   When all methods in the class are abstract.

B.   When at least one of the methods in the class is abstract.

C.   When at least one of the methods in the class is declared.

28: A method _______ an exception when that method detects that a problem has occured.

A.   Catches

B.   Throws

C.   Trys

D.   Trys and Catches

29: Which of the following is the actual .net code translated into?

A.   MSIL

B.   CLR

C.   CTS

D.   CLS

30: Which of the following is a valid C# constant definition?

A.   constant <data_type> <constant_name> = value;

B.   const <data_type> <constant_name> = value;

C.   final <data_type> <constant_name> = value;

D.   (all of these)

31: In .net, can a class inherit from several classes

A.   True

B.   False

32: To ensure that the timing and performance data of your web application is gathered and only made available to users when they are logged on the web server, which code should you add to the Web.config file?

A.   <compilation debug="true" urlLinePragmas="false"> ... </compilation>

B.   <trace enabled="false" pageOutput="true" localOnly="false" />

C.   <trace enabled="true" pageOutput="false" localOnly="true" />

D.   <compilation debug="false" urlLinePragmas="true"> ... </compilation>

33: Which of the following namespaces contain types that support deployment of ClickOnce applications?

A.   System.Data

B.   System.Deployment

C.   System.Configuration

D.   System.ComponentModel

34: In which of the following GC Collection mode the garbage collector determines whether the current time is optimal to reclaim objects?

A.   Forced

B.   Parallel

C.   Concurrent

D.   Optimized

35: While browsing your Web application in IIS 6.0, you receive a Server Application Unavailable error. The application event log states: It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process. To solve this problem as quickly as possible, you should _______.

A.   Change the IIS isolation mode and restart the application pool that hosts the application

B.   Assign the application to a new application pool and configure all applications that are part of your application's application pool to use the same version of ASP.NET

C.   Assign the application to a new application pool and run the Aspnet_regiis.exe tool

D.   Change the IIS isolation mode and assign the application to a new application pool

36: In ASP.NET, how do you register a user control?

A.   Add Tag prefix, Tag name

B.   Add Source, Tag prefix

C.   Add Src, Tagprefix, Tagname

37: In C#, for a class to use an interface, it must _______.

A.   Create an interface object

B.   Inherit the properties of the interface

C.   Contain the same methods as the interface

D.   All of these

38: If an IndexofAny method is passed an array of characters, _______.

A.   It finds the first occurrence of each letter in the string

B.   It generates an error

C.   It searches for the first occurrence of the sequence of characters

D.   It searches for the first occurrence of any of the characters in the string

39: Your Web application includes a page named ErrorPage.aspx. To manage unhandled application exceptions, ErrorPage.aspx should be shown and exception data should be written to the event log. Your web.config file includes the following code: Next, you should consider _______.

A.   Adding this code to the Default.asax file: void Application_Error(object sender, EventArgs e){Exception exc = Server.GetLastError();//Write Exception details to event log}

B.   Adding this code to the Global.asax file: void Application_Error(object sender, EventArgs e){Exception exc = Server.GetLastError();//Write Exception details to event log}

C.   Adding this code to the ErrorPage.aspx file: void Page_Error(object sender, EventArgs e){Exception exc = Server.GetLastError();//Write Exception details to event log Server.ClearError();}

D.   Adding this code to the master page: void Application_Error(object sender, EventArgs e){Exception exc = Server.GetLastError();//Write Exception details to event log}

40: In your Web application, you create a class to implement the IHttpHandler interface. Which code will display the Warning.jpg image in the browser whenever the handler is requested?

A.   public void ProcessRequest(HttpContext ctx){StreamReader sr = new StreamReader(OpenRead(ctx.Server.MapPath("Warning.jpg")));ctx.Response.Pics("pic ");sr.Close();}

B.   public void ProcessRequest(HttpContext ctx){StreamReader sr = new StreamReader(_File.OpenRead(ctx.Server.MapPath("Warning.jpg")));ctx.Response(sr.ReadToEnd());}

C.   public void ProcessRequest(HttpContext ctx){ctx.Response.ContentType = "image/jpg";FileStream fs = File.OpenRead(_ctx.Server.MapPath("Warning.jpg"));int b = 0;while ((b == fs.ReadByte()) != -1) {ctx.Response.OutputStream.WriteByte(Convert.

D.   public void ProcessRequest(HttpContext ctx){ctx.Response.TransmitFile("image/jpg");(_ctx.Server.MapPath("Warning.jpg"));Stream b = default(Stream);while ((b == fs.ReadByte()) != -1) {ctx.Response.Output.Write((b));}Fs.Close();}

A.   HyperLink var = e.Item.Parent.FindControl("hlName") as HyperLink;

B.   HyperLink var = rptData.FindControl("hlName") as HyperLink;

C.   HyperLink var = Page.FindControl("hlName") as HyperLink;

D.   HyperLink var = e.Item.FindControl("hlName") as HyperLink;

42: All methods in an abstract base class must be declared abstract.

A.   True

B.   False

43: In your Web application named ABCWebApp1, you have configured a custom-templated server control named ABCSC that has child controls in the page. To help ensure distinctive identification of the child controls within the hierarchy of the page, you should consider applying the _______ interface.

A.   IDisposable

B.   INamingContainer

C.   IBindableTemplate

D.   GCNotificationStatus Enumeration

44: Evaluate. Which statement must be true for the code to compile and run correctly? public class B : A { public B(int i) :base(i) { } }

A.   One of the constructors in the class A takes an argument of the type int

B.   One of the constructors in the class A takes an argument of the type I, and the class has only a default constructor

C.   One of the constructors in the class A takes an argument of the type i

D.   Class A has only a default constructor

45: Which of the following methods is used for destroying threads?

A.   Abort

B.   Stop

C.   Kill

D.   Destroy

46: How does the .Net framework define a Large Object?

A.   larger than 185KB

B.   Multidimensional arrays

C.   larger than 85KB OR Multidimensional arrays

D.   larger than 85KB

47: Which of the following is NOT a reserved keyword in C#?

A.   groupby

B.   descending

C.   ascending

D.   orderby

48: In ASP.NET, how do you explicitly kill a user session?

A.   Session.Discard( )

B.   Session.Close( )

C.   Session.Abandon

D.   Session.End

49: In ASP.NET, which one of the following namespaces contains the definition for IdbConnection?

A.   System.Data.Common

B.   System.Data

C.   System.Data.Connection

D.   System.Data.Interfaces

50: Which of the following is not a VALID integer literal?

A.   30u

B.   30ul

C.   032UU

D.   0x4b