Dot.Net Interview Quations in TCS

1)Code for updating the database by entering the data into textboxes in
aspx form?
Ans:There are several ways to do so. If you are using a dataset, you can 
write changes to the dataset and then call the data adapter to send 
changes from the dataset to the database.
Ans2:This walkthrough illustrates how to create a Web Forms page that reads 
and writes data to a database using SQL statements. For the walkthrough,
 you will work with the Categories table of the SQL Server Northwind 
database. In the page, you can select a record, edit it, and then save 
it to the database.
...........................................................
2)How do you handle errors in stored procedures?
 Ans:http://articles.techrepublic.com.com/5100-10878_11-1045786.html
............................................................... 
3)How did you implemented classes in your project?
Ans:
...............................................
4)How did you implemented interfaces in your project?
Ans:
using ThirdPartyLibrary; // The only using statement
namespace Interfaces
{
   public interface IConnection
   {
       ...
       BugFactory BugFactory();
   }
}
.................................................. 
5)How did you call javascript from c#?
Ans:<SCRIPT LANGUAGE="JavaScript" src="javascript/projectJS.js">
..................................................
6)Differences between 1.1 and 2.0 versions of .net?
Ans: Some Importent New Features added in .net2.0
(a) Master Pages
(b) PreCompilation
(c) Sharing code in the application
(d) Themes and Skins
(Breaf Descriptin visit "http://www.geekinterview.com/question_details/33965")
.........................................................................................................................  
7)Caching types?
Ans:3 types of catching: 1.data caching 2.output caching 3.fragment caching
.................................................................................................................
8)Session state modes?
Ans:(1) InProc Mode or InProceess this is the clarification of 
InProc.

(2) SQL Server Mode

(3) StateServer Mode -->StateServer is memory based mode. 

(4) Out of process Mode -->This mode is best used when 
performance is important but you can't guarantee which 
server a user will request an application from.

(5) Off Mode -->Disable Session State.
......................................................................................... 
9)what is the connection between IIS and client browser?
How do they communicate?
Ans:IIS is a web server. The client browser makes HTTP connections to a server machine, which IIS handles and responds to.
............................................................
10)which session statemode u used in your current project?why?
Ans:
..........................................................
11)How did you handle exceptions in sql server?
Ans:Visit This Site Breaf Answer
"http://challagullainfo.blogspot.com/2010/12/error-handling-in-sqlserver.html"
................................................................
12)Two methos with same name in parent and inherited classes. If you create
an objct of child which method will be invoked?
Ans:This is not possible...

suppose you can use this method useing shadows keyword....

after it's invoke parent class function.
.............................................................................................................. 

13)Garbage colllector how it works in Background? 
Ans: 
..........................................................................................
14)Asp.net page life cycle? Explain briefly?
Ans:Page_Init -- Page Initialization 

 LoadViewState -- View State Loading 

 LoadPostData -- Postback data processing 

 Page_Load -- Page Loading 

 RaisePostDataChangedEvent -- PostBack Change Notification 

 RaisePostBackEvent -- PostBack Event Handling 

 Page_PreRender -- Page Pre Rendering Phase 

 SaveViewState -- View State Saving 

 Page_Render -- Page Rendering 

 Page_UnLoad -- Page Unloading
.......................................................
15)Asp.net page events?
Ans:
Listing 1: Page Events Summary

MethodPostBackControls

ConstructorAlwaysAll
AddParsedSubObjectAlwaysAll
DeterminePostBackModeAlwaysPage
OnInitAlwaysAll

LoadPageStateFromPersistenceMediumPostBackPage
LoadViewStatePostBackAll
ProcessPostData1PostBackPage
OnLoadAlwaysAll

ProcessPostData2PostBackPage
RaiseChangedEventsPostBackPage
RaisePostBackEventPostBackPage
OnPreRenderAlwaysAll

SaveViewStateAlwaysAll
SavePageStateToPersistenceMediumAlwaysPage
RenderAlwaysAll
OnUnloadAlwaysAll

........................................................................... 16)How iis recognize that which web application we are requesting?
Ans:I guess from the url you are 
requesting. In IIS we have virtual directories pointing to the url's , 
so depending on the url IIS knows which web application you are 
requesting. Ans2:IN IIS While creating Virtual directory
 we can mention framework version and while running framework will 
identify which language from PAGE Directive
........................................................
17)How iis recognize that web application is developed in
which language?
Ans:
.........................................................
18)How iis will use authentication?
Ans:Assuming you have the latest and greatest IIS, you have several choices 
        when working with authentication including: 
        
  • IIS NT Challenge Response
    • A good choice if you are on a Windows Network. Can require the use of IE. There is no proxy-server between the browser and the server.
  • IIS Basic Authentication
    • Can expose your NT usernames and passwords unless all connections are over SSL.
  • A Basic Authentication filter such as AuthentiX
    • Cannot compromise NT accounts. High performance. Large numbers of users. Can validate against ODBC or internal database. Many advanced features.
  • Write your own filter
    • Flexible, but resource intensive to build.
  • Cookie based authentication with ASP pages
    • Only protects ASP pages. Can be slow. Requires cookies. Cookie-based systems can be susceptible to spoofing.
  • Self-Authenticating ISAPI dlls, CGI-scripts using Basic Authentication.
    • Good performance, all content generated though a single URL. Doesn't use conventional directory/file/html format.
  • Certificate based
    Secure, but intimidating for webmasters and surfers alike. Requires SSL.(Visit Website "http://www.devguru.com/features/tutorials/authentication/authentication.asp")
    ..........................................................................................................................................
 19)Is it pages will compile in server?
Ans:Yes the code behind compiles on server with the first call and product dlls.
.................................................................
20)In server pages will compile or execute?
Ans:
After the pages have been compiled on dlls, on every call the system use the dll + aspx to create the page. You can call it execution, maybe not of the page but of the pool.
Actually the pool, use the strings-html that find on aspx, with the dll of the page that is used to make the cycle of an aspx page and create the final html
.................................................................................................................
21)What is diff between compile and execute?
Ans:

C is a high level language which means it is meant for humans to understand not computers. For a computer to understand a C program it has to be compiled, that is changed into machine language. Once a program is in machine language then the computer can understand it and perform the actions it describes (that is to run the program). A C program need only be compiled once but (once compiled) it can be run any number of times.


.......................................................................................................................
22)What is appdomain?
Ans:
An application domain is the CLR equivalent of an operation system’s
process. An application domain is used to isolate applications from one
another. This is the same way an operating system process works. The
separation is required so that applications do not affect one another.
This separation is achieved by making sure than any given unique
virtual address space runs exactly one application and scopes the
resources for the process or application domain using that addess space.

More Inforamation Visit:
("http://www.c-sharpcorner.com/UploadFile/nagryum/Appdomain07102007081415AM/Appdomain.aspx"/
"http://codebetter.com/raymondlewallen/2005/04/04/what-is-an-application-domain-an-explanation-for-net-beginners/")
...............................................................................................................................................
23)What is aspnet_issapi.dll?
Ans:
- ISAPI (Internet Server Application Program Interface) is a set of Windows program calls that let you write a Web server application that will run faster than a common gateway interface (CGI) application. A disadvantage of a CGI application (or "executable file," as it is sometimes called) is that each time it is run, it runs as a separate process with its own address space, resulting in extra instructions that have to be performed, especially if many instances of it are running on behalf of users. Using ISAPI, you create a dynamic link library (DLL) application file that can run as part of the Hypertext Transport Protocol (HTTP) application's process and address space. The DLL files are loaded into the computer when HTTP is started and remain there as long as they are needed; they don't have to be located and read into storage as frequently as a CGI application.
Existing CGI applications can be converted into ISAPI application DLLs without having to rewrite their logic. However, they do need to be written to be thread-safe so that a single instance of the DLL can serve multiple users.

A special kind of ISAPI DLL is called an ISAPI filter, which can be designated to receive control for every HTTP request. You can create an ISAPI filter for encryption or decryption, for logging, for request screening, or for other purposes.

...........................................................................................................................................
24)What is aspnet_wp.exe?
Ans:
For faster execution of ASP.NET applications that are primarily based to be hosted on IIS servers, the aspnet_wp.exe
 comes into picture. This file (aspnet_wp.exe) is actually the ASP.NET 
worker process. The worker process is introduced to actually share the 
load on the IIS, so that application domains and other services may be 
maintained by a single worker process.
The aspnet_wp.exe worker 
process is a part of the Microsoft ASP.NET framework, and it is 
responsible for most of the technical processes in the ASP.NET 
framework. There may be multiple instances of ASP.NET worker process 
running on IIS 6 (a process running as inetinfo.exe), depending 
on multiple application pools. The worker process handles all the 
requests passed to the ASP.NET framework, so we may say that its 
actually the main engine that handles all requests pertaining to ASPNET.
 For example, when a request for an .aspx page is recieved by the IIS 
server, the dll called aspnet_isapi.dll passes this request to the aspnet_wp.exe worker process.   (Visit "http://forums.asp.net/t/1300149.aspx")
............................................................................
25)What is application?
Ans:the act of bringing something to bear; using it for a particular purpose;
...........................................................................
26)What is view state? Ans:Web Forms pages provide the ViewState property as a built-in structure for automatically 
retaining values between multiple requests for the same page. View state is 
maintained as a hidden field in the page. For more information, see ASP.NET State Management Overview.
You can use view state 
to store your own page-specific values across round trips when the page posts 
back to itself. For example, if your application is maintaining user-specific 
information — that is, information that is used in the page but is not 
necessarily part of any control — you can store it in view state.
............................................................................
27)Why we use view state?
Ans:
1.No server resources are required   The view state is contained in a structure within the page code.
2.Simple implementation   View state does not require any custom programming to use. It is on by default to maintain state data on controls.
3.Enhanced security features   The values in view state are hashed, compressed, and encoded for Unicode implementations, which provides more security than using hidden fields.
.........................................................................................................................
28)What are the validation controls? Explain the use of
validation controls?
Ans:
The .NET
    Framework provides validation controls that validate user input and display
    appropriate error messages whenever invalid data is encountered in a validation
    control 
Range Validator...to valaidate that a value entered is between some range of values
Required Field Validator..to validate that a field in not left blank
Regular Expression Validator..to validate that the value entered is in a specific format.
Custom Validator...we can define our own validations.
Compare Validator...to compare to values and validate them.
Validation Summary...to display the error message of the validations.
..........................................................................................................................
29)Validation controls are client side or server side? 
Ans: ASP.NET validation controls provide two
 ways of validation: Server-side or Client-side. The nice thing about 
these Validation controls is that they will preform client-side 
validation when it detects the browser is able (unless client-side 
validation has been disabled),thus reducing roundtrips. And it will 
preform server-side where necessary. This client-side/server-side 
detection and validation is done without extra work
.............................................
30)How to make raise JavaScript at the page is displaying?
 (which page event will use eg: page_load) ?
Ans:
..........................................................
31)What is session?
Ans:
A Session refers to all the request that a single client makes to
a server. A session is specific to the user and for each user a new session is
created to track all the request from that user. Every user has a separate
session and separate session variable is associated with that session. In case
of web applications the default time-out value for session variable is 20
minutes, which can be changed as per the requirement. 
More Info:"http://www.roseindia.net/interviewquestions/servlet/session-tracking.shtml" 
....................................................................
32) Is it necessary to create session object?
Ans: No
......................................................................
33)What is application object?
Ans:
An application on the Web may consists of several ASP files that work together to perform some purpose. The Application object is used to tie these files together.
The Application object is used to store and access variables from any page, just like the Session object. The difference is that ALL users share ONE Application object (with Sessions there is ONE Session object for EACH user).
The Application object holds information that will be used by many pages in the application (like database connection information). The information can be accessed from any page. The information can also be changed in one place, and the changes will automatically be reflected on all pages.
Visit "http://www.w3schools.com/asp/asp_ref_application.asp"
.....................................................................................................................................
34)Diff between session and application object?
Ans:the session object is used to maintain the session of each user. If one user enter in to the application then they get seesion id if he leaves from the application then the session id is deleted.If they again enter in to the application they get different session id.
But for application object the id is maintained for whole application.it doesn't differ

Visit:"http://www.geekinterview.com/question_details/39704"
....................................................................................................................
35)When application object will create?
Ans:
Visit: "http://www.tricerat.com/support/Simplify%20Suite/Creating_an_Application_Object.html"
..................................................................................................................................
36)When session object will create?
Ans:

when user login
.....................................................
37)Where u will store connection string?
Ans:
u can place the connection string in every .aspx page , but imagine u 
have a project with hundreds of pages , can u imagine the time u will 
spend to open each page and change the ConString , so its always better 
to write it once in the web.config file and then from all the asp.net 
pages to refer to the ConString that is written there .
................................................................
38)What is appsettings?
Ans:
The <appSettings> element of a web.config file is a place to
store connection strings, server names, file paths, and other
miscellaneous settings needed by an application to perform work. The
items inside appSettings are items that need to be configurable
depending upon the environment, for instance, any database connection
strings will change as you move your application from a testing and
staging server into production.  
.....................................................................
39)How can i register my assembly in gac?
Ans:
I have created a dll using the Class library in .Net
(Using vb.net).
After that I have associated it with a strong name by
creating a .snk file using sn.exe then i have added this
to my vb.net application using the following tag in
assembly.vb file in my application
<Assembly: AssemblyKeyFileAttribute("sharedDll.snk")>
and the version info as
<Assembly: AssemblyVersion("1.0.1099.0")>

after this i want to configure it to GAC.
...........................................................
40)What is strong name?
Ans:

A strong name is a .NET assembly name combined with its 
version number and other information to uniquely identify 
the assembly. This allows multiple versions of the same 
assembly to peacefully co-exist in the global assembly 
cache, where shared assemblies are typically stored.
...........................................................................................................................................
41)How to generate strong name?

Ans:

Steps for Giving  strong name to DLL
  1. Open .net command prompt.
  2. Go to the folder contanig DLL.
  3. Type sn -k test.snk, you can use any file name instead of test. This will create  test .snk file in that folder.
  4. Open the assemblyinfo.cs file of project.
  5. Type file path  in this tag [assembly:AssemblyKeyFile@"E:\hemant\practice\HP\bin\Debug\HP.snk")]
  6. Build  application, finally your strong name created for your DLL.
Example

->Created class library path E:\hemant\practice\HP
->Open command prompt go to Dll folder path.
.........................................................................................
42)How to register strong name with my class library?
Ans:
 

ASP.NET 3.5 Page Directives

ASP.NET PAGE DIRECTIVE




ASP.NET provides the number of directives with the help of it we can control the behavior of ASP.NET Pages.

We have 11 directives that we can use in our ASP.NET pages or user controls.

We can use these directives regardless we are using Inline Coding Model or Code-Behind Model.

These directives are the commands that complier uses when the page is compiled. Format to write the directive is given below

<%@ Directive attribute= value %>

Now lets talk about the number of directives that are provided in ASP.NET one by one




Page Directive


It specifies the attribute and values that are associated with Web Form Pages (.aspx).
When the compiler complies the project the page directive send command that are basically used for compiling the page.
Some of the attributes of the page directive is :- Code File, Buffer, Culture, Debug, Language, Inherits.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>


Master Directive


It specifies the attribute and values that are associated with Master Pages (.master).
In it, we specify the properties of the master page (templated page) that we will be conjunction with any number of content page.
Some of the attributes of the master page directive is :- Code File, Debug, Language, Inherits, EnableView State, MasterPageFile, Src.

<%@ Master Language="C#" %>


Control Directive


It specifies the attribute and values that are associated with WebUserControl (.ascx).
It is used to bind as ASP.NET user control.
It defines the properties to be inherited by the user control.
When the page is parsed and compiled then these values are assigned then assigned to the use control.
Some of the attributes of the master page directive is :- Code File, Debug, Language, Inherits, EnableView State, Src, ClassName, Description, CompilerOptions

<%@ Control Language="C#" ClassName="WebUserControl" %>


Import Directive


We use the import directive when we want to import any namespace in the ASP.NET page or user control.
When we import any namespace the we are able to use it's classes and interfaces.
This directive has only one attribute called "Namespace".
As much namespace we want to import the same number of import directive must be included.

<%@ Import Namespace="System.Data.SqlClient" %>

Implements Directive


We use the implements directive when we want to import any interface in the ASP.NET page or user control.
When we import any interface the we are able to use it's members.
This directive has only one attribute called "Interface".
As much interface we want to use the same number of implements directive must be included.

<%@ Implements Interface="System.Web.UI.IValidator" %>

h2>Register Directive
When we drag and drop the web user control on the web form page then in the source page the register directive is automatically included.
It is used to register the user control on the page so that the control can be accessed on the web form (.aspx) page.
Some of the attribute of register directive is :- assembly, namespace, src, tagname, tagprefix.

<%@ Register src="WebUserControl.ascx" tagname="WebUserControl" tagprefix="uc1" %>


Assembly Directive


It associates the assemblies to the ASP.NET page or user control so that at the compile time assembly's classes and interface is available to the page.
Attribute of the register directive is :- name and src

<%@ Assembly Name="Baljeet" Src="Baljeet.cs" %>

PreviousPageType Directive


It defines the page from which any cross-page posting originate.
It is new in the ASP.NET 3.5.
Attribute of the previouspagetpype is :- typename, virtualpath.



MasterType Directive


It is applied on the Web Forms not on WebUserControl.
When we define this directive then we get the references or members contained in the specified master page.
Attribute of the MasterType is :- typename, virtualpath.

<%@ MasterType VirtualPath="~/MasterPage.master" %>

OutputCache Directive


It control the output caching of the ASP.NET pages or user control.
Attribute of the outputcache is :- cacheprofile, duration, location, varybycontrol, varybycustom, shared.

<%@ OutputCache Duration="180" VaryByParam="None" %>

Reference Directive


It define the another ASP.NET page or user control that should be complied along with active page or control.
It support only one attribute :- virtualpath.

<%@ Reference VirtualPath="~/WebUserControl.ascx" %>



For more details, visit http://aspdotneteverything.blogspot.com/

ADO and ADO.NET are different in several ways

·         ADO works with connected data. This means that when you access data, such as viewing and updating data, it is real-time, with a connection being used all the time. This is barring, of course, you programming special routines to pull all your data into temporary tables.
ADO.NET uses data in a disconnected fashion. When you access data, ADO.NET makes a copy of the data using XML. ADO.NET only holds the connection open long enough to either pull down the data or to make any requested updates. This makes ADO.NET efficient to use for Web applications. It's also decent for desktop applications.
·         ADO has one main object that is used to reference data, called the Recordset object. This object basically gives you a single table view of your data, although you can join tables to create a new set of records. With ADO.NET, you have various objects that allow you to access data in various ways. The DataSet object will actually allow you to store the relational model of your database. This allows you to pull up customers and their orders, accessing/updating the data in each related table individually.
·         ADO allows you to create client-side cursors only, whereas ADO.NET gives you the choice of either using client-side or server-side cursors. In ADO.NET, classes actually handle the work of cursors. This allows the developer to decide which is best. For Internet development, this is crucial in creating efficient applications.
·         Whereas ADO allows you to persist records in XML format, ADO.NET allows you to manipulate your data using XML as the primary means. This is nice when you are working with other business applications and also helps when you are working with firewalls because data is passed as HTML and XML.

ADO and ADO.NET are different in several ways

·         ADO works with connected data. This means that when you access data, such as viewing and updating data, it is real-time, with a connection being used all the time. This is barring, of course, you programming special routines to pull all your data into temporary tables.
ADO.NET uses data in a disconnected fashion. When you access data, ADO.NET makes a copy of the data using XML. ADO.NET only holds the connection open long enough to either pull down the data or to make any requested updates. This makes ADO.NET efficient to use for Web applications. It's also decent for desktop applications.
·         ADO has one main object that is used to reference data, called the Recordset object. This object basically gives you a single table view of your data, although you can join tables to create a new set of records. With ADO.NET, you have various objects that allow you to access data in various ways. The DataSet object will actually allow you to store the relational model of your database. This allows you to pull up customers and their orders, accessing/updating the data in each related table individually.
·         ADO allows you to create client-side cursors only, whereas ADO.NET gives you the choice of either using client-side or server-side cursors. In ADO.NET, classes actually handle the work of cursors. This allows the developer to decide which is best. For Internet development, this is crucial in creating efficient applications.
·         Whereas ADO allows you to persist records in XML format, ADO.NET allows you to manipulate your data using XML as the primary means. This is nice when you are working with other business applications and also helps when you are working with firewalls because data is passed as HTML and XML.

What is main difference between ADO and ADO.Net

1. In ADO, the in-memory representation of data is the recordset.
In ADO.NET, it is the dataset
2. .A recordset looks like a single table.
If a recordset is to contain data from multiple database tables, it must use a JOIN query, which assembles the data from the various database tables into a single result table.Dataset uses relations to join tables
3. In ADO you scan sequentially through the rows of the recordset using the ADO MoveNext method.
In ADO.NET, rows are represented as collections,
so you can loop through a table as you would through any collection,
or access particular rows via ordinal or primary key index.
4. A cursor is a database element that controls record navigation,
the ability to update data, and the visibility of changes made to the database by other users.
ADO.NET does not have an inherent cursor object, but instead includes data classes
that provide the functionality of a traditional cursor. For example,
the functionality of a forward-only, read-only cursor is available in the ADO.NET DataReader object. For more information

5. In ADO.NET you open connections only long enough to
perform a database operation, such as a Select or Update.
You can read rows into a dataset and then work with them without staying
connected to the data source. In ADO the recordset can provide disconnected access,
but ADO is designed primarily for connected access.

6. There is one significant difference between disconnected
processing in ADO and ADO.NET. In ADO you
communicate with the database by making calls to an OLE DB provider.
In ADO.NET you communicate with the database through a data adapter
which makes calls to an OLE DB provider or the APIs provided by the
underlying data source. The important difference is that in ADO.NET the data adapter
allows you to control how the changes to the dataset are transmitted to the database — by optimizing for
performance, performing data validation checks, or adding any other extra processing.
7. Transmitting an ADO.NET dataset between applications
is much easier than transmitting an ADO disconnected recordset.
To transmit an ADO disconnected recordset from one component to another,
you use COM marshalling. To transmit data in ADO.NET, you use a dataset,
which can transmit an XML stream.

The transmission of XML files offers the following advantages over COM marshalling:

Richer data types
COM marshalling provides a limited set of data types — those defined by the COM standard. Because the transmission of datasets in ADO.NET is based on an XML format, there is no restriction on data types. Thus, the components sharing the dataset can use whatever rich set of data types they would ordinarily use.

Performance
Transmitting a large ADO recordset or a large ADO.NET dataset can consume network resources; as the amount of data grows, the stress placed on the network also rises. Both ADO and ADO.NET let you minimize which data is transmitted. But ADO.NET offers another performance advantage, in that ADO.NET does not require data-type conversions. ADO, which requires COM marshalling to transmit records sets among components, does require that ADO data types be converted to COM data types.

Penetrating Firewalls
A firewall can interfere with two components trying to transmit disconnected ADO recordsets. Remember, firewalls are typically configured to allow HTML text to pass, but to prevent system-level requests (such as COM marshalling) from passing.

Because components exchange ADO.NET datasets using XML, firewalls can allow datasets to pass.

check out these links for difference
with example
http://aspalliance.com/128_A_Quick_Comparison_of_ADO_and_ADONET__Part_I
http://www.devarticles.com/c/a/ADO.NET/A-Practical-Comparison-of-ADO-and-ADO.NET/
http://www.experts-exchange.com/Databases/Q_20985045.html

Difference between ASP.NET Server Controls and HTML Server Controls

Advantages:
1. ASP .NET Server Controls can detect the target browser’s capabilities and render themselves accordingly. No issues for compatibility issues of Browsers i.e page that might be used by both HTML 3.2 and HTML 4.0 browsers code is written in the Server Controls.
2. Newer set of controls that can be used in the same manner as any HTML control like Calender controls. Without any need of Activex Control without bringing up issues of Browser compatibility).
3. Processing would be done at the server side. In built functionality to check for few values(with Validation controls) so no need to choose between scripting language which would be incompatible with few browsers.
4. ASP .NET Server Controls have an object model different from the traditional HTML and even provide a set of properties and methods that can change the outlook and behavior of the controls.
5. ASP .NET Server Controls have higher level of abstraction. An output of an ASP .NET server control can be the result of many HTML tags that combine together to produce that control and its events. Example Gridview or Form control.
Disadvantages:
1. The control of the code is inbuilt with the web server controls so you have no much of direct control on these controls
HTML Server Controls
Advantages:
1. The HTML Server Controls follow the HTML-centric object model. Model similar to HTML
2. Here the controls can be made to interact with Client side scripting. Processing would be done at client as well as server depending on your code.
5. A HTML Server Control has similar abstraction with its corresponding HTML tag and offers no abstraction.
Disadvantages:
1. You would need to code for the browser compatibility.
2. The HTML Server Controls have no mechanism of identifying the capabilities of the client browser accessing the current page.

Life Cycle of A Thread

When you are programming with threads, understanding the life cycle of thread is very valuable. While a thread is alive, it is in one of several states. By invoking start() method, it doesn’t mean that the thread has access to CPU and start executing straight away. Several factors determine how it will proceed.

Different states of a thread are :


  1. New state – After the creations of Thread instance the thread is in this state but before the start() method invocation. At this point, the thread is considered not alive.
         
  2. Runnable (Ready-to-run) state – A thread start its life from Runnable state. A thread first enters runnable state after the invoking of start() method but a thread can return to this state after either running, waiting, sleeping or coming back from blocked state also. On this state a thread is waiting for a turn on the processor.
         
  3. Running state – A thread is in running state that means the thread is currently executing. There are several ways to enter in Runnable state but there is only one way to enter in Running state: the scheduler select a thread from runnable pool.
         
  4. Dead state – A thread can be considered dead when its run() method completes. If any thread comes on this state that means it cannot ever run again.
  5. Blocked - A thread can enter in this state because of waiting the resources that are hold by another thread.
Different states implementing Multiple-Threads are:

As we have seen different states that may be occur with the single thread. A running thread can enter to any non-runnable state, depending on the circumstances. A thread cannot enters directly to the running state from non-runnable state, firstly it goes to runnable state. Now lets understand the some non-runnable states which may be occur handling the multithreads.
  • Sleeping – On this state, the thread is still alive but it is not runnable, it might be return to runnable state later, if a particular event occurs. On this state a thread sleeps for a specified amount of time. You can use the method sleep( ) to stop the running state of a thread.
         
         static void sleep(long millisecond) throws InterruptedException
  • Waiting for Notification – A thread waits for notification from another thread. The thread sends back to runnable state after sending notification from another thread.
          
         final void wait(long timeout) throws InterruptedException
         final void wait(long timeout, int nanos) throws InterruptedException
         final void wait() throws InterruptedException

         
  • Blocked on I/O – The thread waits for completion of blocking operation. A thread can enter on this state because of waiting I/O resource. In that case the thread sends back to runnable state after availability of resources.
         
  • Blocked for joint completion – The thread can come on this state because of waiting the completion of another thread.
        
  • Blocked for lock acquisition – The thread can come on this state because of waiting to acquire the lock of an object.
 Methods that can be applied apply on a Thread:
Some Important Methods defined in java.lang.Thread are shown in the table:
 Method  Return Type  Description
 currentThread( )  Thread  Returns an object reference to the thread in which it is invoked.
 getName( )  String  Retrieve the name of the thread object or instance.
 start( )  void  Start the thread by calling its run method.
 run( )  void  This method is the entry point to execute thread, like the main method for applications.
 sleep( )  void  Suspends a thread for a specified amount of time (in milliseconds).
  isAlive( )  boolean  This method is used to determine the thread is running or not.
 activeCount( )  int  This method returns the number of active threads in a particular thread group and all its subgroups.
 interrupt( )  void  The method interrupt the threads on which it is invoked.
 yield( )  void  By invoking this method the current thread pause its execution temporarily and allow other threads to execute.
 join( )  void  This method and  join(long millisec) Throws InterruptedException.  These two methods are invoked on a thread. These are not returned until either the thread has completed or it is timed out respectively.