net Programming Questions & Answers

Explore model answers categorized by subjects like Java, HTML, DBMS, and more.

net Programming Questions & Answers

Why ADO.NET?

Answer:
ADO.NET is data access layer

What is full name of ADO.NET?

Answer:
ActiveX Data Objects

Give Short History of ADO.Net.

Answer:
Microsoft developed ActiveX Data Objects (ADO) as a COM( Component Object Model ) wrapper around OLE DB for Databases.

Write a sample example of ADO.Net?

Answer:
using System;
using System.Data;
using System.Data.OleDb;

// Step 1.Open Database Connection
OleDbConnection conn = new
                      OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\inventory\\inventory\\db\\invent.mdb;");

// Step 2.Connection database opened 
conn.Open();

// Step 3.Create DataSet and Command objects
OleDbCommand cmd = new OleDbCommand(
                            "SELECT * FROM empr4r",
                            conn);

// Step 4.Execute the command
cmd.ExecuteScalar();

// Step 5.Closed this connection 
conn.Close();

Explain ADO.NET Namespaces?

Answer:
The System.Data is main namespace of ADO.Net  and it has DataSet and classes (DataTable, DataColumn, DataRow, DataRelation, Constraint,etc ). System.Data has a namespace System.Data.Common.

What is ADO.NET Data Structures?

Answer:
ADO.NET has three different ways of accessing database information directly which are:
 
1.Commands :-have classes  SqlCommand and OleDbCommand , used directly to retrieve results from database queries.Command classes always support the IDbCommand interface.Commands classesare used to get a scalar result (the first column of the first row of a result set) or out parameters of a stored procedure.sort of data is retrieved using IDbCommand.ExecuteScalar() and IDbCommand.ExecuteNonQuery()

2.DataReaders has  SqlDataReader and OleDbDataReader.These classes are provide something similar to ADO's Recordset using a forward-only cursor.
3.DataSets classes Microsoft uses DataReaders within the managed providers' DataAdapters to fill DataSet

Define ADO.NET provides data access services in the Microsoft .NET platform?

Answer:
ADO.NET to access data by using the new .NET Framework data providers which are given below:
1.Data Provider for SQL Server (System.Data.SqlClient)
2.Data Provider for OLEDB (System.Data.OleDb)
3.Data Provider for ODBC (System.Data.Odbc).
4.Data Provider for Oracle (System.Data.OracleClient).

Tell me about ADO.NET Classes?

Answer:
The ADO.NET classes are found in System.Data.dll and are integrated with the XML classes in System.Xml.dll. ADO.NET is a set of classes that expose data access services to the .NET developer. There are two central components of ADO.NET classes: the DataSet, and the .NET Framework Data Provider.

Define Data Provider in ADO.NET?

Answer:
Data Provider is a set of components including:
1.The Connection object (SqlConnection, OleDbConnection, OdbcConnection, OracleConnection)
2.The Command object (SqlCommand, OleDbCommand, OdbcCommand, OracleCommand)
3.The DataReader object (SqlDataReader, OleDbDataReader, OdbcDataReader, OracleDataReader)
4.The DataAdapter object (SqlDataAdapter, OleDbDataAdapter, OdbcDataAdapter, OracleDataAdapter).
DataSet object represents a disconnected cache of data which is made up of DataTables and DataRelations that represent the result of the command.

Define Dataset in ADO.Net?

Answer:
Dataset is:
1.Disconnected Recordset objects similar to an array.
2.Supports disconnected data access and operations.
3.Scalability, Provide greater scalability because users no longer have to be connected to the database all the time.
DataSet object is made up of two objects:
1.DataTableCollection object containing null or multiple DataTable objects
2.DataRelationCollection object containing null or multiple DataRelation objects which establish a parent/child relation between two DataTable objects.

Define types of Datasets in ADO.Net?

Answer:
There are two type of dataset in Ado.net: 
1.Typed DataSet: Typed DataSet is derived from the base DataSet class and then uses information in an XML Schema file (.xsd file) in order to generate a new class. 
Create a typed DataSet without designer - manually
a.Call the command prompt (cmd) at the location of the XSD schema file. 
b.Use the XSD.EXE utility to create the class for the typed DataSet.

2.Untyped DataSet : Untyped DataSet is not defined by a schema, instead, you have to add tables, columns and other elements to it yourself, either by setting properties at design time or by adding them at run time. 

Define the ways to populate a Dataset in ADO.Net?

Answer:
There are following way to populate Dataset: 
a.By using DataAdapter objects and Fill method.
b.By creating DataTable, DataColumn and DataRow objects programmatically.
c.Read an XML document or stream into the DataSet.
d.Merge (copy) the contents of another DataSet, with the Merge method.

Define DataAdapter in ADO.Net?

Answer:
DataAdapter object is links the database and a Connection object with the ADO.NET-managedDataSet object through its SELECT and action query Commands. Means it works like a bridge DataAdapter specified that which data is to move into and out of the DataSet. DataAdapter provide references to SQL statements or stored procedures that are invoked to read or write to a database.
The DataAdapter provides four properties that allow us to control how updates are made to the server:
SelectCommand 
UpdateCommand 
InsertCommand 
DeleteCommand 

Define methods of DataAdapter in ADO.Net?

Answer:
The DataAdapter includes three main methods:
1.Fill (populates a DataSet with data). 
2.FillSchema (queries the database for schema information that is necessary to update). 
3.Update (to change the database, DataAdapter calls the DeleteCommand, the InsertCommand and the UpdateCommand properties). 

How to DataBindings for TextBoxes in ADO.Net?

Answer:
To bind some elements of a data source with some graphical elements of an application, this ability known as DataBinding. The data in Windows Forms is bound by calling DataBindings. Windows Forms allows you to bind easily to almost any structure that contains data.
Windows Forms Controls support two types of data binding:
a.Simple Data Binding: To display a single data element, means to display a column value from a DataSet table, in a control. It is possible to bind any property of a control to a given data value. Simple Data Binding can be performedby two ways:
   1.At design time using DataBindings property of a control 
   2.Dynamically at run time. This is the type of binding typical for controls such as a TextBox control or Label control that displays typically only a single value.
b.Complex Data Binding: To bind  more than one data element, typically more than one record in a database, or to more than one of any other type of bindable data element. DataGrid, ListBox and ErrorProvider controls support complex data binding. 

Define ADO.NET Objects in brief?

Answer:
ADO.net includes many objects you can use to work with data. Some of the primary objects are:
1. The SqlConnection Object
2. The SqlCommand Object
3. The SqlDataReader Object
4. The DataSet Object
5. The SqlDataAdapter Object 

How to Create a SqlConnection Object in Ado.Net?

Answer:
SqlConnection object is like a c# object.The object declare like that:
 SqlConnection conn = new SqlConnection(
"Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI"); 
This argument is called a connection string. It is define as:
Data Source:  Identifies the server.  
Integrated Security:  Set to SSPI to make connection with user's Windows login
User ID:  Name of user configured in SQL Server. 
Password:  Password matching SQL Server User ID.
Using a SqlConnetion the connection creates as:
1.Instantiate the SqlConnection. 
2.Open the connection. 
3.Pass the connection to other ADO.NET objects. 
4.Perform database operations with the other ADO.NET objects. 
5.Close the connection.

How to create a SqlCommand Object in ADO.Net?

Answer:
SqlCommand cmd = new SqlCommand("select CategoryName from Categories", conn);
Above syntax is written to instantiating a SqlCommand object.  It takes a string parameter that holds the command you want to execute and a reference to a SqlConnection object.

How to querying in ADO.Net, when using SqlCommand?

Answer:
Instantiate a new command with a query and connection
SqlCommand cmd = new SqlCommand("select CategoryName from Categories", conn);
Call Execute reader to get query results
SqlDataReader rdr = cmd.ExecuteReader(); 
Passing the command string and connection object to the constructor.  Then we obtain a SqlDataReader object by calling the ExecuteReader method of the SqlCommand object, cmd.

How to Inserting Data when using SqlCommand Object in ADO.Net?

Answer:
To insert data into a database, use the ExecuteNonQuery method of the SqlCommand object. 
Instantiate a new command with a query and connection
SqlCommand cmd = new SqlCommand(insertString, conn);
 
Call ExecuteNonQuery to send command
cmd.ExecuteNonQuery();

How to Updating Data when using SqlCommand Object in ADO.Net?

Answer:
The ExecuteNonQuery method is also used for updating data.
  The following code shows how to update data: 
1.Prepare command string
2.Instantiate a new command with command text only
SqlCommand cmd = new SqlCommand(updateString)
3.Set the Connection property
cmd.Connection = conn;
4.Call ExecuteNonQuery to send command
cmd.ExecuteNonQuery(); 

How to Deleting Data when using SqlCommand Object in ADO.Net?

Answer:
To deleting data also using the ExecuteNonQuery method.  The following example shows how to delete a record from a database with the ExecuteNonQuery method: 
1.Prepare command string
2.Instantiate a new command
 SqlCommand cmd = new SqlCommand();
3.Set the CommandText property
 cmd.CommandText = deleteString;
4.Set the Connection property
 cmd.Connection = conn;
5.Call ExecuteNonQuery to send command
 cmd.ExecuteNonQuery(); 

How to create a SqlDataReader Object in ADO.Net?

Answer:
There is a little different way to creating object of a SqlDataReader like other object creation in C#. Necessary call ExecuteReader on a command object.
SqlDataReader rdr = cmd.ExecuteReader();
The ExecuteReader method of the SqlCommand object, cmd , returns a SqlDataReader instance.

How to Read data with SqlDataReader Object in ADO.Net?

Answer:
SqlDataReader rdr = cmd.ExecuteReader();
The typical method of reading from the data stream returned by the SqlDataReader is to iterate through each row with a while loop.
while (rdr.Read())
{
string conta = (string)rdr["ContactName"];
string comp = (string)rdr["CompanyName"];
string cty    = (string)rdr["City"];
Console.Write("{0,-25}", conta);
Console.Write("{0,-20}", cty);
Console.Write("{0,-25}", comp);
Console.WriteLine();
}

How to Create a DataSet Object in ADO.Net?

Answer:
Dataset object create as:
DataSet dsStudents = new DataSet(); 
DataSet constructor doesn't require parameters.  However there is one overload that accepts a string for the name of the DataSet, which is used if you were to serialize the data to XML.  Since that isn't a requirement for this example, I left it out.  Right now, the DataSet is empty and you need a SqlDataAdapter to load it.

How to create a SqlDataAdapter in ADO.Net?

Answer:
SqlDataAdapter holds the SQL commands and connection object for reading and writing data.  It initializes with a SQL select statement and connection object:
SqlDataAdapter daStudent = new SqlDataAdapter(
    "select StudentID, CollegeName from Students", conn);
The SQL select statement specifies what data will be read into a DataSet.   
The connection object, conn, should have already been instantiated, but not opened. 
SqlCommandBuilder is instantiated with a single constructor parameter of the SqlDataAdapter, daStudent, instance.
SqlCommandBuilder cmdBldr = new SqlCommandBuilder(daStudent);
SqlCommandBuilder will read the SQL select statement (specified when the SqlDataAdapter was instantiated), infer the insert, update, and delete commands.

How to Filling the DataSet in Disconnected mode in ADO.Net?

Answer:
Once you have a DataSet and SqlDataAdapter instances, you need to fill the DataSet.  Here's how to do it, by using the Fill method of the SqlDataAdapter:
SqlDataAdapter daStudent = new SqlDataAdapter
       ("select StudentID, CollegeName from Students", conn);
SqlCommandBuilder cmdBldr = new SqlCommandBuilder(daStudent);
daStudent.Fill(dsStudent, "Students"); 
Fill method, takes two parameters: a DataSet and a table name.

What are the basic Namespaces in ADO.Net?

Answer:
Some basic namespaces are: 
1.System.Data (basics types)
2.System.Data.OleDb (OLEDB Provider)
3.System.Data.SqlClient (Microsoft Sql Server provider)
4.System.Data.Common
5.System.Data.SqlTypes
6.System.Data.Odbc (ODBC Provider)
7.System.Data.Odbc.OracleClient (Oracle Provider)
8.System.Data.SqlServerCe (Compact framework)

Compare the Connection-Oriented and Disconnected Scenario in ADO.Net?

Answer:
Connection-Oriented Scenario:  
1.Always accessing current data
2.Low number of concurrent data accesses
3.Many write accesses situation
4.IDbConnection, IDbCommand, IDataReader

Disconnected Scenario:
1.Modification in Dataset is not equal to modification in data source
2.Many concurrent read accesses situation
3.Dataset, Data table, DbDataAdapter

What is the difference between “Dataset” and “DataReader”?

Answer:
1.To cache data and pass to a different tier Dataset forms the best choice and it has decent XML support
2.Dataset is a disconnected architecture; DataReader has live connection while reading data.
3.To access data from more than one table Dataset forms the best choice.
4.If we need to move back while reading records, data reader does not support this functionality.
5.A biggest drawback of Dataset is speed. As Dataset carry considerable overhead because of relations, multiple table etc speed is slower than DataReader. Always try to use DataReader wherever possible, as it is meant especially for speed performance.
 

Define, how can we load multiple tables in a Dataset?

Answer:
objCommand.CommandText = "Tab1"
objDataAdapter.Fill(objDataSet, "Tab1")
objCommand.CommandText = "Tab2"
objDataAdapter.Fill(objDataSet, "Tab2")

Above code shows how to load multiple Data Table objects in one Dataset object. Sample code shows two tables Tab1 and Tab2 in object ObjDataSet.
lstdata.DataSource = objDataSet.Tables("Tab1").DefaultView
In order to refer Tab1 Data Table, use Tables collection of Datasets and the Default view object will give you the necessary output.

Explain the difference between an ADO.NET Dataset and an ADO Recordset?

Answer:
1.Using dataset retrieve data from two databases like Oracle and SQL server and merge them in one dataset, with recordset this is not possible.
2.Recordset uses COM. But all representation of Dataset is using XML.
3.Dataset can be transmitted on HTTP while Recordset cannot be transmitted.

Difference between classic ADO and ADO.NET?

Answer:
1.We have recordset in ADO and in ADO.NET we have dataset.
2.In recordset we can only have one table. If we want to accommodate more than one table we need to do inner join and fill the recordset. Dataset can have multiple tables.
3.All data persist in XML as compared to classic ADO where data persisted in Binary format also. 

Define Connection Pooling in brief?

Answer:
Connection Pooling make a single connection instance, which allows that instance to connect to all the databases. It does not open and close the connection object multiple times.

Define methods provided by the dataset object to generate XML in ADO.Net?

Answer:
1.ReadXML: Read’s a XML document in to Dataset.
2.GetXML: This is a function, which returns the string containing XML document.
3.Writexml: This writes a XML data to disk.

What is ADO.NET?

Answer:
ADO stands for ActiveX  Data Object .ADO.NET is an object-oriented set of libraries that allows  to interact with data sources.  The data source is a database, but it could also be a text file, an Excel spreadsheet, or an XML file.ADO .NET consists of classes that allow a .NET application to connect to the data source, executes commands and manage disconnected data. One of the key Differences between ADO.NET and other database technologies is how it deals with Challenge with different data sources, that means, the code you use to connect to an SQL Database will not differ that much to the one connecting to an Oracle Database.

How to Add an AJAX Extender Control?

Answer:
The ASP.NET AJAX Control Toolkit includes several extender controls that can be used to enhance the client functionality of Web server controls. Before you add an extender control to a server control in the following procedure, you must install the ASP.NET AJAX Toolkit. You can download the Control Toolkit from the “ASP.NET AJAX Control Toolkit” Web site.
1.Switch to Design view.
2.If the page does not already contain a ScriptManager control, from the AJAX Extensions tab of the Toolbox, drag one onto the page.
3.From the Standard tab of the Toolbox, drag a Button control onto the page.
4.If the Common Button Tasks shortcut menu does not appear, right-click the Button control and then click Show Smart Tag.
5.On the Common Button Tasks menu, click Add Extender.
6.In the Extender Wizard, in the Choose the functionality to add to Button1 list, click ConfirmButtonExtender, and then click OK. 
7.In the Properties window, expand the Extenders tab, and then expand Button1_ConfirmButtonExtender.
8.Set the ConfirmText property to Continue?

What is AJAX ?

Answer:
AJAX(Asynchronous JavaScript And XML) is not a new programming language, but a new way to use existing standards. AJAX is the art of exchanging data with a server, and update parts of a web page without reloading the whole page. The main purpose of Ajax is to provide a simple and standard means for a web page to communicate with the server without a complete page refresh.

How to create an AJAX website using Visual Studio?

Answer:
Steps: Start Visual Studio, 
Click on File -> New Website -> Under Visual Studio Installed templates -> Select ASP.NET Ajax-Enabled Site. Enter a location & select OK. 

If using Visual Studio 2008 Web Developer Express Ajax comes along with it (so no need of a separate installation).Using Visual Studio Web Developer Express 2005 & versions above it, Ajax based applications may easily be created. Note that the Ajax Framework & Ajax Extensions should be installed (In case of VS 2005).

What is the ASP.NET Ajax Framework?

Answer:
ASP.NET AJAX is a free framework to implement Ajax in asp.net web applications, for quickly creating efficient and interactive Web applications that work across all popular browsers.
The Ajax Framework is powered with
1 - Reusable Ajax Controls
2 - Support for all modern browsers
3 - Access remote services and data from the browser without tons of complicated script.

What role does the ScriptManager play?

Answer:
The ScriptManager manages all ASP.NET AJAX resources on a page and renders the links for the ASP.NET AJAX client libraries, which lets you use AJAX functionality like PageMethods, UpdatePanels etc. It creates the PageRequestManager and Application objects, which are prominent in raising events during the client life cycle of an ASP.NET AJAX Web page. It also helps you create proxies to call web services asynchronously.
The ScriptManager control (that we may drag on a web form) is actually an instance of the ScriptManager class that we put on a web page. The ScriptManager manages all the ASP.NET Ajax controls on a web page. 
Using ScriptManager class:
1 - All resources managing on a web page.
2 - Partial page updates
3 - Interact with UpdatePanel Control. 
4 - Information Release whether.
5 - Provied Facility to access Web Services Method
6 - Providing access to ASP.NET authentication role.

What are limitations of Ajax?

Answer:
1.If the network bandwidth is slow,end user confused because no page postback full running. 
2.Distributed applications running Ajax will need a central mechanism for communicating with each other 

What is the role of a ScriptManagerProxy?

Answer:
In case of Master page scenario in your application and the MasterPage contains a ScriptManager control, then you can use the ScriptManagerProxy control to add scripts to content pages.A page can contain only one ScriptManager control.
Also, if you come across a scenario where only a few pages in your application need to register to a script or a web service, then its best to remove them from the ScriptManager control and add them to individual pages, by using the ScriptManagerProxy control. That is because if you added the scripts using the ScriptManager on the Master Page, then these items will be downloaded on each page that derives from the MasterPage, even if they are not needed, which would lead to a waste of resources.

What is an UpdatePanel Control?

Answer:
All controls residing inside the UpdatePanel will be partial postbacked.An UpdatePanel control is a holder for server side controls that need to be partial postbacked in an ajax cycle.The UpdatePanel enables you to add AJAX functionality to existing ASP.NET applications. It can be used to update content in a page by using Partial-page rendering. By using Partial-page rendering, you can refresh only a selected part of the page instead of refreshing the whole page with a postback.

What is the name of AJAX controls ?

Answer:
There are 5  AJAX controls.
1. ScriptManager
2. UpdatePanel
3. UpdateProgress
4. Timer
5. ScriptManageProxy

What is ASP.NET AJAX?

Answer:
ASP.NET AJAX is a terminology by Microsoft for implementation of AJAX, which is a set of extensions to ASP.NET. These components allow you to build rich AJAX enabled web applications, which consists of both server side and client side libraries.

Define Internet Standards for AJAX?

Answer:
AJAX is based on internet standards, and uses a combination of:
1. XMLHttpRequest object (to exchange data asynchronously with a server)
2. JavaScript/DOM (to display/interact with the information)
3. CSS (to style the data)
4. XML (often used as the format for transferring data)

What is XMLHttpRequest object in AJAX?

Answer:
The XMLHttpRequest object is used to exchange data with a server. With the XMLHttpRequest object Browser can retrieve and submit XML data directly to a Web server without reloading the page. To convert XML data into renderable HTML content, use the client-side Extensible Stylesheet Language Transformations (XSLT) to compose HTML elements for presentation.

Property:
1. Onreadystatechange 
2. readyState
3. responseBody 
4. responseTextresponseXML
5. StatusstatusText

Method
1. abort  
2. getAllResponseHeaders: 	
3. getResponseHeader	 	
4. open 				
5. send 			

Why Use ASP.NET AJAX Features?

Answer:
Features:
1. Improved efficiency.
2. As user requirement significant parts of a Web page's processing are performed in the browser.
3. UI elements- progress indicators, tool tips, and pop-up windows.
4. Partial-page updates that refresh only the parts of the Web page that have changed.
5. Client integration with ASP.NET application services for forms authentication, roles, and user profiles.
6. Auto-generated proxy classes.
7. Provide a framework that lets you customize of server controls to include client capabilities.

Define ASP.NET AJAX Client Life-Cycle Events?

Answer:
The two main Microsoft AJAX Library classes that raise events during the client life cycle of a page:
1. Application and
2. PageRequestManager classes.
When partial-page rendering with UpdatePanel controls is enabled, the key client events are the events of the PageRequestManager class. These events enable you to handle many common scenarios. These include the ability to cancel postbacks, to give precedence to one postback over another, and to animate UpdatePanel controls when their content is refreshed.

1. Sys.WebForms.PageRequestManager Events:

initializeRequest: Raised during initialization of an asynchronous postback.
beginRequest: Raised before processing of an asynchronous postback starts, 
pageLoading: Raised after a response to an asynchronous postback is received from the server, but before any content on the page is updated.
pageLoaded: Raised after all content on the page is refreshed as the result of either a synchronous or an asynchronous postback.
endRequest: Use this event to provide customized error notification to users or to log errors. 

2. Sys.Application Events:

init: Raised only once when the page is first rendered after all scripts have been loaded, but before objects are created.
load: Raised after all scripts have been loaded and objects in the application have been created and initialized.
unload: Raised before all objects in the client application are disposed.

How to Check Whether AJAX Functionality is Enabled for a Page?

Answer:
Use the following code to determine whether AJAX functionality is enabled for a page in C# Code:

ScriptManager sm = ScriptManager.GetCurrent(Page)
if (sm == null)
{
    // ASP.NET AJAX functionality is not enabled for the page.
}
else
{
    // AJAX functionality is enabled for the page.
}
To determine whether partial page rendering is supported for a page, you can modify this code to use the EnablePartialRendering and the SupportsPartialRendering property of the ScriptManager control.

How to Remove an AJAX Extender Control in ASP.NET?

Answer:
If the functionality of an extender control is no longer needed, you can remove the extender control.
1.Switch to Design view.
2.Select the Button control, and then on the Common Button Tasks menu, click Remove Extender.
3.In the Extenders attached to Button1 list, select ConfirmButtonExtender.
4.Click Remove, and then click OK.

What is the ASP.NET AJAX Extender Controls?

Answer:
If you want to adds client functionality to a Button control when users confirm to submit a form to the server then extender controls can use. ASP.NET AJAX extender controls enhance the client capabilities of standard ASP.NET Web server controls such as TextBox controls, Button controls, and Panel controls by using one or more extender controls to provide a richer user experience in the browser, and you also add ASP.NET AJAX extender controls to Visual Studio and work with them as you do with other controls. You can create your own extender controls and source for extender controls is the ASP.NET AJAX Control Toolkit.

What are the features of ASP.NET AJAX Extender Controls

Answer:
Visual Studio supports the following extender control features:
1.Adding extender controls.
2.Removing extender controls.
3.Setting extender control properties.
4.Managing extender controls

List of all Extender Controls in the AJAX Control Toolktit?

Answer:
Extender Controls in the AJAX Control Toolktit:
1.CascadingDropDown
2.CollapsiblePanelExtender
3.ConfirmButtonExtender
4.FilteredTextBoxExtender
5.ModalPopupExtender
6.PasswordStrength
7.RoundedCornersExtender
8.TextBoxWatermarkExtender

Define Classes in ASP.NET AJAX Extender Controls?

Answer:
Two classes:
1.ExtenderControl: 
The ExtenderControl class enabled to programmatically add AJAX functionality to an ASP.NET server control and inherits from the Control class and implements the IExtenderControl interface. The Control class defines the properties, methods, and events that are shared by all ASP.NET server controls.

Inheritance Hierarchy:
System.Object
  System.Web.UI..::.Control
   System.Web.UI.ExtenderControl

2.IExtenderControl: The ExtenderControl base class performs an explicit test to make sure that a ScriptManager control exists on the page. However, if you want to create extender controls and the page does not contain an ScriptManager control, you can create a class that implements the IExtenderControl interface directly. 

Inheritance Hierarchy:
System.Object
  System.Web.UI.Control
    System.Web.UI.IExtenderControl

What is the Debug Helper Classes in AJAX ASP.NET?

Answer:
ASP.NET provides the Sys.Debug class for debugging client applications. By calling methods of the Sys.Debug class, you can display objects in readable form at the end of the page, show trace messages, use assertions, and break into the debugger. 

The following table lists the methods of the Sys.Debug class.

Sys.Debug.assert(condition, message, displayCaller): 
Checks for a condition, and if the condition is false, displays a message and prompts the user to break into the debugger.

Sys.Debug.clearTrace():
Clears all trace messages from the TraceConsoletextarea element.

Sys.Debug.traceDump(object, name): 
Dumps an object to the debugger console and to the TraceConsoletextarea element, if available.

Sys.Debug.fail(message): 
Displays a message in the debugger's output window and breaks into the debugger.

Sys.Debug.trace(text): 
Appends a text line to the debugger console and to the TraceConsoletextarea element, if available.

What is AJAX Server Controls in ASP.NET?

Answer:
ASP.NET Web server controls that enable you to add AJAX functionality to an ASP.NET Web page. AJAX functionality includes refreshing parts of a page with a partial-page update and therefore avoiding a full-page postback.

1. ScriptManager Control Overview:
Manages client script for AJAX-enabled ASP.NET pages
2. Timer Control Overview:
Performs postbacks at defined intervals.
3. UpdatePanel Control Overview:
Enables you to refresh selected parts of the page instead of refreshing the whole page with a postback. 
4. UpdateProgress Control Overview:
Enables you to provide status information about partial-page updates in UpdatePanel controls.

What is Timer control in AJAX ASP.NET?

Answer:
The ASP.NET AJAX Timer control performs postbacks at defined intervals. If Timer control used with an UpdatePanel control, you can enable partial-page updates at a defined interval. You can also use the Timer control to post the whole page.

You use the Timer control when you want to do the following:
1. Periodically update the contents of one or more UpdatePanel controls without refreshing the whole Web page.
2. Run code on the server every time that a Timer control causes a postback.
3. Synchronously post the whole Web page to the Web server at defined intervals

How to use a Timer Control inside an UpdatePanel Control in AJAX ASP.NET?

Answer:
For Timer controls inside an UpdatePanel control, the JavaScript timing component is re-created only when each postback finishes. Therefore, the timed interval does not start until the page returns from the postback. For instance, if the Interval property is set to 60,000 milliseconds (60 seconds) but the postback takes 3 seconds to complete, the next postback will occur 63 seconds after the previous postback. When the Timer control is included inside an UpdatePanel control, the Timer control automatically works as a trigger for the UpdatePanel control.
The following example shows how to include a Timer control inside an UpdatePanel control: 


  
    
    
  

How to use a Timer Control outside an UpdatePanel Control in AJAX ASP.NET?

Answer:
: If the Timer controls are outside an UpdatePanel control, the JavaScript timing component continues to run as the postback is being processed. For example, if the Interval property is set to 60,000 milliseconds (60 seconds) and the postback takes 3 seconds to complete, the next postback will occur 60 seconds after the previous postback. The user will see the refreshed content in the UpdatePanel control for only 57 seconds.

The following example shows how to use the Timer control outside an UpdatePanel control:




  
    
    
    
      
  

What is Custom Component Properties in AJAX ASP.NET?

Answer:
When creating a client component class, define the properties that expected page developers to access. Also raise Sys.Component.propertyChanged notification events in the set accessors for properties of your component. Page developers who use the component can bind the property notification event to their own handler to run code when the property value changes.

Defining Public Properties in a Custom Client Component in AJAX ASP.NET?

Answer:
In ASP.NET AJAXclient components, property accessors are defined as methods of the class prototype. The accessor methods are named with get_ and set_ prefixes followed by the property name. The following example shows how to define a read-write property named interval in the class prototype.

get_interval: function() 
{
    return this._interval;
},
set_interval: function(value)
 {
    this._interval = value;
}

How to raise a PropertyChanged Event in AJAX ASP.NET?

Answer:
Invoking to the Sys.Component raisePropertyChanged method in a property set accessor to raise a propertyChanged event. Your component inherits the raisePropertyChanged method from the Sys.Component, Sys.UI.Behavior, or Sys.UI.Control base class.

The following example shows how to raise a propertyChanged event for an interval property whenever the property is set.

get_interval: function()
 {
    return this._interval;
},
set_interval: function(value) 
{
    if (this._interval !== value) 
{
        this._interval = value;
        this.raisePropertyChanged('interval');
    }
}

How to Globalize and Localize client script files in AJAX ASP.NET?

Answer:
The ScriptManager control enables you to globalize and localize client script files. Globalization lets you use the Date and Number JavaScript type extensions in your script and have those objects display values that are based on the current culture. Localization lets you provide client script files for different cultures.

How to Configure SMTP in asp .NET?

Answer:

This example specifies SMTP parameters to send e-mail using a remote SMTP server and user  that are importent. This program shows configuration process-

<system.net>

<mailSettings>

<smtp 

deliveryMethod=\"Network|PickupDirectoryFromIis|SpecifiedPickupDirec>

<network 

defaultCredentials=\"true|false\"

from=\"r4r@fco.in\"

host=\"smtphost\"

port=\"26\"

password=\"password\"

userName=\"user\"/>

<specifiedPickupDirectory 

pickupDirectoryLocation=\"c:pickupDirectory\"/>

</smtp>

</mailSettings>

</system.net>

Print Hello World message using SharePoint in Asp.Net 2.0?

Answer:

using System;

using System.Collections.Generic;

using System.Text;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using Microsoft.SharePoint.WebPartPages;

namespace LoisAndClark.WPLibrary

{

public class MYWP : WebPart

{

protected override void CreateChildControls()

{

Content obj = new Content();

string str1 = obj.MyContent<string>(\"Hello World!\");

this.Controls.Add(new System.Web.UI.LiteralControl(str1));

}

}

}

 generic method shows that  SharePoint site is  running on .NET Framework

2.0, and the code of the generic method seems like this:

public string MyContent<MyType>(MyType arg)

{

return arg.ToString();

}

How to create a SharePoint web part using File upload control.give example?

Answer:

using System;

using System.Collections.Generic;

using System.Text;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using Microsoft.SharePoint.WebPartPages;

namespace LoisAndClark.WPLibrary

{

public class MYWP : WebPart

{

FileUpload objFileUpload = new FileUpload();

protected override void CreateChildControls()

{

this.Controls.Add(new System.Web.UI.LiteralControl

(\"Select a file to upload:\"));

this.Controls.Add(objFileUpload);

Button btnUpload = new Button();

btnUpload.Text = \"Save File\";

this.Load += new System.EventHandler(btnUpload_Click);

this.Controls.Add(btnUpload);

}

private void btnUpload_Click(object sender, EventArgs e)

{

string strSavePath = @\"C:temp\";

if (objFileUpload.HasFile)

{

string strFileName = objFileUpload.FileName;

strSavePath += strFileName;

objFileUpload.SaveAs(strSavePath);

}

else

{

//otherwise let the message show file was not uploaded.

}

}

}

}

What is BulletedList Control in Share Point. Give an example?

Answer:

Bullet style allow u choose the style of the element that precedes the item.here u can choose numbers, squares, or circles.here child items can be rendered as plain text, hyperlinks, or buttons.

This example uses a custom image that requires to be placed in a virtual directory on the server.

using System;

using System.Collections.Generic;

using System.Text;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using Microsoft.SharePoint.WebPartPages;

namespace LoisAndClark.WPLibrary

{

public class MyWP : WebPart

{

protected override void CreateChildControls

 {

BulletedList objBullist = new BulletedList();

objBullist.BulletStyle = BulletStyle.CustomImage;

objBullist.BulletImageUrl = @\"/_layouts/images/rajesh.gif\";

objBullist.Items.Add(\"First\");

objBullist.Items.Add(\"Seciond\");

objBullist.Items.Add(\"Third\");

objBullist.Items.Add(\"Fourth\");

this.Controls.Add(objBullist);

}

}

}

DescribeWizard server control with example in Share Point?

Answer:

This control enables you to build a sequence of steps that are displayed to the

end users side. It is alos used either display or gather information in small steps in system.

using System;

using System.Collections.Generic;

using System.Text;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using Microsoft.SharePoint.WebPartPages;

namespace LoisAndClark.WPLibrary

{

public class MyWP : WebPart

{

protected override void CreateChildControls()

{

Wizard objWizard = new Wizard();

objWizard.HeaderText = \"Wizard Header\";

for (int i = 1; i <= 6; i++)

{

WizardStepBase objStep = new WizardStep();

objStep.ID = \"Step\" + i;

objStep.Title = \"Step \" + i;

TextBox objText = new TextBox();

objText.ID = \"Text\" + i;

objText.Text = \"Value for step \" + i;

objStep.Controls.Add(objText);

objWizard.WizardSteps.Add(objStep);

}

this.Controls.Add(objWizard);

}

}

Define Life Cycle of Page in ASP.NET?

Answer:

    protected void Page_PreLoad(object sender, EventArgs e)

    {

        Response.Write(\"<br>\"+\"Page Pre Load\");

    }

    protected void Page_Load(object sender, EventArgs e)

    {

        Response.Write(\"<br>\" + \"Page Load\"); 

    }

    protected void Page_LoadComplete(object sender, EventArgs e)

    {

        Response.Write(\"<br>\" + \"Page Complete\");

    }

    protected void Page_PreRender(object sender, EventArgs e)

    {

        Response.Write(\"<br>\" + \"Page Pre Render\");

    }

    protected void Page_Render(object sender, EventArgs e)

    {

        Response.Write(\"<br>\" + \"Pre Render\");

    }

    protected void Page_PreInit(object sender, EventArgs e)

    {

        Response.Write(\"<br>\" + \"Page Pre Init\");

    }

    protected void Page_Init(object sender, EventArgs e)

    {

        Response.Write(\"<br>\" + \"Page Init\");

    }

    protected void Page_InitComplete(object sender, EventArgs e)

    {

        Response.Write(\"<br>\" + \"Page Pre Init Complete\");

    }


Write a program in ASP.NET to Show Data With Access?

Answer:

Page_Load():-

    OleDbConnection x;

    OleDbCommand y;

    OleDbDataReader z;

    protected void Page_Load(object sender, EventArgs e)

    {

        x = new OleDbConnection(\"provider=microsoft.jet.oledb.4.0;data source=c:\\db1.mdb\");

        x.Open();

        y = new OleDbCommand(\"select * from emp\", x);

        z = y.ExecuteReader();

        while (z.Read())

        {

            Response.Write(z[\"ename\"]);

            Response.Write(\"<hr>\");  

        }

        z.Close();

        y.Dispose(); 

        x.Close(); 

    }


Write a program to show connection with Oracle in ASP.NET?

Answer:

    OleDbConnection x;

    OleDbCommand y;

    OleDbDataReader z;

    protected void Page_Load(object sender, EventArgs e)

    {

        x = new OleDbConnection(\"provider=msdaora;user id=scott;password=tiger\");

        x.Open();

        y = new OleDbCommand(\"select * from emp\", x);

        z = y.ExecuteReader();

        while (z.Read())

        {

            Response.Write(\"<li>\");

            Response.Write(z[\"ename\"]);

        }    

        z.Close();

        y.Dispose(); 

        x.Close(); 

    }


Write a program to show connection to Excel in ASP.NET?

Answer:

OleDbConnection x;

    OleDbCommand y;

    OleDbDataReader z;

    protected void Page_Load(object sender, EventArgs e)

    {

        x = new OleDbConnection(\"provider=microsoft.jet.oledb.4.0;data source=c:\\book1.xls;Extended Properties=excel 8.0\");

        x.Open();

        y = new OleDbCommand(\"select * from [sheet1$]\", x);

        z = y.ExecuteReader();

        while (z.Read())

        {

            Response.Write(\"<li>\");

            Response.Write(z[\"ename\"]);

        }    

        z.Close();

        y.Dispose(); 

        x.Close(); 

    }


How to add Record in ASP.NET?

Answer:

OleDbConnection x;

    OleDbCommand y;

    protected void Button1_Click(object sender, EventArgs e)

    {

        x = new OleDbConnection(\"provider=microsoft.jet.oledb.4.0;data source=c:\\db1.mdb\");

        x.Open();

        y = new OleDbCommand(\"Insert into emp(empno,ename,sal) values(@p,@q,@r)\", x);

        y.Parameters.Add(\"@p\", TextBox1.Text);

        y.Parameters.Add(\"@q\", TextBox2.Text);

        y.Parameters.Add(\"@r\", TextBox3.Text);

        y.ExecuteNonQuery();

        Label1.Visible = true;   

        Label1.Text=\"Record Addedd\";

        y.Dispose();

        x.Close(); 

     }


Write a program to Delete Record in ASP.NET ?

Answer:

OleDbConnection x;

    OleDbCommand y;

     protected void Button1_Click(object sender, EventArgs e)

    {

        x = new OleDbConnection(\"provider=microsoft.jet.oledb.4.0;data source=c:\\db1.mdb\");

        x.Open();

        y = new OleDbCommand(\"delete from emp where empno=@p\",x);

        y.Parameters.Add(\"@p\", TextBox1.Text);

        y.ExecuteNonQuery();

        Label1.Visible = true;   

        Label1.Text=\"Record Deleted\";

        y.Dispose();

        x.Close(); 

 }

Write a program to show data in Gridview in ASP.NET?

Answer:

    OleDbConnection x;

    OleDbDataAdapter y;

    DataSet z;

    protected void Button2_Click(object sender, EventArgs e)

    {

        x = new OleDbConnection(\"provider=msdaora;user id=scott;password=tiger\");

        x.Open();

        y = new OleDbDataAdapter(\"select * from emp\", x);

        z = new DataSet();

        y.Fill(z, \"emp\");

        GridView1.DataSource = z.Tables[\"emp\"];

        GridView1.DataBind();  

        y.Dispose();

        x.Close(); 

    }

Write a Program to Connect with dropdownlist in ASP.NET

Answer:

OleDbConnection x;

    OleDbDataAdapter y;

    DataSet z;

    protected void Button1_Click(object sender, EventArgs e)

    {

        x = new OleDbConnection(\"Provider=msdaora;user         id=scott;password=tiger\");

        x.Open();

        y=new OleDbDataAdapter(\"select * from emp\",x);

        z = new DataSet();

        y.Fill(z, \"emp\");

        DropDownList1.DataSource = z;

        DropDownList1.DataTextField = \"ename\"; 

        DropDownList1.DataBind();

        x.Close();  

 

    }

How Repeater is used in ASP.NET?

Answer:

<asp:Repeater ID=\"Repeater1\" runat=\"server\"> <ItemTemplate>

                            <%#DataBinder.Eval(Container.DataItem, \"Empno\") %>

                            <%#DataBinder.Eval(Container.DataItem, \"Ename\") %>

                            <%#DataBinder.Eval(Container.DataItem, \"Sal\") %>

 </ItemTemplate> 

 </asp:Repeater>

//the whole structure looks like this

<asp:Repeater ID=\"Repeater1\" runat=\"server\">

<HeaderTemplate>

 Employee Detailed

</HeaderTemplate> 

            <ItemTemplate>

               <font color=gray>

                            <%#DataBinder.Eval(Container.DataItem, \"Empno\") %>

                            <%#DataBinder.Eval(Container.DataItem, \"Ename\") %>

                            <%#DataBinder.Eval(Container.DataItem, \"Sal\") %>

                </font> 

                </ItemTemplate> 

                <AlternatingItemTemplate>

                <font color=green>

                            <%#DataBinder.Eval(Container.DataItem, \"Empno\") %>

                            <%#DataBinder.Eval(Container.DataItem, \"Ename\") %>

                            <%#DataBinder.Eval(Container.DataItem, \"Sal\") %>

                 </font> 

                  </AlternatingItemTemplate>

                 <FooterTemplate>

                       Thanks

                </FooterTemplate> 

               <SeparatorTemplate>

                        <hr/>

                </SeparatorTemplate> 

                </asp:Repeater>

How to show data in HTML table using Repeater?

Answer:

<asp:Repeater ID=\"Repeater1\" runat=\"server\">

                    <HeaderTemplate>

                    <table border=\"10\" width=\"100%\"  bgcolor=green  style=\"width:100%\" >

                       <tr>

                       <th>Empno</th> <th>Ename</th> <th>Sal</th>  

                       </tr>

                    </HeaderTemplate> 

                    <ItemTemplate>

                            <tr>

                            <td>

                            <%#DataBinder.Eval(Container.DataItem, \"Empno\") %>

                            </td>

                            <td>

                            <%#DataBinder.Eval(Container.DataItem, \"Ename\") %>

                            </td>

                            <td>

                            <%#DataBinder.Eval(Container.DataItem, \"Sal\") %>

                            </td>

                            </tr>

                            </font> 

                    </ItemTemplate> 

                    <FooterTemplate>

                       </table> 

                    </FooterTemplate> 

                    </asp:Repeater>

                </td>

                <td style=\"width: 100px; height: 226px\">

                </td>

            </tr>

        </table>

Write a program to show the Use of dataList in ASP.NET?

Answer:

<asp:DataList ID=\"DataList1\" runat=\"server\" BackColor=\"White\" BorderColor=\"#336666\" BorderStyle=\"Double\" BorderWidth=\"3px\" CellPadding=\"4\" GridLines=\"Both\">

        <HeaderTemplate>Employee Detailed</HeaderTemplate>  

        <ItemTemplate>

                            <%#DataBinder.Eval(Container.DataItem, \"Empno\") %>

                            <%#DataBinder.Eval(Container.DataItem, \"Ename\") %>

                            <%#DataBinder.Eval(Container.DataItem, \"Sal\") %>

        </ItemTemplate>    

How to make User Control in ASP.net?

Answer:

a) Add User Controll

write code:-

<hr color=red/>

<center><H1><SPAN 

style=\"COLOR: #ff9999; TEXT-DECORATION: underline\">BigBanyanTree.com</SPAN></H1></center> 

<hr Color=Green/>


b) In .aspx page:-

<%@ Register TagPrefix=a TagName=\"MyUserCtl\" Src=\"~/WebUserControl.ascx\"%>


c) Now use this :-

<a:MyUserCtl ID=\"tata\" runat=server/>

What is Benefits of ASP.NET?

Answer:

>>Simplified development

ASP.NET offers a very rich object model that developers can use to reduce the amount of code they need to write.

>>Web services:

Create Web services that can be consumed by any client that understands HTTP and

XML,  the de facto language for inter-device communication.

>>Performance:

When ASP.NET page is first requested, it is compiled and cached, or saved in memory, by

the .NET Common Language Runtime (CLR). This cached copy can then be re-used for

each subsequent request for the page. Performance is thereby improved because after

the first request, the code can run from a much faster compiled version.

>>Language independence

>>Simplified deployment

>>Cross-client capability

How does cookies work in ASP.Net?

Answer:

Using Cookies in web pages is very useful for temporarily storing small amounts of data, for the website to use. These Cookies are small text files that are stored on the user\'s computer, which the web site can read for information; a web site can also write new cookies.

An example of using cookies efficiently would be for a web site to tell if a user has already logged in. The login information can be stored in a cookie on the user\'s computer and read at any time by the web site to see if the user is currently logged in. This enables the web site to display information based upon the user\'s current status - logged in or logged out. 

Difference Between Thread and Processs?

Answer:

Process is a program in execution where thread is a seprate part of execution in the program.

Thread is a part of process. process is the collection of thread. 

What is the difference between an EXE and a DLL?

Answer:

DLL: Its a Dynamic Link Library .There are many entry points. The system loads a DLL into the context of an existing thread. Dll cannot Run on its own

EXE: Exe Can Run On its own.exe is a executable file.When a system launches new exe, a new process is created.The entry thread is called in context of main thread of that process.

         


Difference bt ASP and asp.net?

Answer:
1.Asp .net is compiled while asp is interpreted.
2.ASP is mostly written using VB Script and HTML. while asp .net can be written in C#, J# and VB etc.
3.Asp .net have 4 built in classes session , application , request response, while asp .net have more than 2000 built in classes.
4.ASP does not have any server side components whereas Asp .net have server side components such as Button , Text Box etc.
5.Asp does not have page level transaction while Asp .net have page level transaction.
ASP .NET pages only support one language on a single page, while Asp support multiple language on a single page.
6.Page functions must be declared as 


    Set Cookie Values


    









Define Error Events in Asp.Net?

Answer:

In ASP.Net when any unhandled exception accurs in application then an event occures,that event called Error event.Two types of Event:

1. Page_Error:When exception occures in a page then this event raised.

2. Application_error:Application_Error event raised when unhandled exceptions in the ASP.NET application and is implemented in global.asax.

The error event have two method:

1. GetLastError: Returns the last exception that occurred on the server.

2. ClearError: This method clear error and thus stop the error to trigger subsequent error event.


Why the exception handling is important for an application?

Answer:
Exception handling prevents the unusual error in the asp.net application,when apllication executed.If the exceptions are handled properly, the application will never get terminated abruptly.

Explain the aim of using EnableViewState property?

Answer:
When the page is posted back to the server, the server control is recreated with the state stored in viewstate.It allows the page to save the users input on a form across postbacks. It saves all the server side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser. 

What are the two levels of variable supported by Asp.net?

Answer:

1. Page level variable:String ,int ,float.

2. Object level variable:Session level, Application level.

Difference between Session object and Profile object in ASP.NET?

Answer:

Profile object:

1. Profile object is persistent.

2. Its uses the provider model to store information.

3. Strongly typed

4. Anonymous users used mostly.


Session object:

1. Session object is non-persistant.

2. Session object uses the In Proc, Out Of Process or SQL Server Mode to store information.

3. Not strongly typed.

4. Only allowed for authenticated users.

What is the Default Expiration Period For Session and Cookies,and maximum size of viewstate?

Answer:

The default Expiration Period for Session is 20 minutes.

The default Expiration Period for Cookie is 30 minutes.

The maximum size of the viewstate is 25% of the page size

What is the use of Global.asax File in ASP.NET Application ?

Answer:

The Global.asax file, can be stored in root directory and accesible for web-sites,is an optional file.This Global.asax file contained in HttpApplicationClass.we can declare global variables like variables used in master pages because these variables can be used for different pages right.Importent feature is that its provides more security in comparision to other.

It handle two event:

1.Application-level  

2.Session-level events.


Global.asax File itself configured but it can not be accessed.while one request is in processing it is impossible to send another request, we can not get response for other request and even we can not start a new session.

while adding this Global.asax file to our application by default it contains five methods,

Those methods are:

1.Application_Start.

2.Application_End.

3.Session_Start.

4.Session_End.

5.Application_Error.

What is the Purpose of System.Collections.Generic ?

Answer:
For more safty and better performance strongly typed collections are useful for the user. System.Collections.Generic having interfaces and classes which define strongly typed generic collections.

What is GAC and name of the utility used to add an assembly into the GAC ?

Answer:

GAC(Global Assembly Cache) for an effective sharing of assemblies.GAC refers to the machine-wide code cache in any of the computers that have been installed with common language runtime.Global Assembly Cache in .NET Framework acts as the central place for private registering assemblies.

\"gacutil.exe\" utility used to add assembly in GAC

Whether we can use vbscript and javascript combination for validation?

Answer:
WE cant use them togather,since compiler are different.

What are the different states in ASP.NET?

Answer:

There are three types of state:

1. View state: Under the client-side state managment.The ViewState property provides a dictionary object for retaining values between multiple requests for the same page. When an ASP.NET page is processed, the current state of the page and controls is hashed into a string and saved in the page as a hidden field. 

2. Application state:Under the server side state managment. ASP.NET allows you to save values using application state, a global storage mechanism that is accessible from all pages in the Web application. Application state is stored in the Application key/value dictionary.

3. Session state:Under server side state managment . ASP.NET allows you to save values using session state, a storage mechanism that is accessible from all pages requested by a single Web browser session.

Define State managment?

Answer:

This is passible to at a time many request occures.State management is the process by which maintained state and page information over multiple requests for the same or different pages.

Two types of State Managment:

1. Client side state managment:This stores information on the client\'s computer by embedding the information into a Web page,uniform resource locator(url), or a cookie.

2. Server side state managment: There are two state Application State,Session State. 

What is Authentication and Authorization ?

Answer:

An authentication system is how you identify yourself to the computer. The goal behind an authentication system is to verify that the user is actually who they say they are.

Once the system knows who the user is through authentication, authorization is how the system decides what the user can do.

Discribe Client Side State Management?

Answer:

Client side state managment have:

a. Stores information on the client\'s computer by embedding the information into a Web page.

b. A uniform resource locator(url).

c. Cookie.

To store the state information at the client end terms are:

1. View State:It is used by the Asp.net page framework to automatically save the values of the page and of each control just prior to rendering to the page.Asp.Net uses View State to track the values in the Controls. You can add custom values to the view state.

2. Control State:When user create a custom control that requires view state to work properly, you should use control state to ensure other developers dont break your control by disabling view state.

3. Hidden fields:Like view state, hidden fields store data in an HTML form without displaying it in the user\'s browser. The data is available only when the form is processed.

4. Cookies: Cookies store a value in the user\'s browser that the browser sends with every page request to the same server. Cookies are the best way to store state data that must be available for multiple Web pages on a web site.

5. Query Strings: Query strings store values in the URL that are visible to the user. Use query strings when you want a user to be able to e-mail or instant message state data with a URL.


Describe Server Side State Management ?

Answer:

Sever side state managment provied Better security,Reduced bandwidth.

1. Application State: This State information is available to all pages, regardless of which user requests a page.

2. Session State Session State information is available to all pages opened by a user during a single visit.


What is SessionID?

Answer:
To identify the request from the browser used sessionID. SessionId value stored in a cookie. Configure the application to store SessionId in the URL for a \"cookieless\" session.  

What is the Session Identifier?

Answer:

Session Identifier is :

1. To identify session. 

2. It has SessionID property.

3. When a page is requested, browser sends a cookie with a session identifier. 

4. Session identifier is used by the web server to determine if it belongs to an existing session or not. If not, then Session ID is generated by the web server and sent along with the response.  

Advantages of using Session State?

Answer:

Advantages:

1. It is easy to implement.

2. Ensures platform scalability,works in the multi-process configuration.

3. Ensures data durability, since session state retains data even if ASP.NET work process restarts as data in Session State is stored in other process space. 

Disadvantages of using Session State ?

Answer:

Disadvatages:

1. It is not advisable to use session state when working with large sum of data.Because Data in session state is stored in server memory.

2. Too many variables in the memory effect performance. Because session state variable stays in memory until you destroy it.   

What are the Session State Modes? Define each Session State mode supported by ASP.NET.

Answer:

ASP.NET supports three Session State modes.

1. InProc:This mode stores the session data in the ASP.NET worker process and fastest among all of the storage modes.Its Also effects performance if the amount of data to be stored is large.

2. State Server:This mode maintained on a different system and session state is serialized and stored in memory in a separate process.

State Server mode is serialization and de-serialization of objects. State Server mode is slower than InProc mode as this stores data in an external process.

3. SQL Server:This mode can be used in the web farms and reliable and secures storage of a session state.In this storage mode, the Session data is serialized and stored in a database table in the SQL Server database.

  

  

What is a Master Page in Asp.Net?

Answer:
For consistent layout for the pages in application used Master Pages.A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application.Then user create individual content pages that share all the information and lay out of a Master Page.

What are the 2 important parts of a master page and file extension for a Master Page?

Answer:

The following are the 2 important parts of a master page

1. The Master Page itself

2. One or more Content Pages

The file extention for Master Page is \".master\".

How do you identify a Master Page and how do you bind a Content Page to a Master Page?

Answer:

The master page is identified by a special @ Master directive that replaces the @ Page directive that is used for ordinary .aspx pages.

MasterPageFile attribute of a content page\'s @ Page directive is used to bind a Content Page to a Master Page.

Can you dynaimically assign a Master Page?

Answer:

   void Page_PreInit(Object sender, EventArgs e) {

    

        if (Request.Browser.IsBrowser(\"IE\")) {

           this.MasterPageFile = \"ArticleMaster_IE.master\";

        }

        else if (Request.Browser.IsBrowser(\"Mozilla\")) {

           this.MasterPageFile = \"ArticleMaster_FireFox.master\";

        }

        else {

           this.MasterPageFile = \"ArticleMaster.master\";

        }

    }

From the content page code how can you reference a control on the master page?

Answer:

Use the FindControl() method as shown in the code sample below.

void Page_Load()

{

// Gets a reference to a TextBox control inside

// a ContentPlaceHolder

ContentPlaceHolder ContPlaceHldr = (ContentPlaceHolder)Master.FindControl (\"ContentPlaceHolder1\");

if(ContPlaceHldr != null)

{

TextBox TxtBox = (TextBox)ContPlaceHldr.FindControl(\"TextBox1\");

if(TxtBox != null)

{

TxtBox.Text = \"WHERE R4R\";

}

}

// Gets a reference to a Label control that not in

// a ContentPlaceHolder

Label Lbl = (Label)Master.FindControl(\"Label1\");

if(Lbl != null)

{

Lbl.Text = \"R4R HERE\";

}

}

What is Globalization?

Answer:

Globalization is the process of creating an application that meets the needs of users from multiple cultures.

This process involves translating the user interface elements of an application into multiple languages, using the correct currency, date and time format, calendar, writing direction, sorting rules, and other issues. 

What are the 3 different ways to globalize web applications?

Answer:

Detect and redirect approach : In this approach we create a separate Web application for each supported culture, and then detect the users culture and redirect the request to the appropriate application. This approach is best for applications with lots of text content that requires translation and few executable components.

Run-time adjustment approach : In this approach we create a single Web application that detects the users culture and adjusts output at run time using format specifiers and other tools. This approach is best for simple applications that present limited amounts of content.

Satellite assemblies approach : In this approach we create a single Web application that stores culture-dependent strings in resource files that are compiled into satellite assemblies. At run time, detect the users culture and load strings from the appropriate assembly. This approach is best for applications that generate content at run time or that have large executable components.

What are the steps to follow to get user\'s culture at run time?

Answer:

1. Get the Request objects UserLanguages property.

2. Use the returned value with the CultureInfo class to create an object representing the users current culture.


For example, the following code gets the users culture and displays the English name and the abbreviated name of the culture in a label the first time the page is displayed:


private void Page_Load(object sender, System.EventArgs e)

{

// Run the first time the page is displayed

if (!IsPostBack)

{

// Get the user\'s preferred language.

string sLang = Request.UserLanguages[0];

// Create a CultureInfo object from it.

CultureInfo CurrentCulture = new CultureInfo(sLang);

lblCulture.Text = CurrentCulture.EnglishName + \": \" +

CurrentCulture.Name;

}

}

What do you mean by neutral cultures?

Answer:
Neutral cultures represent general languages, such as English or Spanish and a specific language and region.ASP.NET assigns that culture to all the threads running for that Web application.When user set culture attribute for a Web application in Web.config.ASP.NET maintains multiple threads for a Web application within the aspnet_wp.exe worker process. 

What is the advantage of using Windows authentication in a Web application?

Answer:

The advantage of Windows authentication:

1. Web application can use the exact same security that applies to your corporate network like user names, passwords, and permissions.

2. To access the Web application users logged on to the network. It is importent that user does\'nt logged on again.

What is the default authentication method when you create a new Web application project?

Answer:
Windows authentication is the default authentication method when you create a new Web application project.

How do you get a User Identity?

Answer:

Using the User objects Identity property. The Identity property returns an object that includes the user name and role information, as shown in the following code:


private void Page_Load(object sender, System.EventArgs e)

{

Label1.Text = User.Identity.IsAuthenticated.ToString();

Label2.Text = User.Identity.Name;

Label3.Text = User.Identity.AuthenticationType;

}

How do you determine, what is the role of the current user?

Answer:

The User object provides an IsInRole method to determine the role of the current user, as shown in the following example:

if(User.IsInRole(\"Administrators\"))

{

///////

}

Can you specify authorization settings both in Web.config and in IIS?

Answer:
Yes,It wil be done. For this, the IIS setting is evaluated first and then the setting in Web.config is evaluated. Hence we can say,the most restrictive setting will be used.

What are the 2 Layouts supported by a Web form in ASP.NET?

Answer:

1. Grid layout:  Pages using grid layout will not always display correctly in non-Microsoft browsers,and controls are placed exactly where they draw.It means they have absolute positions on the page. Use grid layout for Microsoft Windows style applications, in which controls are not mixed with large amounts of text.

2. Flow layout: Controls relative to other elements on the page.

Controls that appear after the new element move down if you add elements at run time.

Flow layout for document-style applications, in which text and controls are intermingled.

What is the difference between Literal and Lable Control?

Answer:

We use literals control if we want to typed text using HTML formating and without using property.We typed HTML code in .cs file when used literals.

Lable control when displayed already formated.Typed text can not be formated in .cs file.

What is smart navigation?

Answer:

Smart navigation is, cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.


What is the difference between Server.Transfer and Response.Redirect?

Answer:

1. Server.Transfer() performs server side redirection of the page avoiding extra round trip. While The Response. Redirect() method can be used to redirect the browser to specified url.

2. Server.Transfer is used to post a form to another page. Response.Redirect is used to redirect the user to another page or site.

Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?

Answer:

1. A DataSet can represent an entire relational database in memory, complete with tables, relations, and views. 

2. A DataSet is designed to work without any continuing connection to the original data source. 

3. Data in a DataSet is bulk-loaded, rather than being loaded on demand. 

Can you give an example of when you might use it?

Answer:
When you want to inherit (use the functionality of) another class. Base Class Employee. A Manager class could be derived from the Employee base class. 

Can the action attribute of a server-side <form> tag be set to a value and if not how can you possibly pass data from a form page to a subsequent page.

Answer:
No, You have to use Server.Transfer to pass the data to another page.

What is the role of global.asax.

Answer:
Store global information about the application

Whats a bubbled event?

Answer:
When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.

Describe the difference between inline and code behind.

Answer:
Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page. 

Which method do you invoke on the DataAdapter control to load your generated dataset with data?

Answer:
The .Fill() method 

Can you edit data in the Repeater control?

Answer:
No, it just reads the information from its data source 

Which template must you provide, in order to display data in a Repeater control?

Answer:
ItemTemplate 

How can you provide an alternating color scheme in a Repeater control?

Answer:
Use the AlternatingItemTemplate 

What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?

Answer:
You must set the DataSource property and call the DataBind method. 

Name two properties common in every validation control?

Answer:
ControlToValidate property and Text property

Where does the Web page belong in the .NET Framework class hierarchy?

Answer:
System.Web.UI.Page 

Where do you store the information about the user&#65533;s locale?

Answer:
System.Web.UI.Page.Culture

Can you give an example of what might be best suited to place in the Application Start and Session Start subroutines?

Answer:
This is where you can set the specific variables for the Application and Session objects.

What is the transport protocol you use to call a Web service?

Answer:
 SOAP is the preferred protocol. 

To test a Web service you must create a windows application or Web application to consume this service?

Answer:
The webservice comes with a test page and it provides HTTP-GET method to test.

Whats the difference between struct and class in C#?

Answer:

1. Structs cannot be inherited. 

2. Structs are passed by value, not by reference. 

3. Struct is stored on the stack, not the heap.

Where do the reference-type variables go in the RAM?

Answer:
The references go on the stack, while the objects themselves go on the heap. However, in reality things are more elaborate. 

What is the difference between the value-type variables and reference-type variables in terms of garbage collection?

Answer:
The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null. 

What is main difference between Global.asax and Web.Config?

Answer:
aASP.NET uses the global.asax to establish any global objects that your Web application uses. The .asax extension denotes an application file rather than .aspx for a page file. Each ASP.NET application can contain at most one global.asax file. The file is compiled on the first page hit to your Web application. ASP.NET is also configured so that any attempts to browse to the global.asax page directly are rejected. However, you can specify application-wide settings in the web.config file. The web.config is an XML-formatted text file that resides in the Web sites root directory. Through Web.config you can specify settings like custom 404 error pages, authentication and authorization settings for the Web site, compilation options for the ASP.NET Web pages, if tracing should be enabled, etc

What is SOAP and how does it relate to XML?

Answer:
The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls. Unless experience with SOAP is a direct requirement for the open position, knowing the specifics of the protocol, or how it can be used in conjunction with HTTP, is not as important as identifying it as a natural application of XML. 

Using XSLT, how would you extract a specific attribute from an element in an XML document?

Answer:
Successful candidates should recognize this as one of the most basic applications of XSLT. If they are not able to construct a reply similar to the example below, they should at least be able to identify the components necessary for this operation: xsl:template to match the appropriate XML element, xsl:value-of to select the attribute value, and the optional xsl:apply-templates to continue processing the document.

Whats a Windows process?

Answer:

Its an application thats running and had been allocated memory. 


What is typical about a Windows process in regards to memory allocation?

Answer:

Each process is allocated its own block of available RAM space, no process can access another process code or data. If the process crashes, it dies alone without taking the entire OS or a bunch of other applications down. 


Explain what relationship is between a Process, Application Domain, and Application?

Answer:
A process is an instance of a running application. An application is an executable on the hard drive or network. There can be numerous processes launched of the same application (5 copies of Word running), but 1 process can run just 1 application.

Define the possible implementations of distributed applications in .NET?

Answer:

.NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services. 


Give your idea when deciding to use .NET Remoting or ASP.NET Web Services?

Answer:

1. Remoting is a more efficient communication exchange when you can control both ends of the application involved in the communication process.  2. Web Services provide an open-protocol-based exchange of informaion.  Web Services are best when you need to communicate with an external organization or another (non-.NET) technology.


Do you know the proxy of the server object in .NET Remoting?

Answer:

This process is known as marshaling. It handles the communication between real server object and the client object. We can say that It is a fake copy of the server object that resides on the client side and behaves as if it was the server. 

 

What are remotable objects in .NET Remoting?

Answer:

1. They can be marshaled across the application domains.

2. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where  just a reference to an existing object is passed. 

In .NET Remoting, What are channels?

Answer:
Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred. 

What security measures exist for .NET Remoting?

Answer:
None. 

What is Singleton activation mode?

Answer:

A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime lease. 


How to configure a .NET Remoting object via XML file?

Answer:

It can be done via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config. 


How can you automatically generate interface for the remotable object in .NET?

Answer:
Use the Soapsuds tool.

What is the top .NET class that everything is derived from?

Answer:
System.Object. 

Difference between System.String and System.Text.StringBuilder classes?

Answer:

System.String is immutable.  System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed. 


Difference between the System.Array.Clone() and System.Array.CopyTo()?

Answer:
The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array.  The CopyTo() method copies the elements into another existing array.  Both perform a shallow copy.  A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array.  A deep copy (which neither of these methods performs) would create a new instance of each element\'s object, resulting in a different, yet identacle object.

What is the .NET collection class that allows an element to be accessed using a unique key?

Answer:
HashTable. 

What class is underneath the SortedList class?

Answer:
A sorted HashTable. 

How to prevent your class from being inherited by another class?

Answer:

We use the sealed keyword to prevent the class from being inherited. 


How to allowed a class to be inherited, but it must be prevent the method from being over-ridden?

Answer:
Just leave the class public and make the method sealed. 

Define abstract class?

Answer:

1. A class that cannot be instantiated.

2. An abstract class is a class that must be inherited and have the methods overridden.

3. An abstract class is essentially a blueprint for a class without any implementation


When you declared a class as abstract?

Answer:

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

2. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.  


Define interface class ?

Answer:
Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes. 

How to Specify the accessibility modifier for methods inside the interface?

Answer:

They all must be public, and are therefore public by default. 


What is the difference between an interface and abstract class ?

Answer:

1. In an interface class, all methods are abstract and there is no implementation.  In an abstract class some methods can be concrete.

2. In an interface class, no accessibility modifiers are allowed.  An abstract class may have accessibility modifiers. 

Tell me implicit name of the parameter that gets passed into the set property of a class?

Answer:

The data type of the value parameter is defined by whatever data type the property is declared as. 


What does the keyword virtual declare for a method?

Answer:

The method or property can be overridden. 


What are the two important TCP Socket classes?

Answer:
The Two important Socket classes are there : 

ServerSocket : ServerSocket is used for normal two-way socket communication.
Socket : Socket class allows us to read and write through the sockets.

getInputStream()
getOutputStream()

are the two methods available in Socket class.

How can we write o/p to a Socket?

Answer:
Writing Output to a Socket : 
The getOutputStream() method returns an output stream which writes data to the socket.
Most of the time you\'ll chain the raw output stream to some other output stream or writer class to more easily handle the data.

How can i read and write to a Socket?

Answer:
Reading and Writing to a Socket : 
It\'s unusual to only read from a socket. It\'s even more unusual to only write to a socket.
Most protocols require the client to both read and write.

What do you mean by Asynchronous in the terms of Socket?

Answer:
Asynchronous is basically defined as :

  1. Other protocols don\'t care and allow client requests and server responses to be freely intermixed.
  2. Java places no restrictions on reading and writing to sockets.
  3. One thread can read from a socket while another thread writes to the socket at the same time.

How can i Send and Receive the Data in Socket?

Answer:
Sending and Receiving the Data : 
Data is sent and received with output and input streams.
There are methods to get an input stream for a socket and an output stream for the socket.

public InputStream  getInputStream() throws  IOException

public OutputStream getOutputStream() throws IOException

There\'s also a method to close a socket:

public synchronized void close() throws IOException

How can i read Input from a Socket?

Answer:
Reading Input from a Socket : 

  1. The getInputStream() method returns an InputStream which reads data from the socket.
  2. We can use all the normal methods of the InputStream class to read this data.
  3. Most of the time we\'ll chain the input stream to some other input stream or reader object to more easily handle the data.

How can we pick the IP Address?

Answer:
Picking an IP address : 

  1. The last two constructors also specify the host and port you\'re connecting from.
  2. On a system with multiple IP addresses, like many web servers, this allows you to pick your network interface and IP address.

How can we choose the local port?

Answer:
Choosing a Local Port : 

  1. We can also specify a local port number,
  2. Setting the port to 0 tells the system to randomly choose an available port.
  3. If we need to know the port we\'re connecting from, we can always get it with getLocalPort().

Socket webMetalab = new Socket(\"metalab.unc.edu\", 80, \"calzone.oit.unc.edu\", 0);

What is the difference between the File and RandomAccessFile classes?

Answer:
The RandomAccessFile class basically  provides the methods which is needed to directly access data contained in any part of a file. The File class encapsulates the files and directories of the local file system. 

How can we choose the host and the port?

Answer:
Choosing the Host and the Port : 

We must at least specify the remote host and port to connect to.
The host may be specified as either a string like \"utopia.poly.edu\" or as an InetAddress object.
The port should be an int between 1 and 65535.

      Socket webMetalab = new          
      Socket(\"metalab.unc.edu\", 80);
We cannot just connect to any port on any host. The remote host must actually be listening for connections on that port.
We can use the constructors to determine which ports on a host are listening for connections.

How can we open the Sockets?

Answer:
Opening Sockets :  

All the constructors throw an IOException if the connection can\'t be made for any reason.

The Socket() constructors do not just create a Socket object. They also help to connect the underlying socket to the remote server.

What is the RMI?

Answer:
RMI is basically stands for Remote Method Invocation. RMI is a the mainly use for set the APIs that allows to build distributed applications. RMI uses interfaces to define remote objects to turn local method invocations into remote method invocations.

When Mal formed URL Exception and Unknown Host Exception throws?

Answer:
When the specified URL is not connected then the URL throw MalformedURLException throws that time when specified URL is not connected and  In the case of UnknownHostException throws when If InetAddress\'s methods getByName and getLocalHost are unable to resolve the host name .

What information is needed to create a TCP Socket?

Answer:
Some information is needed to create a TCP Socket  

Which is following here :

  1. The Local System\'s IP Address and Port Number.
  2. The Remote System\'s IPAddress and Port Number.

What Is a Socket in Java Networking and RMI?

Answer:
A socket is one end-point of a two-way communication link between two programs running on the network. 

A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent.

Socket classes is basically a type of class, Which is used to represent the connection between a client program and a server program. The java.net package provides two classes :

Socket
ServerSocket.
     
Which implement the client side of the connection and the server side of the connection, respectively.

How do I make a connection to URL?

Answer:
Firstly We have a URL instance and then invoke open Connection on it. URLConnection is a basically abstract class, which means we can\'t directly create instances of it using a constructor. 

We have to invoke openConnection method on a URL instance, to get the right kind of connection for our URL. Eg.
URL url ;

URLConnection connection;
try {
url = new URL(\"\");
connection = url.openConnection();
} catch (MalFormedURLException e) { }

What is the difference between URL instance and URLConnection instance?

Answer:
A URL basically stands for UNIFORM RESOURCE LOCATOR . 

Its instance represents the location of a resource, and a URL Connection instance represents a link for accessing or communicating with the resource at the location.

What interface must an object implement before it can be written to a stream as an object?

Answer:
Two type of object which is interface must on object implement before it can be written to a stream as an object :

Serializable interface
Externalizable interface

How can i connect to the Socket with the help of constructor?

Answer:
Sockets connection is accomplished with the help of constructors.

public Socket(String host, int port) throws UnknownHostException,IOException

public Socket(InetAddress address, int port) throws IOException

public Socket(String host, int port, InetAddress localAddr, int localPort)throws IOException

public Socket(InetAddress address, int port, InetAddress localAddr, int localPort) throws IOException

What is the use of The java.net.Socket class?

Answer:
The java.net.Socket is mainly a class, which is very useful class, this is defined as :

  1. We can connect to remote machines;
  2. We can send data;
  3. We can receive data;
  4. We can close the connection.
  5. The java.net.Socket class allows us to create socket objects that perform all four fundamental socket operation.
  6. Each Socket object is associated with exactly one remote host. To connect to a different host, We must create a new Socket object.

What are the Socket Operations?

Answer:
Socket have a four fundamental operations .

Which is  following as :

  1. Connect to a remote machine
  2. Send data
  3. Receive data
  4. Close the connection

What is the Sockets?

Answer:
Socket is the basically defined as : 

  1. A socket is a mainly use for the transmission of data b/w two hosts It is reliable connection for the transmission.
  2. Sockets isolate programmers from the details of packet encoding, lost and retransmitted packets, and packets that arrive out of order.
  3. There are limits. Sockets are more likely to throw IOExceptions than files.

What is the Java Authentication and Authorization Service (JAAS) 1.0?

Answer:
The Java Authentication and Authorization Service (JAAS) is basically a use for the provides the facility to run the java applications for the authenticate way to the authorized person.  

JAAS is a Java programing language version of the standard Pluggable Authentication Module (PAM) framework that extends the Java 2 platform security architecture to support user-based authorization.

How do I use a proxy server for HTTP requests?

Answer:
When a Java applet under the control of a browser ,such as Netscape or Internet Explorer fetches content via a URLConnection, it will automatically and transparently use the proxy settings of the browser.
If we\'re writing an application, however, we\'ll have to manually specify the proxy server settings. we can do this when running a Java application, or we can write code that will specify proxy settings automatically for the user (providing we allow the users to customize the settings to suit their proxy servers).

To specify proxy settings when running an application, use the -D parameter :
jre -DproxySet=true -DproxyHost=myhost -DproxyPort=myport MyApp

Alternately, our application can maintain a configuration file, and specify proxy settings before using a URLConnection :

// Modify system properties
Properties sysProperties = System.getProperties();

// Specify proxy settings
sysProperties.put(\"proxyHost\", \"myhost\");
sysProperties.put(\"proxyPort\", \"myport\");
sysProperties.put(\"proxySet\",  \"true\");

What is a malformed url, and why is it exceptional?

Answer:
When we create an instance of the java.net.URL class, its constructor can throw a MalformedURLException. This occurs when the URL is invalid. 

When it is thrown, it isn\'t because the host machine is down, or the URL path points to a missing file; a malformed URL exception is thrown when the URL cannot be correctly parsed.

How do I prevent caching of HTTP requests?

Answer:
Caching will be enabled by default. we must use a URLConnection, rather than the URL.openStream() method, and explicitly specify that we do not want to cache the requests. 

This is achieved by calling the URLConnection.setUseCaches(boolean) method with a value of false.

What is thin client ?

Answer:
A thin client is basically a type of system, which is run a very light operating system with no local system administration and Its also executes applications delivered over the network.

What is TCP/IP ?

Answer:
TCP/IP is stands for Transmission Control Protocol based on Ip . This is an Internet protocol that provides for the reliable delivery of streams of data from one host to another host.

What is Technology Compatibility Kit (TCK) ?

Answer:
A test suite, a set of tools, and other requirements used to certify an implementation of a particular Sun technology conformant both to the applicable specifications and to Sun or Sun-designated reference implementations.

What is Web module ?

Answer:
A Deployable unit that consists of one or more Web components, other resources, and a Web application deployment descriptor contained in a hierarchy of directories and files in a standard Web application format.

How many types are Socket Options?

Answer:
Several methods set various socket options. Most of the time the defaults are fine.

public void  -  setTcpNoDelay(boolean on) throws SocketException
public boolean  -  getTcpNoDelay() throws SocketException
public void  -  setSoLinger(boolean on, int val) throws SocketException
public int  -   getSoLinger() throws SocketException
public void  -  setSoTimeout(int timeout) throws SocketException
public int  -   getSoTimeout() throws SocketException

How can i use Get Method ? and why we use this method?

Answer:
Get method is basscially use for the returning the information about socket :  

public InetAddress getInetAddress()
public InetAddress getLocalAddress()
public int getPort()
public int getLocalPort()

Finally there\'s the usual toString() method:

public String toString()

Should I use ServerSocket or DatagramSocket in my applications?

Answer:
DatagramSocket allows a server to accept UDP packets, whereas ServerSocket allows an application to accept TCP connections. It depends on the protocol we\'re trying to implement. If we\'re creating a new protocol.

DatagramSockets communicate using UDP packets. These packets don\'t guarantee delivery - we\'ll need to handle missing packets in our client/server.

ServerSockets communicate using TCP connections. TCP guarantees delivery, so all we need to do is have our applications read and write using a socket\'s InputStream and OutputStream.

How do I get the IP address of a machine from its hostname?

Answer:
The InetAddress class is able to resolve IP addresses for us. Obtain an instance of InetAddress for the machine, and call the getHostAddress() method, which returns a string in the xxx.xxx.xxx.xxx address form.

InetAddress inet = InetAddress.getByName(\"www.r4r.xo.in\");
System.out.println (\"IP  : \" + inet.getHostAddress());

What&#65533;s the difference between JNDI lookup(), list(), listBindings(), and search()?

Answer:
These are defined as : 
lookup() It attempts to find the specified object in the given context. It looks for a single, specific object and either finds it in the current context or it fails.

list() It attempts to return an enumeration of all of the NameClassPair\'s of all of the objects in the current context. It\'s a listing of all of the objects in the current context but only returns the object\'s name and the name of the class to which the object belongs.

listBindings() It attempts to return an enumeration of the Binding\'s of all of the objects in the current context. It\'s a listing of all of the objects in the current context with the object\'s name, its class name, and a reference to the object itself.

search()  It attempts to return an enumeration of all of the objects matching a given set of search criteria. It can search across multiple contexts (or not). It can return whatever attributes of the objects that you desire. It\'s by far the most complex and powerful of these options but is also the most expensive.

Components of JNDI ?

Answer:
There are many Components which is defined as : 

Naming Interface The naming interface organizes information hierarchically and maps human-friendly names to addresses or objects that are machine-friendly. It allows access to named objects through multiple namespaces.

Directory Interface JNDI includes a directory service interface that provides access to directory objects, which can contain attributes, thereby providing attribute-based searching and schema support.

Service Provider Interface JNDI comes with the SPI, which supports the protocols provided by third parties.

What is the Max amount of information that can be saved in a Session Object?

Answer:
As such there is no limit on the amount of information that can be saved in a Session Object. Only the RAM available on the server machine is the limitation. 

The only limit is the Session ID length(Identifier), which should not exceed more than 4K.

If the data to be store is very huge, then it\'s preferred to save it to a temporary file onto hard disk, rather than saving it in session.

Internally if the amount of data being saved in Session exceeds the predefined limit, most of the servers write it to a temporary cache on Hard disk.

What is the function of T3 in WebLogic Server?

Answer:
T3 provides  is basically a framework for WebLogic Server messages that support for enhancements. 

These enhancements include abbreviations and features, such as object replacement, that work in the context of WebLogic Server clusters and HTTP and other product tunneling.

T3 predates Java Object Serialization and RMI, while closely tracking and leveraging these specifications.

T3 is a superset of Java Object. Serialization or RMI; anything we can do in Java Object Serialization and RMI can be done over T3.

T3 is mandated between WebLogic Servers and between programmatic clients and a WebLogic Server cluster. HTTP and IIOP are optional protocols that can be used to communicate between other processes and WebLogic Server.

It depends on what you want to do. For example, when we want to communicate between a browser and WebLogic Server-use HTTP, or an ORB and WebLogic Server-IIOP.

How do I convert a numeric IP address like 192.19.98.38 into a hostname like java.sun.com?

Answer:
String hostname = InetAddress.getByName(\"192.19.98.38\").getHostName();

How can I find out the current IP address for my machine?

Answer:
The InetAddress has a static method called getLocalHost() which will return the current address of the local machine. We can then use the getHostAddress() method to get the IP address.

InetAddress local = InetAddress.getLocalHost();

// Print address
System.out.println (\"Local IP : \" + local.getHostAddress());

How do I perform a hostname lookup for an IP address?

Answer:
The InetAddress class contains a method that can return the domain name of an IP address. We need to obtain an InetAddress class, and then call its getHostName() method. This will return the hostname for that IP address. Depending on the platform, a partial or a fully qualified hostname may be returned.

InetAddress inet = InetAddress.getByName(\"209.200.240.21\");
System.out.println (\"Host: \" + inet.getHostName())

How can I find out who is accessing my server?

Answer:
If we\'re using a DatagramSocket, every packet that we receive will contain the address and port from which it was sent.
DatagramPacket packet = null;

// Receive next packet
myDatagramSocket.receive ( packet );

// Print address + port
System.out.println (\"Packet from : \" +
    packet.getAddress().getHostAddress() + \':\' + packet.getPort());


If we\'re using a ServerSocket, then every socket connection we accept will contain similar information. The Socket class has a getInetAddress() and getPort() method which will allow we to find the same information.

Socket mySock = myServerSocket.accept();

// Print address + port
System.out.println (\"Connection from : \" +
    mySock.getInetAddress().getHostAddress() + \':\' + mySock.getPort());   

What are socket options, and why should I use them?

Answer:
Socket options give developers greater control over how sockets behave. Most socket behavior is controlled by the operating system, not Java itself, but as of JDK1.1, you can control several socket options, including SO_TIMEOUT, SO_LINGER, TCP_NODELAY, SO_RCVBUF and SO_SNDBUF.

These are advanced options, and many programmers may want to ignore them. That\'s OK, but be aware of their existence for the future. You might like to specify a timeout for read operations, to control the amount of time a connection will linger for before a reset is sent, whether Nagle\'s algorithm is enabled/disabled, or the send and receive buffers for datagram sockets.

When my client connects to my server, why does no data come out?

Answer:
This is basically a type of common problem, made more difficult by the fact that the fault may lie in either the client, or the server, or both. The first step is to try and isolate the cause of the problem, by checking whether the server is responding correctly.

If we\'re writing a TCP service, then you can telnet to the port the server uses, and check to see if it is responding to data. If so, then the fault is more than likely in the client, and if not, we\'ve found our problem. A debugger can be very helpful in tracking down the precise location of server errors. We could try jdb, which comes with JDK, or use an IDE\'s debugger like Visual J++ or Borland JBuilder.

If our fault looks like it is in the client, then it can often be caused by buffered I/O. If we\'re using a buffered stream, or a writer, We may need to manually flush the data. Otherwise, it will be queued up but not sent, causing both client and server to stall. The problem can even be intermittent, as the buffer will flush sometimes  but not other times.

What is the cause of a NoRouteToHostException?

Answer:
Basically It means that there isn\'t an active Internet connection through which a socket connection may take place, or that there is a nasty little firewall in the way. 

Firewalls are the bane of users and developers alike, while useful for security, they make legitimate networking software harder to support.java/java_network_programming/jnpfaq.txt
our best option is to try using a SOCKS proxy, or to use a different protocol, like HTTP.

If we still have firewall problems, we can manually specify a HTTP proxy server.


This is a common problem, made more difficult by the fact that the fault may lie in either the client, or the server, or both. The first step is to try and isolate the cause of the problem, by checking whether the server is responding correctly.

How can I fetch files using HTTP?

Answer:
The Easiest way to fetch files using HTTP is to use the java.net.URL class. The openStream() method will return an InputStream instance, from which the file contents can be read. For added control, We can use the openConnection() method, which will return a URLConnection object.

Here\'s a brief example that demonstrates the use of the java.net.URL.openStream() method to return the contents of a URL specified as a command line parameter.

import java.net.*;
import java.io.*;
public class URLDemo
{
    public static void main(String args[]) throws Exception
    {
        try
        {
        // Check to see that a command parameter was entered
            if (args.length != 1)
            {
                 // Print message, pause, then exit
                 System.err.println (\"Invalid command parameters\");
                 System.in.read();
                 System.exit(0);
            }

            // Create an URL instance
            URL url = new URL(args[0]);

            // Get an input stream for reading
            InputStream in = url.openStream();

            // Create a buffered input stream for efficency
            BufferedInputStream bufIn = new BufferedInputStream(in);

            // Repeat until end of file
            for (;;)
            {
                int data = bufIn.read();

                // Check for EOF
                if (data == -1)
                    break;
                else
                    System.out.print ( (char) data);
            }
        }
        catch (MalformedURLException mue)
        {
            System.err.println (\"Invalid URL\");
        }
        catch (IOException ioe)
        {
            System.err.println (\"I/O Error - \" + ioe);
        }
    }
}

How do I handle timeouts in my networking applications?

Answer:
We can use socket options to generate a timeout after a read operation blocks for a specified length of time. This is by far the easiest method of handling timeouts. 

A call to the java.net.Socket.setSoTimeout() method allows we to specify the maximum amount of time a Socket I/O operation will block before throwing an InterruptedIOException.

This allows you to trap read timeouts, and handle them correctly. If we\'re trying to handle connection timeouts, or if our application must support earlier versions of Java, then another option is the use of threads.

Multi-threaded applications can wait for timeouts, and then perform some action . However, we as a programmer should avoid writing complex multi-threaded code-particularly in our clients. There\'s usually an easy way to encapsulate the complexity of multi-threading, and provide a simple non-blocking I/O version

How do I control the amount of time a socket will linger before resetting?

Answer:
When a socket wishes to terminate a connection it can \"linger\", allowing unsent data to be transmitted, or it can \"reset\" which means that all unsent data will be lost. 

We can explicitly set a delay before a reset is sent, giving more time for data to be read, or you can specify a delay of zero, meaning a reset will be sent as the java.net.Socket.close() method is invoked.The socket option SO_LINGER controls whether a connection will be aborted, and if so, the linger delay.

Use the java.net.Socket.setSoLinger method, which accepts as parameters a boolean and an int.

The boolean flag will activate/deactivate the SO_LINGER option, and the int will control the delay time.

What does the java.net.Socket.setTcpNoDelay method do, and what is Nagle\'s algorithm?

Answer:
This method controls the socket option TCP_NODELAY, which allows applications to enable or disable Nagle\'s algorithm. Nagle\'s algorithm,Conserves bandwidth by minimizing the number of segments that are sent. When applications wish to decrease network latency and increase performance, they can disable Nagle\'s algorithm. Data will be sent earlier, at the cost of an increase in bandwidth consumption.

How do I implement a (FTP/HTTP/Telnet/Finger/SMTP/POP/IMAP/..../) client/server?

Answer:
Our first step towards creating such systems will be to read the relevant Request For Comments (RFCs) document. There are specific search engines,Which will allow we to search for the name of a protocol, and to then read relevant documents. These RFCs describe the protocol we wish to implement.

How do I implement PING in Java?

Answer:
Java includes support for UDP and TCP sockets. PING requires support for the Internet Control Message Protocol (ICMP). Our only choice, is to use native code, or to use java.lang.Runtime to execute an external ping application. We won\'t be able to develop a 100% Pure implementation.NB - A native implementation that uses the Java Native Interface (JNI) is available for PING, in both English and Spanish.

How can I send/receive email from Java?

Answer:
We can choose to implement Simple Mail Transfer Protocol (SMTP), to send email, and either POP or IMAP to receive email. However, an easier alternative is to use the JavaMail API, which provides a set of classes for mail and messaging applications. Royalty-free implementations of the API are now available from Sun for SMTP, POP and IMAP and many other mail systems are supported by third parties.

What is transaction isolation level ?

Answer:
Transaction isolation level is the basically as a  degree to which the intermediate state of the data being modified by a transaction is visible to other concurrent transactions and data being modified by other transactions is visible to it.

What is transaction manager ?

Answer:
Transaction manager is basically Provides the services and management functions required to support transaction demarcation, transactional resource management, synchronization, and transaction context propagation.

What is Unicode ?

Answer:
Unicode is the very imp for the java, It is 16-bit character set defined by ISO 10646. See also ASCII. All source code in the Java programming environment is written in Unicode.

What is URI ?

Answer:
URI basically stands for Uniform Resource Identifier. A compact string of characters for identifying an abstract or physical resource. A URI is either a URL or a URN. URLs and URNs are concrete entities that actually exist, A URI is an abstract super class.

What is URL ?

Answer:
URL basically stands for the Uniform Resource Locator. A standard for writing a text reference to an arbitrary piece of data in the WWW. A URL looks like \"protocol://host/localinfo\" where protocol specifies a protocol to use to fetch the object , host specifies the Internet name of the host on which to find it, and local info is a string passed to the protocol handler on the remote host.

What is URN ?

Answer:
URN basically stands for the Uniform Resource Name. A unique identifier that identifies an entity, but doesn\'t tell where it is located. A system can use a URN to look up an entity locally before trying to find it on the Web. It also allows the Web location to change, while still allowing the entity to be found.

What is virtual machine ?

Answer:
An abstract specification for a computing device that can be implemented in different ways, in software or hardware. We compile to the instruction set of a virtual machine much like we\'d compile to the instruction set of a microprocessor. The Java virtual machine consists of a byte code instruction set, a set of registers, a stack, a garbage-collected heap, and an area for storing methods.

What is world readable files ?

Answer:
Files is the bassically a part of the  file system that can be viewed by any user. For example : files residing on Web servers can only be viewed by Internet users if their permissions have been set to world readable.

What is Embedded Java Technology ?

Answer:
The availability of Java 2 Platform, Micro Edition technology under a restrictive license agreement that allows a licensee to leverage certain Java technologies to create and deploy a closed-box application that exposes no APIs.

What is URL path ?

Answer:
A URL path basically consists of the context path + servlet path + path info, where Context path is the path prefix associated with a servlet context of which the servlet is a part. The path of a URL passed by an HTTP request to invoke a servlet.  If this context is the default context rooted at the base of the Web server\'s URL namespace, the path prefix will be an empty string. Otherwise, the path prefix starts with a / character but does not end with a / character. Servlet path is the path section that directly corresponds to the mapping that activated this request. This path starts with a / character. Path info is the part of the request path that is not part of the context path or the servlet path.

What is user data constraint ?

Answer:
User Data Constraints bassically indicates how data between a client and a Web container should be protected. The protection can be the prevention of tampering with the data or prevention of eavesdropping on the data.

What is user (security) ?

Answer:
A user security is bassically An individual identity that has been authenticated. A user can have a set of roles associated with that identity, which entitles the user to access all resources protected by those roles.

What is virtual host ?

Answer:
virtual host is bassically Multiple hosts plus domain names mapped to a single IP address.

Define Network?

Answer:
The network is a set of devices which is connected by physical media links. A network recursively is a connection of two or more nodes by a physical link or two or more networks connected by one or more nodes.

What is a Link?

Answer:

At the lowest level, a network can consist of two or more computers directly connected by some physical medium such as coaxial cable or optical fiber. Such a physical medium is called as Link.


What is a node?

Answer:
A network can consist of two or more computers directly connected by some physical medium such as coaxial cable or optical, fiber cable. Such a physical medium is called as Links and the computer it connects is called as Nodes.

What is a gateway or Router?

Answer:
A node that is connected to two or more networks is commonly called as router or Gateway. It generally forwards message from one network to another.

What is point-point link?

Answer:
If the physical links are limited to a pair of nodes it is said to be point-point link.

What are the advantages of Distributed Processing?

Answer:

1. Security

2. Encapsulation

3. Distributed database

4. Faster Problem solving

5. Security through redundancy

6. Collaborative Processing


What are the criteria necessary for an effective and efficient network?

Answer:

a. Performance

   It can be measured in many ways, including transmit time and response time. 

b. Reliability

   It is measured by frequency of failure, the time it takes a link to recover from a failure, and the network\'s robustness.

c. Security

   Security issues includes protecting data from unauthorized access and virues.


Define Bandwidth and Latency?

Answer:
Network performance is measured in Bandwidth (throughput) and Latency (Delay). Bandwidth of a network is given by the number of bits that can be transmitted over the network in a certain period of time. Latency corresponds to how long it t5akes a message to travel from one end off a network to the other. It is strictly measured in terms of time.

What is a peer-peer process?

Answer:
The processes on each machine that communicate at a given layer are called peer-peer process.

When a switch is said to be congested?

Answer:
It is possible that a switch receives packets faster than the shared link can accommodate and stores in its memory, for an extended period of time, then the switch will eventually run out of buffer space, and some packets will have to be dropped and in this state is said to congested state.

What is semantic gap?

Answer:
Defining a useful channel involves both understanding the applications requirements and recognizing the limitations of the underlying technology. The gap between what applications expects and what the underlying technology can provide is called semantic gap.

Define the terms Unicasting, Multiccasting and Broadcasting?

Answer:

If the message is sent from a source to a single destination node, it is called Unicasting.

If the message is sent to some subset of other nodes, it is called Multicasting.

If the message is sent to all the m nodes in the network it is called Broadcasting.

What is Multiplexing?

Answer:
Multiplexing is the set of techniques that allows the simultaneous transmission of multiple signals across a single data link.

What is FDM?

Answer:
FDM is an analog technique that can be applied when the bandwidth of a link is greater than the combined bandwidths of the signals to be transmitted.

What is WDM?

Answer:
WDM is conceptually the same as FDM, except that the multiplexing and demultiplexing involve light signals transmitted through fiber optics channel.

What is TDM?

Answer:
TDM is a digital process that can be applied when the data rate capacity of the transmission medium is greater than the data rate required by the sending and receiving devices.

What is Synchronous TDM?

Answer:
In STDM, the multiplexer allocates exactly the same time slot to each device at all times, whether or not a device has anything to transmit.

List the layers of OSI ?

Answer:

1. Physical Layer

2. Data Link Layer

3. Network Layer

4. Transport Layer

5. Session Layer

6. Presentation Layer

7. Application Layer

Which layers are network support layers?

Answer:

1. Physical Layer

2. Data link Layer and 

3. Network Layers

Which layers are user support layers?

Answer:

1. Session Layer

2. Presentation Layer and 

3. Application Layer