Elance .NET Test Answers 2015



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?
<trace enabled="true" pageOutput="false" localOnly="true" />
<compilation debug="true" urlLinePragmas="false"> ... </compilation>
<compilation debug="false" urlLinePragmas="true"> ... </compilation>
<trace enabled="false" pageOutput="true" localOnly="false" />


In C#, use _______ to return a thread from a suspended state.
Resume
Restart
Pulse
Interrupt


A _______ block encloses code that could throw an exception.
Exception
Catch
Try
Error


Which of the following exception is thrown when a member/class lookup results in more than one member/class matching the lookup criteria?
AppDomain.UnhandledException
FormatException
System.Reflection.AmbiguousMatchException
FileNotFoundException


Which of the following are part of ASP.NET?
SignalR
ASP.NET and MVC
Web Forms and MVC.
All answers are correct.
Web Forms, MVC, and Web API


In C#, is it possible to pass methods as arguments for other methods without modification.
False
True


Which of the following is not a VALID C# access specifier ?
Static
Private
Protected
Public


Which of the following reasons make C# a widely used professional language?
All of the given options are correct
Component oriented
Object oriented
Structured language


Which of the following namespaces contain types that enable interaction with system processes, event logs, and performance counters?
System.Diagnostics
System.Data
System.ComponentModel
System.AddIn


Which of the following would force an immediate garbage collection of all generations?
GC.Collect()
GC.Garbage()
GC.Force()
GCCollect()


What does the following code snippet imply : namespace TestApplication { class HelloWorld {} }
TestApplication class contains the namespace HelloWorld
TestApplication namespace contains the class HelloWorld
Compilation error
TestApplication class contains the class HelloWorld


In ASP.NET, what is the extension of a web user control file?
.ascx
.aspx
.asmx
.ashx


Which caching type is supported by ASP.NET?
None of these
Output caching and data caching
Data caching
Output caching


In C#, what does the following code do: class Test: Form { }
Creates the class Test : Form
Creates the class Test that inherits the class Form
Creates the class Form that inherits the class Test
Creates the class Test : Form and creates the class Test that inherits the class Form


In ASP.NET, to what namespace does the Web page belong in the .NET Framework class hierarchy?
System.Web.page
System.web.UI.Page
System.Windows.Page


In ASP.NET, which method do you invoke on the Data Adapter control to load your generated dataset?
ExecuteQuery( )
Read( )
Fill()


Synchronization means _______.
Delay a thread until there is sufficient memory and work to keep it up
Make every thread start and end at the same time
Make every thread do the same thing
Ensure that two concurrently-executing threads or processes do not execute specific portions of a program at the same time


To create a string literal exclude escape sequence, use _______.
!string
#string
@string
$string


String indexers treat strings as _______.
Binary code
Arrays of characters
A character
1 to string length


In ASP.NET, why is Global.asax used?
To implement application and session level events
To declare Global variables
Neither of these


An event is _______.
Code used to force a user action
The result of a party
Not an object type
The result of a user action


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


In C#, what does the following code create: String mystring;
A class
A constructor
An object
A class and a constructor


Exception objects are derived from the _______ class.
Event
Catch
System
Exception


Which of the following is a valid syntax of entry point of all C# programs?
static Main(string args)
Static void Main(string[] args)
static Main(string[] args)
static void Main(string[] args)


Which of the following keywords is used to include existing namespace in a C# program?
namespace
package
import
using


A String literal _______.
Is a sequence of characters in double quotation marks
Contains numbers rather than letters
Contains exactly its variable name and nothing else
Contains only one character


The first event to be triggered in an .aspx page is:
Page.PreRender
Page.Load
Page.Init


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


What type of processing model does ASP.NET simulate?
Static
Linear
Event-driven
Top-down


A class declared with the sealed keyword cannot be a base class.
True
False


An abstract class _______.
May contain constructors
All of these
May contain instance variables
May extend another class


How do you manage states in an ASP.NET application?
All of these
Application objects
Viewstate
Session objects


In C#, defining two methods in single class with the same name but with different sets of argument types is called _______.
Multiplexing
Overriding
Duplexing
Overloading


In C#, a variable declared inside a method is called a _________ variable.
Local
Serial
Private
Static


A Thread _______.
Is a deprecated object that is no longer used
Is an object that wraps itself with other threads
Is an object that allows computer multitasking
Does not exist


In C#, a constructor ________.
All of these
Must have the same name as the class it is declared within
May be overloaded
Is used to create objects


In ASP.NET, to add a custom control to a Web form you have to register with:
TagPrefix
All of these
The namespace of the .dll that is referenced
Assemblyname


Which of the following kick in the Garbage Collector (GC) process?
The system has low physical memory
When GC.Collect method is invoked
The total memory being used on the managed heap exceeds the acceptable threshold
All of the given options are correct


In ASP.NET, what control does not have any visible interface?
Datalist
Datagrid
Repeater
DropdownList


How is ASP.NET different from classic ASP?
Code is separated from the HTML, and interpreted code is interpreted separately
Scripting is separated from the HTML, code is compiled as a DLL, and DLLs can be executed on the server
Scripting is separated from the HTML, and code is interpreted separately


Which of the following is true about the following : for(;;) { Console.WriteLine("Testing for loop"); }
"Testing for loop" will get printed twice
Compilation error
It's an infinite loop
"Testing for loop" will get printed once


In C#, every class directly or indirectly extends the ________ class.
Console
Object
Drawing
System


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 _______.
Configure the app.config file to include the <authentication mode="[None]"> element
Configure the machine.config file to include the <authentication mode="[None]"> element
Configure the machine.config file to include the <identity impersonate="true"/> element
Configure the Web.config file to include the <identity impersonate="true"/> element


Which of the following "type" of members are accessible only within files in the same DLL ?
Protected
Private
Internal


In C#, what is the proper header for a class that intends to use an interface?
class MyClass ; Iface
class MyClass Iface
class MyClass : Iface
class MyClass {IFace}


In C#, the following code measures time in _______. Thread.Sleep(time)
Milliseconds
Nanoseconds
Minutes
Seconds


BCL stands for?
Bass Class Language
Binary Class Language
Base Class Language
Binary Common Libraries
Base Class Libraries


In the body of a method, C# uses the variable named ________ to refer to the current object whose method is being invoked.
do
call
that
this


Which C# code will output an element's value from a multidimensional array?
Console.WriteLine( myArray{1}{3} );
Console.WriteLine( myArray[1][3] );
Console.WriteLine( myArray[1.3] );
Console.WriteLine( myArray(1),(3) );


In ASP.NET, postback occurs in which of the following forms?
Winforms
Webforms
HTMLForms


Which of the following is not a component of .Net framework?
Common Language Specification
Metadata and Assemblies
JVM
Windows Forms


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


The ASP.NET server control, which provides an alternative way of displaying text on web page, is:
< asp:listitem >
< asp:label >
< asp:button >


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>
The app.config file
The workstation's machine.config file
The web.config file
The project's property pages


When an .aspx page is requested from the web server, the output is rendered to the browser in which format?
html
wml
jsp
txt


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
HttpContext.Current.ToString
HttpContext.Current.RewritePath
HttpContext.Current.GetType
HttpContext.Current.RemapHandler


The number of forms that can be added to a .aspx page is ________.
3
More than 3
2
1


In C#, for a class to use an interface, it must _______.
Create an interface object
All of these
Inherit the properties of the interface
Contain the same methods as the interface


How many generations does Garbage Collector use for Small Objects in .Net?
4
6
3
5


Which of the following namespaces contain types that support deployment of ClickOnce applications?
System.Deployment
System.Data
System.Configuration
System.ComponentModel


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 _______.
Add your Windows user account to the Administrators group on ABC-SR01
Stop and restart the application pool on ABC-SR01
Add the following configuration to the Web.config file <identity impersonate="true" />
Create a Debugger Users group on your workstation and add your Windows user account to it


A method _______ an exception when that method detects that a problem has occured.
Trys
Throws
Catches
Trys and Catches


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 _______.
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();}

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}

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}

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


The ThreadPriority enumeration does not contain _______.
Belownormal
Highest
Lowest
ThreadPriority enumeration contains all of these.


Which of the following is a valid C# constant definition?
final <data_type> <constant_name> = value;
(all of these)
const <data_type> <constant_name> = value;
constant <data_type> <constant_name> = value;


Which of the following represents a thread-safe map of key/value pair and can be used in a multi-threaded environment?
ConcurrentBag
ConcurrentQueue
ConcurrentDictionary
BlockingCollection


A delegate is _______.
A class that encapsulates methods
A Washington representative
A substitue for an inherited method
A means of passing arrays into methods


In C#, what code converts a string to lowercase?
string.ToLower(string);
string.ToLower();
String = string.ToLower(string);
ToLower(string);


Which of the following is the actual .net code translated into?
MSIL
CLS
CTS
CLR


In ASP.NET, IsPostBack is a ________.
Method of the System.Web.UI.Page class
Read-only property of the System.Web.UI.Page class
Method of the System.UI.Web.Page class


In C#, two StringBuilder objects that contain the same string _______.
All of these
Are two different objects
Represent the same memory location
Are both changed when a change is made to either


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)
Adding the code segment to the default page
Adding the code segment directly to the content page
Adding the code segment to the Page_Load event of the content page
Adding the code segment to the master page


In ASP.NET, how do you register a user control?
Add Source, Tag prefix
Add Src, Tagprefix, Tagname
Add Tag prefix, Tag name


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?
public void ProcessRequest(HttpContext ctx){StreamReader sr = new StreamReader(OpenRead(ctx.Server.MapPath("Warning.jpg")));ctx.Response.Pics("pic ");sr.Close();}

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

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();}

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.Close();}


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.
INamingContainer
IBindableTemplate
IDisposable
GCNotificationStatus Enumeration


In which of the following GC Collection mode the garbage collector determines whether the current time is optimal to reclaim objects?
Concurrent
Parallel
Forced
Optimized

In ASP.NET, how do you explicitly kill a user session?
Session.End
Session.Discard( )
Session.Abandon
Session.Close( )


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?
TextBox txtDetails = PreviousPage.FindControl("txtDetails") as TextBox; lblName.Text = txtDetails.Text;

TextBox txtDetails = NextPage.FindControl("txtDetails") as TextBox; lblName.Text = txtDetails.Text;

TextBox txtDetails = PreviousPage.FindControl("txtDetails") as lblDetails; lblName.Text = lblDetails.Text;

TextBox txtDetails = FindControl("txtDetails") as lblDetails;lblName.Text = lblDetails.Text;


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 _______.
Change the IIS isolation mode and restart the application pool that hosts the application
Assign the application to a new application pool and run the Aspnet_regiis.exe tool
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
Change the IIS isolation mode and assign the application to a new application pool


The String class and Char structure are found in the _______.
System.Text namespace
System.Chars namespace
System.Strings namespace
System namespace


Which of the following is not a VALID variable type in C#?
Numeral
Value
Reference
Pointer


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>
HyperLink var = e.Item.FindControl("hlName") as HyperLink;
HyperLink var = e.Item.Parent.FindControl("hlName") as HyperLink;
HyperLink var = Page.FindControl("hlName") as HyperLink;
HyperLink var = rptData.FindControl("hlName") as HyperLink;


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?
Server.Transfer("NewPage.aspx");
Server.MapPath("NewPage.aspx");
Server.Execute("NewPage.aspx");
Response.Redirect("NewPage.aspx");


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 _______.
The ASP.NET SQL Server registration tool
The Aspnet_merge.exe command
The Aspnet_compiler.exe command and the aspnet_regiis.exe command
The Aspnet_compiler.exe command


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?
certData.DataSource = ABCCertList;certData.DataValueField = "Certs.title";certData.DataBind();

XmlReader xmlread = XmlReader.Create(xmlStream);Certs cert = xmlread.ReadContentAs(typeof(Certs),null) as Certs;ABCCertList.Text = cert.title();

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

certData.DataSource = ABCCertList;certData.DataTextField = "title";certData.DataBind();


Concatenation of strings is done with _______.
Reserved words
Operator overloading
Method calls
Operator overloading and method calls


Evaluate. Which statement must be true for the code to compile and run correctly? public class B : A { public B(int i) :base(i) { } }
One of the constructors in the class A takes an argument of the type I, and the class has only a default constructor
One of the constructors in the class A takes an argument of the type int
One of the constructors in the class A takes an argument of the type i
Class A has only a default constructor


How does the .Net framework define a Large Object?
larger than 85KB
larger than 85KB OR Multidimensional arrays
Multidimensional arrays
larger than 185KB


In ASP.NET, what is the difference between Response.Write() and Response.Output.Write()?
Response.Output.Write() allows you to buffer output
Response.Output.Write() allows you to write formatted output
Response.Output.Write() allows you to flush output
Response.Output.Write() allows you to stream output


Which of the following is NOT a reserved keyword in C#?
ascending
descending
orderby
groupby


All methods in an abstract base class must be declared abstract.
False
True


Which of the following is NOT a valid GC Collection mode ?
Optimized
Parallel
Forced
Default


The CLR allocates memory for new objects in which of the following Generation?
Generation 0
Generation 1
Generation 3
Generation 2


In ASP.NET, which one of the following namespaces contains the definition for IdbConnection?
System.Data
System.Data.Connection
System.Data.Common
System.Data.Interfaces


Which of the following is not a VALID integer literal?
032UU
30u
0x4b
30ul


Which of the following methods is used for destroying threads?
Abort
Kill
Stop
Destroy


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?

public void ProcessRequest(HttpContext context){Bitmap validationBitmap = (Bitmap)Session["ValidationImage"]; context.Response.ContentType = "image/jpeg"; context.Response.Write(validationBitmap);}

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

public void ProcessRequest(HttpContext context){Bitmap validationBitmap = (Bitmap)Session["ValidationImage"]; context.Response.ContentType = "image/jpeg"; context.Response.Write(validationBitmap.RawFormat);}

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


If an IndexofAny method is passed an array of characters, _______.
It searches for the first occurrence of the sequence of characters
It generates an error
It searches for the first occurrence of any of the characters in the string
It finds the first occurrence of each letter in the string


Which of the following is not a VALID floating point literal?
2.74
3.14159
510E
314159E-5L


Where is the default session data stored in ASP.NET?
All of these
StateServer
Session Object
InProcess


Which of the following interrupts the thread, which contains wait, sleep or join state?
Yield()
Interrupt()
Abort()
Join()


Which of the following .Net framework class can be used for Custom Parallel Partitioning ?
BlockingCollection<T> Class
ConcurrentBag<T>
OrderablePartitioner<TSource>
ConcurrentQueue<T>


Which of the following provides blocking and bounding capabilities for thread-safe collections?
ConcurrentBag<T>
ConcurrentQueue<T>
BlockingCollection<T> Class
ConcurrentDictionary<TKey, TValue>


Which of the following property gets the current thread ?
this.CurrentThread
Thread.CurrentThread
Thread.Thread
Thread.Current


In ASP.NET, what is the maximum number of cookies that can be allowed for a web site?
10
1
More than 30
20


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?
private void SaveComment(){ string ipaddr = null; ipaddr = Request.ServerVariables("REMOTE_ADDR").ToString(); SqlDataSource1.InsertParameters("IPAddress").DefaultValue = ipaddr; // ...

private void SaveComment(){ string ipaddr = null; ipaddr = Request.ServerVariables("REMOTE_ADDR").ToString(); SqlDataSource1.Insert(); // ...

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

private void SaveComment(){ string ipaddr = null; ipaddr = Request.ServerVariables("REMOTE_ADDR").ToString(); // ...


In C#, an instance method ________.
Represents the attributes of an object
Represents another class
Represents both the behavior and attributes of an object
Represents the behavior of an object


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 _______.

Setting the Theme attribute of the pages element to the name of the theme in the application's App.config file

Creating a default page for the application and setting the Theme attribute to the name of the theme in the @Default directive

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

Creating a master page for the application and setting the Theme attribute to the name of the theme in the @Master directive


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?

<caching> <outputCacheSettings> <outputCacheProfiles> <ProfileCache profile="CachedProfileSet" varyByControl="CachedControl" duration="2"> </ProfileCache> </outputCacheProfiles> </outputCacheSettings> </caching>

<caching> <outputCacheSettings> <outputCacheProfiles> <addname="CachedProfileSet" varyByParam="CachedControl" duration="2" /> </outputCacheProfiles> </outputCacheSettings> </caching>

<caching> <outputCacheSettings> <outputCacheProfiles> <ProfileCache profile="CachedProfileSet" varyByControl="CachedControl" duration="120"> </ProfileCache> </outputCacheProfiles> </outputCacheSettings> </caching>

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


Which of the following methods is not a member of the ADODBCommand object?
ExecuteReader
ExecuteScalar
ExecuteStream
Open