Thursday, December 17, 2015

.NET test answers of 2016

Find Complete and recently updated Correct Question and answers of .NET. All Answers updated regularly with new questions. Upwork .NET test answers of 2016.



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

Answer: • All of the given options are correct

Question:* In C#, a local variable ________.

Answer: • Is declared within a method

Question:* A delegate is _______.

Answer: • A class that encapsulates methods

Question:* In C#, use _______ to return a thread from a suspended state.

Answer: • Resume

Question:* A _______ block encloses code that could throw an exception.

Answer: • Try

Question:* In ASP.NET, what is the extension of a web user control file?

Answer: • .ascx

Question:* In C#, what does the following code create: String mystring;

Answer: • An object

Question:* An abstract class _______.

Answer: • All of these

Question:* In C#, a constructor ________.

Answer: • All of these

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

Answer: • Console.WriteLine( myArray[1][3] );

Question:* 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? <system.web> <authentication mode="Forms"> <forms loginUrl="login.aspx" /> </authentication> <authorization> <deny users="?" /> </authorization> </system.web>

Answer: • The web.config file

Question:* When an .aspx page is requested from the web server, the output is rendered to the browser in which format?

Answer: • html

Question:* The ASP.NET server control, which provides an alternative way of displaying text on web page, is:

Answer: • < asp:label >

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

Answer: • Webforms

Question:* Which of the following is not a component of .Net framework?

Answer: • JVM

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

Answer: • Yes

Question:* In the body of a method, C# uses the variable named ________ to refer to the current object whose method is being invoked.

Answer: • this

Question:* In C#, the following code measures time in _______. Thread.Sleep(time)

Answer: • Milliseconds

Question:* A Thread _______.

Answer: • Is an object that allows computer multitasking

Question:* In C#, what is the proper header for a class that intends to use an interface?

Answer: • class MyClass : Iface

Question:* In C#, a variable declared inside a method is called a _________ variable.

Answer: • Local

Question:* In C#, is it possible to pass methods as arguments for other methods without modification.

Answer: • True

Question:* In C#, defining two methods in single class with the same name but with different sets of argument types is called _______.

Answer: • Overloading

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

Answer: • All of these

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

Answer: • True

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

Answer: • Event-driven

Question:* The first event to be triggered in an .aspx page is:

Answer: • Page.Init

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

Answer: • Static

Question:* A String literal _______.

Answer: • Is a sequence of characters in double quotation marks

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

Answer: • True

Question:* String indexers treat strings as _______.

Answer: • Arrays of characters

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

Answer: • using

Question:* Exception objects are derived from the _______ class.

Answer: • Exception

Question:* Which of the following is a valid syntax of entry point of all C# programs?

Answer: • static void Main(string[] args)

Question:* Which of the following are part of ASP.NET?

Answer: • All answers are correct.

Question:* To be able to use following statement, which particular namespace has to be included in a C# program? Console.WriteLine("Hello World")

Answer: • System

Question:* Which of the following exception is thrown when a member/class lookup results in more than one member/class matching the lookup criteria?

Answer: • System.Reflection.AmbiguousMatchException

Question:* Synchronization means _______.

Answer: • Ensure that two concurrently-executing threads or processes do not execute specific portions of a program at the same time

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

Answer: • System.Diagnostics

Question:* An event is _______.

Answer: • The result of a user action

Question:* To create a string literal exclude escape sequence, use _______.

Answer: • @string

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

Answer: • Fill()

Question:* In ASP.NET, to what namespace does the Web page belong in the .NET Framework class hierarchy?

Answer: • System.web.UI.Page

Question:* What does the following code snippet imply : namespace TestApplication { class HelloWorld {} }

Answer: • TestApplication namespace contains the class HelloWorld

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

Answer: • To implement application and session level events

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

Answer: • GC.Collect()

Question:* Which caching type is supported by ASP.NET?

Answer: • Output caching and data caching

Question:* In ASP.NET, to add a custom control to a Web form you have to register with:

Answer: • All of these

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

Answer: • Creates the class Test that inherits the class Form

Question:* In C#, every class directly or indirectly extends the ________ class.

Answer: • Object

Question:* In ASP.NET, what control does not have any visible interface?

Answer: • Repeater

Question:* Your Web application, ABCWebApp1, is configured to use Windows Authentication. After granting a specific group NTFS permissions to access a specific file named ABC.doc, you need to ensure that users not belonging to this group cannot access the file. You should _______.

Answer: • Configure the Web.config file to include the <identity impersonate="true"/> element

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

Answer: • All of the given options are correct

Question:* How is ASP.NET different from classic ASP?

Answer: • Scripting is separated from the HTML, code is compiled as a DLL, and DLLs can be executed on the server

Question:* Which of the following is true about the following : for(;;) { Console.WriteLine("Testing for loop"); }

Answer: • It's an infinite loop

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

Answer: • Internal

Question:* To develop an application that meets the following requirements, you should consider using the _______ method. • A different ASPX page is displayed when the application's original URL is entered • After the page executes, the original URL is not visible to users • A single client browser request is sufficient for the execution of a page

Answer: • HttpContext.Current.RewritePath

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

Answer: • Throws

Question:* BCL stands for?

Answer: • Base Class Libraries

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

Answer: • 3

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

Answer: • All of these

Question:* The number of forms that can be added to a .aspx page is ________.

Answer: • 1

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

Answer: • ConcurrentDictionary

Question:* 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: <customErrors mode="On" defaultRedirect="ErrorPage.aspx" /> Next, you should consider _______.

Answer: • 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}

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

Answer: • System.Deployment

Question:* In C#, what code converts a string to lowercase?

Answer: • string.ToLower();

Question:* 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 _______.

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

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

Answer: • MSIL

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

Answer: • const <data_type> <constant_name> = value;

Question:* The ThreadPriority enumeration does not contain _______.

Answer: • ThreadPriority enumeration contains all of these.

Question:* In C#, two StringBuilder objects that contain the same string _______.

Answer: • Are two different objects

Question:* Your Web application has a master page with a static navigation menu. All content pages in the application use this master page, but may also substitute their own menu controls for those in the static navigation menu. After writing the following code, you should consider _______. Dim placeHolder As PlaceHolder = TryCast( _Page.Master.FindControl("MenuPlaceHolder"), PlaceHolder) Dim menuControl As New Menu() placeHolder.Controls.Add(menuControl)

Answer: • Adding the code segment to the Page_Load event of the content page

Question:* 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?

Answer: • <trace enabled="true" pageOutput="false" localOnly="true" />

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

Answer: • Add Src, Tagprefix, Tagname

Question:* In ASP.NET, IsPostBack is a ________.

Answer: • Read-only property of the System.Web.UI.Page class

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

Answer: • Optimized

Question:* 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?

Answer: • 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.ToByte(b));}fs.C

Question:* 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.

Answer: • INamingContainer

Question:* The String class and Char structure are found in the _______.

Answer: • System namespace

Question:* You create a Web page named enterDetails.aspx that includes a TextBox control named txtDetails. The enterDetails.aspx page cross-posts to another page, displayDetails.aspx, which includes a Label control named lblDetails. What code will ensure that text entered in the the txtDetails TextBox control is displayed by the lblDetails Label control?

Answer: • TextBox txtDetails = PreviousPage.FindControl("txtDetails") as TextBox; lblName.Text = txtDetails.Text;

Question:* 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 _______.

Answer: • 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

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

Answer: • Session.Abandon

Question:* Your Web form uses the following code to display data from a SQL Server 2005 database. What must you add to the _ItemBound event handler in order to access the value of the hlName HyperLink in a variable named var? <asp:RepeaterID="ABCRepeater" runat="server"DataSourceID="SqlDS1" ItemDataBound="_ItemBound"> <ItemTemplate><asp:Hyperlink ID="hlName" runat="server"Text='<%# Eval("ProdName") %> NavigateURL='<%# Eval("ProdURL") %>' /> </ItemTemplate></asp:Repeater>

Answer: • HyperLink var = e.Item.FindControl("hlName") as HyperLink;

Question:* Which of the following is not a VALID variable type in C#?

Answer: • Numeral

Question:* Your Web application contains the following class: public class Certs { public string Title {get; set;} public string Number { get; set; } public string Vendor { get; set; } } You store data in certData.xml with the following structure: <Certs> <title>cert title</title> <code>xx-xxx</code> <vendor>vendor name</vendor> </Certs> Which code segment will bind the data in certData.xml to the instance of List<Certs> named ABCCertsList?

Answer: • XmlSerializer xmlserial = new XmlSerializer(typeof(Certs));Certs cert = xmlserial.Deserialize(xmlStream) as Certs;ABCCertList.Text = cert.title();

Question:* Your Web application on IIS 6.0 includes OldPage.aspx. When a user tries to access OldPage.aspx, the browser should display the URL for OldPage.aspx, but open NewPage.aspx. Which code will accomplish this?

Answer: • Server.Transfer("NewPage.aspx");

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

Answer: • One of the constructors in the class A takes an argument of the type int

Question:* Your Web appplication, ABCApp1, is hosted on ABC-SR13 and runs an instance of MS SQL Server 2005 locally configured to use Windows Authentication. As you prepare to configure the role management and membership providers on ABC-SR13, you should consider using _______.

Answer: • The Aspnet_compiler.exe command and the aspnet_regiis.exe command

Question:* In ASP.NET, what is the difference between Response.Write() and Response.Output.Write()?

Answer: • Response.Output.Write() allows you to write formatted output

Question:* Concatenation of strings is done with _______.

Answer: • Operator overloading and method calls

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

Answer: • larger than 85KB OR Multidimensional arrays

Question:* Which of the following is NOT a valid GC Collection mode ?

Answer: • Parallel

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

Answer: • groupby

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

Answer: • Abort

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

Answer: • 032UU

Question:* The CLR allocates memory for new objects in which of the following Generation?

Answer: • Generation 0

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

Answer: • False

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

Answer: • System.Data

Question:* Your Web application contains an IHttpHandler interface named ABCHandler. To render the validationBitmap instance as a JPEG image as soon as ABCHandler is requested, what code segment should you add to ABCHandler?

Answer: • public void ProcessRequest(HttpContext context){Bitmap validationBitmap = (Bitmap)Session["ValidationImage"]; context.Response.ContentType = "image/jpeg"; validationBitmap.Save(context.Response.OutputStream, ImageFormat.Jpeg);}

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

Answer: • It searches for the first occurrence of any of the characters in the string

Question:* Which of the following is not a VALID floating point literal?

Answer: • 510E

Question:* Where is the default session data stored in ASP.NET?

Answer: • InProcess

Question:* Which of the following .Net framework class can be used for Custom Parallel Partitioning ?

Answer: • OrderablePartitioner<TSource>

Question:* Which of the following provides blocking and bounding capabilities for thread-safe collections?

Answer: • BlockingCollection<T> Class

Question:* Which of the following interrupts the thread, which contains wait, sleep or join state?

Answer: • Interrupt()

Question:* Your Web application should facilitate posting of user comments that must remain visible to all application users. Your code will make use of a SqlDataSource control named SqlDataSource1 and allow the IP address of every user who posts a comment to be captured. Which is the correct way to start your code?

Answer: • private void SaveComment(){ string ipaddr = null; ipaddr = Request.ServerVariables("REMOTE_ADDR").ToString(); SqlDataSource1.InsertParameters("IPAddress").DefaultValue = ipaddr; // ...

Question:* Which of the following property gets the current thread ?

Answer: • Thread.CurrentThread

Question:* In ASP.NET, what is the maximum number of cookies that can be allowed for a web site?

Answer: • 20

Question:* Your Web application must be reconfigured to include a new theme. To implement the theme in such a way that the theme settings take precedence over all individual control settings, you should consider _______.

Answer: • Setting the Theme attribute of the pages element to the name of the theme in the application's Web.config file

Question:* You must add a new custom control to an .aspx page in your Web application, with these requirements: • The state of the custom control must remain static for 2 minutes • The cache settings of other elements on the page must not be affected by the settings for the new custom control Which code will meet the requirements when added to the Web.configfile?

Answer: • <caching> <outputCacheSettings> <outputCacheProfiles> <addname="CachedProfileSet" varyByControl="controlname" duration="120" /> </outputCacheProfiles> </outputCacheSettings> </caching>

Question:* In C#, an instance method ________.

Answer: • Represents the behavior of an object

Question:* Which of the following methods is not a member of the ADODBCommand object?

Answer: • Open

Question:* In ASP.NET, which property of the session object is used to set the locale identifier?

Answer: • LCID

Question:* If A = 60, what will be the value of A >> 2 ?

Answer: • 0000 1111

Question:* Your Web application was developed on .NET 1.0 and uses MS IIS 6.0. It does not use any features of MS .NET Framework 3.5. To configure the Web application for .NET Framework 3.5 with as little administrative effort as possible, you should consider accessing _______ to modify the handler runtime version.

Answer: • MS IIS 6.0

Question:* Your Web application ABCApp1, uses MS .NET Framework 3.5. After retrieving the project code from your source control repository, you try to compile it on your workstation and find that the reference to the assembly is absent. You should access _______ to add a reference path that connects to the absent assembly.

Answer: • The project's property pages

Question:* A thread returning from a WaitSleepJoin or Suspended state returns to the _______.

Answer: • Started state (now considering a part of the running state)

Question:* Which of the following is not a valid built-in C# reference type?

Answer: • class

Question:* Which of the following methods causes a thread to wait the number of times defined by the iterations parameter?

Answer: • SpinWait

Question:* Which of the following Generation contains the longest surviving objects?

Answer: • Generation 2

Question:* In ASP.NET, which .DLL translates XML to SQL in IIS?

Answer: • SQLISAPI.dll

Question:* Your Web application should make use of ASP.NET AJAX. It will also be installed in abcdef.com's Web farm environment. To configure the SessionState of the new Web application before deployment, you should consider setting the mode attribute of the <sessionState> element to _______.

Answer: • SQLServer

Question:* When an unhandled exception occurs on products.aspx, your Web application should display an error page that contains the stack trace, and this page must be displayed only to remote users. You set the Page attribute for the products.aspx page to: <%@ Page Language="VB" AutoEventWireup="true" CodeFile="products.aspx.vb" Inherits="_products" ErrorPage="~/ABCApp/error.html" Debug="false" %> Which configuration should you use to the Web.config file?

Answer: • <customErrors mode="On" />

Question:* Which of the following is NOT a method in Thread class?

Answer: • public void Run()

Question:* Use the _______ methods to lock and unlock an object.

Answer: • Enter and Exit

Question:* In C#, an instance variable ________.

Answer: • Represents an attribute of an object

Question:* Methods that are declared abstract in the base class must show implementation at the time of declaration.

Answer: • False

Question:* Which of the following is not a valid state in the life cycle of a thread ?

Answer: • Started

Question:* In ASP.NET, there can be more than 1 machine.config file in a system.

Answer: • True

Question:* In ASP.NET, custom controls are derived from the ________ class.

Answer: • System.Web.UI.Customcontrols.Webcontrol

Question:* In ASP.NET, ________ are displayed correctly in the Visual Studio .NET Designer.

Answer: • Custom controls

Question:* 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 _______.

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

Question:* An event is often:

Answer: • The result of a user action

Question:* 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? <system.web> <authentication mode="Forms"> <forms loginUrl="login.aspx" /> </authentication> <authorization> <deny users="?" /> </authorization> </system.web>

Answer: • The web.config file

Question:* Your Web application, ABCWebApp1, is configured to use Windows Authentication. After granting a specific group NTFS permissions to access a specific file named ABC.doc, you need to ensure that users not belonging to this group cannot access the file. You should _______.

Answer: • Configure the Web.config file to include the <identity impersonate="true"/> element

Question:* What is the number of server forms that can be added to a .aspx page?

Answer: • 1

Question:* Which of the following is true about the following : for(;;) { Console.WriteLine("Testing for loop"); }

Answer: • It's an infinite loop

Question:* 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?

Answer: • <trace enabled="true" pageOutput="false" localOnly="true" />

Question:* 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 _______.

Answer: • 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

Question:* Your Web form uses the following code to display data from a SQL Server 2005 database. What must you add to the _ItemBound event handler in order to access the value of the hlName HyperLink in a variable named var? <asp:RepeaterID="ABCRepeater" runat="server"DataSourceID="SqlDS1" ItemDataBound="_ItemBound"> <ItemTemplate><asp:Hyperlink ID="hlName" runat="server"Text='<%# Eval("ProdName") %> NavigateURL='<%# Eval("ProdURL") %>' /> </ItemTemplate></asp:Repeater>

Answer: • HyperLink var = e.Item.FindControl("hlName") as HyperLink;

Question:* 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?

Answer: • 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(Conv

Question:* Your Web application on IIS 6.0 includes OldPage.aspx. When a user tries to access OldPage.aspx, the browser should display the URL for OldPage.aspx, but open NewPage.aspx. Which code will accomplish this?

Answer: • Server.Transfer("NewPage.aspx");

Question:* The following code is an example of: public class A { IEmailSender _emailSender public A(IEmailSender emailSender) { _emailSender = emailSender; } private void SendEmail() { _emailSender.Send(); } }

Answer: • Dependency Injection

Question:* Your Web application contains an IHttpHandler interface named ABCHandler. To render the validationBitmap instance as a JPEG image as soon as ABCHandler is requested, what code segment should you add to ABCHandler?

Answer: • public void ProcessRequest(HttpContext context){Bitmap validationBitmap = (Bitmap)Session["ValidationImage"]; context.Response.ContentType = "image/jpeg"; validationBitmap.Save(context.Response.OutputStream, ImageFormat.Jpeg);}

Question:* You must add a new custom control to an .aspx page in your Web application, with these requirements: • The state of the custom control must remain static for 2 minutes • The cache settings of other elements on the page must not be affected by the settings for the new custom control Which code will meet the requirements when added to the Web.configfile?

Answer: • <caching> <outputCacheSettings> <outputCacheProfiles> <addname="CachedProfileSet" varyByControl="controlname" duration="120" /> </outputCacheProfiles> </outputCacheSettings> </caching&gt

Question:* Your Web application must be reconfigured to include a new theme. To implement the theme in such a way that the theme settings take precedence over all individual control settings, you should consider _______.

Answer: • Setting the Theme attribute of the pages element to the name of the theme in the application's Web.config file

Question:* Your Web application should facilitate posting of user comments that must remain visible to all application users. Your code will make use of a SqlDataSource control named SqlDataSource1 and allow the IP address of every user who posts a comment to be captured. Which is the correct way to start your code?

Answer: • private void SaveComment(){ string ipaddr = null; ipaddr = Request.ServerVariables("REMOTE_ADDR").ToString(); SqlDataSource1.InsertParameters("IPAddress").DefaultValue = ipaddr; // ...

Question:* Your Web application ABCApp1, uses MS .NET Framework 3.5. After retrieving the project code from your source control repository, you try to compile it on your workstation and find that the reference to the assembly is absent. You should access _______ to add a reference path that connects to the absent assembly.

Answer: • The project's property pages

Question:* When an unhandled exception occurs on products.aspx, your Web application should display an error page that contains the stack trace, and this page must be displayed only to remote users. You set the Page attribute for the products.aspx page to: <%@ Page Language="VB" AutoEventWireup="true" CodeFile="products.aspx.vb" Inherits="_products" ErrorPage="~/ABCApp/error.html" Debug="false" %> Which configuration should you use to the Web.config file?

Answer: • <customErrors mode="On" />



No comments:

HTML5 Upwork (oDesk) TEST ANSWERS 2022

HTML5 Upwork (oDesk) TEST ANSWERS 2022 Question: Which of the following is the best method to detect HTML5 Canvas support in web br...

Disqus for upwork test answers