ASP.NET Interview Questions and Answers (1544) - Page 46

Validation Controls in Asp.Net are available in which namespace ?

NOTE: This is objective type question, Please click question title for correct answer.
Which is the base class of all validation controls in asp.net ?

BaseValidator is a part of the class library namespace.

System.Web.UI.WebControls.BaseValidator exposes a series of properties and methods that are common to all the validation controls.
What are the two different types of remote object creation mode in .NET ?

There are two different ways in which object can be created using Remoting. They are:
• SAO (Server Activated Objects) also called as Well-Known call mode.
• CAO (Client Activated Objects)
SAO has two modes “Single Call” and “Singleton”.
With Single Call object, the object is created with every method call thus making the object stateless.
With Singleton, the object is created only once and the object is shared with all clients.
CAO are stateful as compared to SAO. In CAO, the creation request is sent from client side. Client holds a proxy to the server object created on server.
Is Session_End event supported in all session modes?

Session_End event occurs only in “Inproc mode”.
“State Server” and “SQL SERVER” do not have Session_End event.
What is the ideal size of a cookie ?

Web browsers must support a minimum of :

•300 cookies in total
•20 cookies per domain
•4096 bytes per cookie

The "official" maximum size of a cookie is 4KB.
What are the drawbacks of collections in .net ?

The drawbacks of collections in .net are:

1. Performance will be low as they store each and every member as an object
2. Incorrect parsing throws runtime "Invalid Cast" exception
Examples of System.Collections: Array List, Hash Table, Stack, Queue
Note: System.Collections.Generic came up in .NET 2.0 to overcome the drawbacks of collections.
Can an object be instantiated using const keyword?

No, we cannot instantiate an object using const keyword.
Only possible constant reference types are string and null.

Example:


const int x = 0;
public const double gravitationalConstant = 6.673e-11;
private const string productName = "Visual C#";

How do you split a string based on a character without using string.split function ?

You can split a string based on a character by the following way:
System.Text.RegularExpressions namespace have to be imported to use Regex.Split() method.

Example:

using System;

using System.Text.RegularExpressions;

class Program
{
static void Main()
{
//
// String containing numbers.
//
string sentence = "10 cats, 20 dogs, 40 fish and 1 programmer.";
//
// Get all digit sequence as strings.
//
string[] digits = Regex.Split(sentence, @"\D+");
//
// Now we have each number string.
//
foreach (string value in digits)
{
//
// Parse the value to get the number.
//
int number;
if (int.TryParse(value, out number))
{
Console.WriteLine(value);
}
}
}
}

Output

10
20
40
1

In what instances you will declare a constructor to be private ?

When we create a private constructor, we cannot create object of the class directly from a client. Therefore, you will use private constructors when you do not want instances of the class to be created by any external client.
Do interface have accessibility modifier ?

All elements in Interface should be public. Therefore, by default all interface elements are public and abstract by default.

Example:


interface IExample{
public void funExample(); //Error: The modifier 'public' is not valid for this item.
string fun2(string strParam1, string strParam2);//no error
}

What are the differences between const and readonly keywords ?

The major differences between both the keywords are listed below:

'const':
-cannot be static
-value is evaluated at compile time
-initialized at compile time only

'readonly':
-can't be either instance level or static
-value is evaluated at compile time
-can be initialized in declaration or by code in the constructor
Is c# support Multiple Inheritance?

NOTE: This is objective type question, Please click question title for correct answer.
What is the Difference between Int and Int32 ?

Int32 is the alias of Int the only difference of the storage data bit .
What is ELMAH ?

ELMAH stand for Error Logging Modules and Handlers is an application-wide error logging facility. It can be dynamically added to a running .NET web application, or even all .NET web applications without any need for re-compilation or re-deployment.

Is used to log unhandled exceptions to the file system, event log, databases or even have it email you the errors.
Define two important properties and methods and events of datagrid?

DataSource is the property of datagrid to give source name like dataset or datatable.
and DataBind is the method to bind datagrid.

Example:

gridview.DataSource = ds; //ds is the dataset and filled with some data.

gridview.DataBind();

What is the difference between properties and methods?

Properties are used to represent data, whereas methods are used to performs actions.

Properties are created by using getter and setter. get{} and set{} but methods create like public void method1(parameter list here)
Data Pager control in ASP.Net can be used with which of the following controls?

NOTE: This is objective type question, Please click question title for correct answer.
What is meant by CCW ?

CCW is known as COM Callable Wrapper.
The CLR will create a wrapper i.e, CCW, to enable theCOM components which are used to access .NET objects.
What is meant by MIME ?

The definition of MIME is Multipurpose Internet Mail Extensions.
This is used to include various types of contents in a single message.It is a standard form.To include multiple content, this MIME extends the Simple Mail Transfer Protocol (SMTP) format of mail messages.They can be of textual or non-textual.These messages can also include images, audio, or text in different character sets.
Explain about Passport Authentication..

It is based on the passport website.This Passport website is provided by Microsoft.
When the user logins, the authentication will be done on the passport website(Ex:hotmail,devhood,windows live etc). It will return a token to your website, if the authentication is successful.
Set up Passport as the authentication mode in the application configuration file as follows.

<authentication mode= "Passport"/>

Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories