Wednesday, March 4, 2009

.Net. Asp.Net, Ajax..etc FAQs

1) What is a IL?
Twist :- What is MSIL or CIL , What is JIT?

ANS: (IL) Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL
(Common Intermediate Language). All .NET source code is compiled to IL. This IL is then
converted to machine code at the point where the software is installed, or at run-time by a Just-In-
Time (JIT) compiler.

2) What is a CLR?

ANS: Full form of CLR is Common Language Runtime and it forms the heart of the .NET framework.
All Languages have runtime and its the responsibility of the runtime to take care of the code
execution of the program. For example VC++ has MSCRT40.DLL,VB6 has MSVBVM60.DLL,
Java has Java Virtual Machine etc. Similarly .NET has CLR. Following are the responsibilities of
CLR
· Garbage Collection :- CLR automatically manages memory thus eliminating
memory leaks. When objects are not referred GC automatically releases those
memories thus providing efficient memory management.
· Code Access Security :- CAS grants rights to program depending on the security
configuration of the machine. Example the program has rights to edit or create
a new file but the security configuration of machine does not allow the program
to delete a file. CAS will take care that the code runs under the environment of
machines security configuration.
· Code Verification :- This ensures proper code execution and type safety while
the code runs. It prevents the source code to perform illegal operation such as
accessing invalid memory locations etc.
· IL ( Intermediate language )-to-native translators and optimizer’s :- CLR uses
JIT and compiles the IL code to machine code and then executes. CLR also
determines depending on platform what is optimized way of running the IL
code.

3) What is a CTS?

ANS: In order that two language communicate smoothly CLR has CTS (Common Type System).Example
in VB you have “Integer” and in C++ you have “long” these data types are not compatible so the
Interfacing between them is very complicated. In order to able that two different languages can
communicate Microsoft introduced Common Type System. So “Integer” data type in VB6 and
“int” data type in C++ will convert it to System.int32 which is data type of CTS. CLS which is
covered in the coming question is subset of CTS.

Note: If you have undergone COM programming period interfacing VB6 application with
VC++ application was a real pain as the data type of both languages did not have a
common ground where they can come and interface, by having CTS interfacing is smooth.

4) What is a CLS(Common Language Specification)?

ANS: This is a subset of the CTS which all .NET languages are expected to support. It was always a
dream of Microsoft to unite all different languages in to one umbrella and CLS is one step
towards that. Microsoft has defined CLS which are nothing but guidelines that language to follow
so that it can communicate with other .NET languages in a seamless manner.
5) What is a Managed Code?
ANS: Managed code runs inside the environment of CLR i.e. .NET runtime. In short all IL are managed
code. But if you are using some third party software example VB6 or VC++ component they are
unmanaged code as .NET runtime (CLR) does not have control over the source code execution
of the language.

6) What is an Assembly?

ANS: Assembly is a collection of single file or multiple files.
· Assembly is unit of deployment like EXE or a DLL.
· An assembly consists of one or more files (dlls, exe’s, html files etc.), and
represents a group of resources, type definitions, and implementations of those
types. An assembly may also contain references to other assemblies. These
resources, types and references are described in a block of data called a manifest.
The manifest is part of the assembly, thus making the assembly self-describing.
An assembly is completely self-describing.An assembly contains metadata
· information, which is used by the CLR for everything from type checking and
security to actually invoking the components methods. As all information is in the
assembly itself, it is independent of registry. This is the basic advantage as
compared to COM where the version was stored in registry.
· Multiple versions can be deployed side by side in different folders. These
different versions can execute at the same time without interfering with each
other. Assemblies can be private or shared. For private assembly deployment, the
assembly is copied to the same directory as the client program that references
it. No registration is needed, and no fancy installation program is required.
70
When the component is removed, no registry cleanup is needed, and no uninstall
program is required. Just delete it from the hard drive.
· In shared assembly deployment, an assembly is installed in the Global Assembly
Cache (or GAC). The GAC contains shared assemblies that are
globally accessible to all .NET applications on the machine.

7) What are the different types of Assembly?

ANS: There are two types of assembly.
* Private Assembly
* Public Assembly/Shared Assembly.
A private assembly is normally used by a single application, and is stored in the application's directory, or a sub-directory beneath.
A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful, e.g. Crystal report classes which will be used by all application for Reports.

8) What is NameSpace?

ANS: Namespace has two basic functionality :-
· Namespace Logically group types, example System.Web.UI logically groups
our UI related features.
· In Object Oriented world many times its possible that programmers will use the
same class name. By qualifying Namespace with class name this collision can be
avoided.
9) What is Difference between NameSpace and Assembly?

ANS: Following are the differences between namespace and assembly :
· Assembly is physical grouping of logical units. Namespace logically groups
classes.
· Namespace can span multiple assembly.

10)If you want to view a Assembly how do you go about it ?
Twist : What is ILDASM ?

ANS: When it comes to understanding of internals nothing can beat ILDASM. ILDASM basically converts
the whole exe or dll in to IL code. To run ILDASM you have to go to "C:\Program Files\Microsoft
71
Visual Studio .NET 2003\SDK\v1.1\Bin". Note that i had v1.1 you have to probably change it
depending on the type of framework version you have.
If you run IDASM.EXE from the path you will be popped with the IDASM exe program as
shown in figure ILDASM. Click on file and browse to the respective directory for the DLL
whose assembly you want to view. After you select the DLL you will be popped with a tree view
details of the DLL as shown in figure ILDASM. On double clicking on manifest you will be able
to view details of assembly, internal IL code etc as shown in Figure Manifest View.

11) What is Manifest?

ANS: Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the
following things (See Figure Manifest View for more details):
· Version of assembly
· Security identity
· Scope of the assembly
· Resolve references to resources and classes.
· The assembly manifest can be stored in either a PE file (an .exe or .dll) with
Microsoft intermediate language (MSIL) code or in a stand-alone PE file that
contains only assembly manifest information.

12) Where is version information stored of an assembly ?

ANS: Version information is stored in assembly in manifest.

13) Is versioning applicable to private assemblies?

ANS : Versioning concept is only applicable to global assembly cache (GAC) as private assembly lie in
their individual folders.

14) What is GAC ?
Twist :- What are situations when you register .NET assembly in GAC ?

ANS: GAC (Global Assembly Cache) is used where shared .NET assembly reside. GAC is used in the
following situations :-
· If the application has to be shared among several application.
· If the assembly has some special security requirements like only administrators
can remove the assembly. If the assembly is private then a simple delete of
assembly the assembly file will remove the assembly.
Note :- Registering .NET assembly in GAC can lead to the old problem of DLL hell,
where COM version was stored in central registry. So GAC should be used when absolutely
necessary.

15) What is the concept of strong names ?
Twist :- How do we generate strong names ?
Twist :- What is use the of SN.EXE ?
Twist :- How do we apply strong names to assembly?
Twist :- How do you sign an assembly?

ANS: Strong name is similar to GUID(It is supposed to be unique in space and time) in COM
components. Strong Name is only needed when we need to deploy assembly in GAC. Strong
Names helps GAC to differentiate between two versions. Strong names use public key cryptography
(PKC) to ensure that no one can spoof it. PKC use public key and private key concept.

16) How to add and remove an assembly from GAC?

ANS: There are two ways to install .NET assembly in GAC:-
· Using Microsoft Installer Package. You can get download of installer from
http://www.microsoft.com.
· Using Gacutil. Go to “Visual Studio Command Prompt” and type “gacutil –i
(assembly_name)”, where (assembly_name) is the DLL name of the project.

17) What is Delay signing ?

ANS: During development process you will need strong name keys to be exposed to developer which
is not a good practice from security aspect point of view. In such situations you can assign the key
later on and during development you use delay signing
Following is process to delay sign an assembly:
· First obtain your string name keys using SN.EXE.
· Annotate the source code for the assembly with two custom attributes from
System.Reflection: AssemblyKeyFileAttribute, which passes the name of the file
containing the public key as a parameter to its constructor. AssemblyDelaySignAttribute,
which indicates that delay signing, is being used by passing true as a parameter to its
constructor. For example as shown below:
[Visual Basic]


[C#]
[assembly:AssemblyKeyFileAttribute("myKey.snk")]
[assembly:AssemblyDelaySignAttribute(true)]
The compiler inserts the public key into the assembly manifest and reserves space in the PE file for
the full strong name signature. The real public key must be stored while the assembly is built so
that other assemblies that reference this assembly can obtain the key to store in their own assembly
reference.
· Because the assembly does not have a valid strong name signature, the verification of
that signature must be turned off. You can do this by using the –Vr option with the
Strong Name tool.The following example turns off verification for an assembly called
myAssembly.dll.
Sn –Vr myAssembly.dll
· Just before shipping, you submit the assembly to your organization's signing authority
for the actual strong name signing using the –R option with the Strong Name tool.
The following example signs an assembly called myAssembly.dll with a strong name
using the sgKey.snk key pair.
Sn -R myAssembly.dll sgKey.snk

18) What is garbage collection?

ANS: Garbage collection is a CLR feature which automatically manages memory.
Programmers forget to release the objects while coding ..... Laziness (Remember in VB6 where one of the good practices is to set object to nothing).
CLR automatically releases objects when they are no longer in use and referenced.
CLR runs on non-deterministic to see the unused objects and cleans them.
One side effect of this non-deterministic feature is that we cannot assume an object is destroyed when
it goes out of the scope of a function.
we should avoid using destructors because before GC destroys the object it first executes destructor in that case it will have to wait for code to release the unmanaged resource.
Resulting in additional delays in GC. So its recommended to implement
IDisposable interface and write cleaup code in Dispose method and call GC. Suppress Finalize
method so instructing GC not to call your constructor.

19) Can we force garbage collector to run ?

ANS: System.GC.Collect() forces garbage collector to run. This is not recommended but can be used if
situations arises.

20) What is reflection?

ANS: All .NET assemblies have metadata information stored about the types defined in modules. This
metadata information can be accessed by mechanism called as “Reflection”.System. Reflection
can be used to browse through the metadata information.
Using reflection you can also dynamically invoke methods using System.Type.Invokemember.
Below is sample source code if needed you can also get this code from CD provided, go to
“Source code” folder in “Reflection Sample” folder.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim Pobjtype As Type
Dim PobjObject As Object
Dim PobjButtons As New Windows.Forms.Button()
Pobjtype = PobjButtons.GetType()
For Each PobjObject In Pobjtype.GetMembers
LstDisplay.Items.Add(PobjObject.ToString())
Next
End Sub
End Class
Note :- Sample source code are compiled using VB.NET 2005.
Sample source code uses reflection to browse through “Button” class of “Windows.Forms”. If
you compile and run the program following is output as shown in “Sample Reflection Display”.
Using reflection you can also dynamically invoke a method using “System.Type.InvokeMember”.
Note :- System.Type.InvokeMember is left as homework for readers. Believe me you will
enjoy doing it yourself and the concept of reflection will be clearer.

21) What are different types of JIT ?

ANS: JIT compiler is a part of the runtime execution environment.
In Microsoft .NET there are three types of JIT compilers:
· Pre-JIT :- Pre-JIT compiles complete source code into native code in a single
compilation cycle. This is done at the time of deployment of the application.
· Econo-JIT :- Econo-JIT compiles only those methods that are called at runtime.
However, these compiled methods are removed when they are not required.
· Normal-JIT :- Normal-JIT compiles only those methods that are called at runtime.
These methods are compiled the first time they are called, and then they are stored in
cache. When the same methods are called again, the compiled code from cache is
used for execution.

22) What are Value types and Reference types ?

ANS: Value types directly contain their data which are either allocated on the stack or allocated in-line in
a structure.
Reference types store a reference to the value's memory address, and are allocated on the heap.
Reference types can be self-describing types, pointer types, or interface types.
Variables that are value types each have their own copy of the data, and therefore operations on
one variable do not affect other variables. Variables that are reference types can refer to the same
object; therefore, operations on one variable can affect the same object referred to by another
variable. All types derive from the System.Object base type.

23) What is concept of Boxing and Unboxing ?

ANS:
Boxing permits any value type to be implicitly converted to type object or to any interface type
implemented by value type. Boxing is a process in which object instances are created and copy
values in to that instance.

Unboxing is vice versa of boxing operation where the value is copied from the instance in to
appropriate storage location.

24) What is the difference between VB.NET and C# ?

ANS: Well this is the most debatable issue in .NET community and people treat there languages like
religion. Its a subjective matter which language is best. Some like VB.NET’s natural style and some
like professional and terse C# syntaxes. Both use the same framework and speed is also very much
equivalents. But still let’s list down some major differences between them :-
Advantages VB.NET :-
· Has support for optional parameters which makes COM interoperability much easy.
· With Option Strict off late binding is supported.Legacy VB functionalities can be
used by using Microsoft.VisualBasic namespace.
· Has the WITH construct which is not in C#.
· The VB.NET part of Visual Studio .NET compiles your code in the background.
While this is considered an advantage for small projects, people creating very large
projects have found that the IDE slows down considerably as the project gets larger.
Advantages of C#
· XML documentation is generated from source code but this is now been incorporated
in Whidbey.
· Operator overloading which is not in current VB.NET but is been introduced in
Whidbey.
· Use of this statement makes unmanaged resource disposal simple.
· Access to Unsafe code. This allows pointer arithmetic etc, and can improve
performance in some situations. However, it is not to be used lightly, as a lot of the
normal safety of C# is lost (as the name implies).This is the major difference that you
can access unmanaged code in C# and not in VB.NET.

25)What is the difference between System exceptions and Application
exceptions?

ANS: All exception derives from Exception Base class. Exceptions can be generated programmatically
or can be generated by system. Application Exception serves as the base class for all application specific
exception classes. It derives from Exception but does not provide any extended functionality.
You should derive your custom application exceptions from Application Exception.
Application exception is used when we want to define user defined exception, while system
exception is all which is defined by .NET.

26)What is a satellite assembly?

ANS: Refer Localization chapter for more details

27)How to prevent my .NET DLL to be decompiled?

ANS: By design .NET embeds rich Meta data inside the executable code using MSIL. Anyone can easily
decompile your DLL back using tools like ILDASM (owned by Microsoft) or Reflector for
.NET which is a third party. Secondly there are many third party tools which make this decompiling
process a click away. So any one can easily look in to your assemblies and reverse engineer them
back in to actual source code and understand some real good logic which can make it easy to
crack your application.
The process by which you can stop this reverse engineering is using “obfuscation”. It’s a technique
which will foil the decompilers. There are many third parties (XenoCode, Demeanor for .NET)
which provide .NET obfuscation solution. Microsoft includes one that is Dotfuscator Community
Edition with Visual Studio.NET.

28) How can we use COM Components in .NET?
Twist : What is RCW ?

ANS: .NET components communicate with COM using RCW (Runtime Callable Wrapper). Following
are the ways with which you can generate RCW :-
·  Adding reference in Visual Studio.net. See figure below (Adding reference using VS.NET
2005). Wrapper class is generated and placed in the “BIN” directory.

29)What is COM ?

ANS: Microsoft’s COM is a technology for component software development. It is a binary standard
which is language independent. DCOM is a distributed extension of COM.

30) What is Reference counting in COM ?

ANS: Reference counting is a memory management technique used to count how many times an object
has a pointer referring to it. The first time it is created, the reference count is set to one. When the
last reference to the object is nulled, the reference count is set to zero and the object is deleted.
Care must be exercised to prevent a context switch from changing the reference count at the time
of deletion. In the methods that follow, the syntax is shortened to keep the scope of the discussion
brief and manageable.

31) What is Multi-tasking ?

ANS: It’s a feature of modern operating systems with which we can run multiple programs at
same time example Word, Excel etc.

32) What is Multi-threading ?

ANS: Multi-threading forms subset of Multi-tasking. Instead of having to switch between
programs this feature switches between different parts of the same program. Example
you are writing in word and at the same time word is doing a spell check in background.

33)What is a Thread ?

ANS: A thread is the basic unit to which the operating system allocates processor time.

34)Can we have multiple threads in one App domain ?

ANS: One or more threads run in an AppDomain. An AppDomain is a runtime representation
of a logical process within a physical process. Each AppDomain is started with a single
thread, but can create additional threads from any of its threads.
Note :- All threading classes are defined in System.Threading namespace.

35)Which namespace has threading ?

ANS: System.Threading has all the classes related to implement threading. Any .NET application
who wants to implement threading has to import this namespace.
Note :- .NET program always has at least two threads running one is the main program
and second is the garbage collector.


36) What is a Web Service ?

ANS: Web Services are business logic components which provide functionality via the Internet
using standard protocols such as HTTP.
Web Services uses Simple Object Access Protocol (SOAP) in order to expose the business
functionality. SOAP defines a standardized format in XML which can be exchanged
between two entities over standard protocols such as HTTP. SOAP is platform independent
so the consumer of a Web Service is therefore completely shielded from any
implementation details about the platform exposing the Web Service. For the consumer it
is simply a black box of send and receive XML over HTTP. So any web service hosted on
windows can also be consumed by UNIX and LINUX platform.

37) What is UDDI ?

ANS: Full form of UDDI is Universal Description, Discovery and Integration. It is a directory
that can be used to publish and discover public Web Services.
.
38) What is WSDL?

ANS: Web Service Description Language (WSDL) is a W3C specification which defines XML
grammar for describing Web Services.XML grammar describes details such as:-
· Where we can find the Web Service (its URI)?
· What are the methods and properties that service supports?
· Data type support.
· Supported protocols
In short its a bible of what the web service can do. Clients can consume this WSDL and
build proxy objects that clients use to communicate with the Web Services

39) What is an application object ?

ANS: Application object can be used in situation where we want data to be shared across users
globally.

40)What’s the difference between Cache object and application object ?

ANS: The main difference between the Cache and Application objects is that the Cache object
provides cache-specific features, such as dependencies and expiration policies.

41) What is ViewState ?
ANS: Viewstate is a built-in structure for automatically retaining values amongst the multiple
requests for the same page. The Viewstate is internally maintained as a hidden field on the
page but is hashed, providing greater security than developer-implemented hidden fields
do.

42) What is Object Oriented Programming ?
ANS: It is a problem solving technique to develop software systems. It is a technique to think
real world in terms of objects. Object maps the software model to real world concept.
These objects have responsibilities and provide services to application or other objects.

43) What’s a Class ?

ANS: A class describes all the attributes of objects, as well as the methods that implement the
behavior of member objects. It’s a comprehensive data type which represents a blue print
of objects. It’s a template of object.

44) What’s an Object ?

ANS: It is a basic unit of a system. An object is an entity that has attributes, behavior, and
identity. Objects are members of a class. Attributes and behavior of an object are defined
by the class definition.

45) Abstraction

ANS: It allows complex real world to be represented in simplified manner. Example color is
abstracted to RGB. By just making the combination of these three colors we can achieve
any color in world. It’s a model of real world or concept.

46) Encapsulation

ANS: It is a process of hiding all the internal details of an object from the outside world.

47) Class hierarchies (Inheritance and aggregation)
Twist :- What is difference between Association, Aggregation and Inheritance relationships?

ANS: In object oriented world objects have relation and hierarchies in between them. There are
basically three kind of relationship in Object Oriented world :-
Association
This is the simplest relationship between objects. Example every customer has sales. So
Customer object and sales object have an association relation between them.
Aggregation
This is also called as composition model. Example in order to make a “Accounts” class it
has use other objects example “Voucher”, “Journal” and “Cash” objects. So accounts
class is aggregation of these three objects.
Inheritance
Hierarchy is used to define more specialized classes based on a preexisting generalized
class. Example we have VEHICLE class and we can inherit this class make more
specialized class like CAR, which will add new attributes and use some existing qualities
of the parent class. Its shows more of a parent-child relationship. This kind of hierarchy
is called inheritance.

48) Polymorphism
ANS: When inheritance is used to extend a generalized class to a more specialized class, it
includes behavior of the top class(Generalized class). The inheriting class often implement
a behavior that can be somewhat different than the generalized class, but the name of the
behavior can be same. It is important that a given instance of an object use the correct
behavior, and the property of polymorphism allows this to happen automatically.

49) What is a Interface ?

ANS: Interface is a contract that defines the signature of the functionality. So if a class is
implementing a interface it says to the outer world, that it provides specific behavior.
Example if a class is implementing Idisposable interface that means it has a functionality
to release unmanaged resources. Now external objects using this class know that it has
contract by which it can dispose unused unmanaged objects.
· Single Class can implement multiple interfaces.
· If a class implements a interface then it has to provide implementation to all
its methods.
Note:- In CD sample “WindowsInterFace” is provided, which has a simple interface
implemented.
In sample there are two files.One has the interface definition and other class implements
the interface. Below is the source code “IInterface” is the interface and “ClsDosomething”
implements the “IInterface”. This sample just displays a simple message box.

Public Interface IInterFace
Sub DoSomething()
End Interface
Public Class ClsDoSomething
Implements IInterFace
Public Sub DoSomething() Implements
WindowsInterFace.IInterFace.DoSomething
MsgBox(“Interface implemented”)
End Sub
End Class

50) What is difference between abstract classes and
interfaces?

ANS: Following are the differences between abstract and interfaces :-
· Abstract classes can have concrete methods while interfaces have no methods
implemented.
· Interfaces do not come in inheriting chain, while abstract classes come in
inheritance.

51) What is a delegate ?

ANS: Delegate is a class that can hold a reference to a method or a function. Delegate class has
a signature and it can only reference those methods whose signature is compliant with the
class. Delegates are type-safe functions pointers or callbacks.

52) What are events ?

ANS: As compared to delegates events works with source and listener methodology. So listeners
who are interested in receiving some events they subscribe to the source. Once this
subscription is done the source raises events to its entire listener when needed. One
source can have multiple listeners.
In sample given below class “ClsWithEvents” is a event source class, which has a event
“EventAddString()”. Now the listeners who are interested in receiving this events they
can subscribe to this event. In class “FrmWithEvents” you can see they handle clause
which is associated with the “mobjClsWithEvents” objects.

Public Class ClsWithEvents
Event EventAddString(ByVal Value As String)
Public Sub AddString()
RaiseEvent EventAddString(“String added by Event”)
End Sub
End Class
Public Class FrmWithEvents
Inherits System.Windows.Forms.Form
Private WithEvents mobjClsWithEvents As New ClsWithEvents()
Private Sub FrmWithEvents_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub mobjClsWithEvents_EventAddString(ByVal Value As
String) Handles mobjClsWithEvents.EventAddString
LstData.Items.Add(Value)
End Sub
Private Sub CmdRunEvents_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CmdRunEvents.Click
mobjClsWithEvents.AddString()
End Sub
End Class
Nore:- Above source code is provided in “WindowsEvent”

53) Do events have return type ?

ANS: No, events do not have return type.

54) Can event’s have access modifiers ?

ANS: Event’s are always public as they are meant to serve every one registering to it. But you
can access modifiers in events. You can have events with protected keyword which will
be accessible only to inherited classes. You can have private events only for object in that
class.
55) Can we have shared events ?

ANS: Yes, you can have shared event’s note only shared methods can raise shared events.

56) What is shadowing ?

ANS: When two elements in a program have same name, one of them can hide and shadow the
other one. So in such cases the element which shadowed the main element is referenced.
Below is a sample code, there are two classes “ClsParent” and “ClsShadowedParent”. In
“ClsParent” there is a variable “x” which is a integer. “ClsShadowedParent” overrides
“ClsParent” and shadows the “x” variable to a string.
Note:- In Sample CD “WindowsShadowing” is folder which has the sample code. If you
run the program you can have two output’s one which shows a integer and other which shows
a string.
Public Class ClsParent
Public x As Integer
End Class
Public Class ClsShadowedParent
Inherits ClsParent
Public Shadows x As String
End Class

57) What is the difference between Shadowing and
Overriding ?

ANS: Following are the differences between shadowing and overriding :-
· Overriding redefines only the implementation while shadowing redefines the
whole element.
· In overriding derived classes can refer the parent class element by using “ME”
keyword, but in shadowing you can access it by “MYBASE”.

58) What is the difference between delegate and events?

ANS:
· Actually events use delegates in bottom. But they add an extra layer on the
delegates, thus forming the publisher and subscriber model.
· As delegates are function to pointers they can move across any clients. So any
of the clients can add or remove events, which can be pretty confusing. But
events give the extra protection by adding the layer and making it a publisher
and subscriber model.
Just imagine one of your clients doing this
c.XyzCallback = null
This will reset all your delegates to nothing and you have to keep searching where the
error is.

59) What are the different accessibility levels defined in .NET
?
ANS: Following are the five levels of access modifiers :-
· Private : Only members of class have access.
· Protected :-All members in current class and in derived classes can access the
variables.
· Friend (internal in C#) :- Only members in current project have access to the
elements.
· Protected friend (protected internal in C#) :- All members in current project
and all members in derived class can access the variables.
· Public :- All members have access in all classes and projects.

60) What are similarities between Class and structure ?

ANS: Following are the similarities between classes and structures :-
· Both can have constructors, methods, properties, fields, constants,
enumerations, events, and event handlers.
· Structures and classes can implement interface.
· Both of them can have constructors with and without parameter.
· Both can have delegates and events.

61) What is the difference between Class and structure’s ?

ANS: Following are the key differences between them :-
· Structure are value types and classes are reference types. So structures use
stack and classes use heap.
· Structures members can not be declared as protected, but class members can
be. You can not do inheritance in structures.
· Structures do not require constructors while classes require.
· Objects created from classes are terminated using Garbage collector. Structures
are not destroyed using GC.

62) Where are all .NET Collection classes located ?

ANS: System.Collection namespace has all the collection classes available in .NET.

63) What is ArrayList ?

ANS: Array is whose size can increase and decrease dynamically. Array list can hold item of
different types. As Array list can increase and decrease size dynamically you do not have
to use the REDIM keyword. You can access any item in array using the INDEX value of
the array position.

64) What’s a HashTable ?
Twist :- What’s difference between HashTable and ArrayList ?

ANS: You can access array using INDEX value of array, but how many times you know the
real value of index. Hashtable provides way of accessing the index using a user identified
KEY value, thus removing the INDEX problem.

65) What are queues and stacks ?

ANS: Queue is for first-in, first-out (FIFO) structures. Stack is for last-in, first-out (LIFO)
structures.

66) What is ENUM ?

ANS: It’s used to define constants.

67) What is nested Classes ?

ANS: Nested classes are classes within classes. In sample below “ClsNested” class has a
“ChildNested” class nested inside it.
Public Class ClsNested
Public Class ChildNested
Public Sub ShowMessage()
MessageBox.Show(“Hi this is nested class”)
End Sub
End Class
End Class
This is the way we can instantiate the nested class and make the method call.
Dim pobjChildNested As New ClsNested.ChildNested()
pobjChildNested.ShowMessage()
188
Note:-In CD the above sample is provided in “WindowsNestedClasses”.

68)What is Operator Overloading in .NET?

ANS: It provides a way to define and use operators such as +, -, and / for user-defined classes
or structs. It allows us to define/redefine the way operators work with our classes and
structs. This allows programmers to make their custom types look and feel like simple
types such as int and string.
VB.NET till now does not support operator overloading. Operator overloading is done
by using the “Operator” keyword.
Note:- Operator overloading is supported in VB.NET 2005

69)What is the use of DISPOSE method?

ANS: Dispose method belongs to IDisposable interface. We had seen in the previous section
how bad it can be to override the finalize method for writing the cleaning of unmanaged
resources. So if any object wants to release its unmanaged code best is to implement
IDisposable and override the Dispose method of IDisposable interface. Now once your
class has exposed the Dispose method it’s the responsibility of the client to call the
Dispose method to do the cleanup.

70)Can we have different access modifiers on get/set
methods of a property ?

ANS: No we can not have different modifiers same property. The access modifier on a property
applies to both its get and set accessors.

71)What is Indexer ?

ANS: An indexer is a member that enables an object to be indexed in the same way as an array.

72) What’ is the sequence in which ASP.NET events are
processed ?

ANS: Following is the sequence in which the events occur :-
· Page_Init.
·  Page_Load.
· Control events
· Page_Unload event.
Page_init event only occurs when first time the page is started, but Page_Load occurs in
subsequent request of the page.

73) How can we identify that the Page is PostBack ?

ANS: Page object has a “IsPostBack” property which can be checked to know that is the page
posted back.


74) How many types of validation controls are provided by
ASP.NET ?

ANS: There are six main types of validation controls :-
RequiredFieldValidator
It checks whether the control have any value. It's used when you want the control should
not be empty.
RangeValidator
It checks if the value in validated control is in that specific range. Example
TxtCustomerCode should not be more than eight length.
CompareValidator
It checks that the value in controls should match some specific value. Example Textbox
TxtPie should be equal to 3.14.
RegularExpressionValidator
When we want the control value should match with a specific regular expression.
CustomValidator
It is used to define UserDefined validation.
ValidationSummary
It displays summary of all current validation errors.

75)Can you explain what is “AutoPostBack” feature in
ASP.NET ?

ANS: If we want the control to automatically postback in case of any event, we will need to
check this attribute as true. Example on a ComboBox change we need to send the event
immediately to the server side then set the “AutoPostBack” attribute to true.

76) What’s the use of “GLOBAL.ASAX” file ?

ANS: It allows to executing ASP.NET application level events and setting application-level
variables.

77) What is the difference between “Web.config” and
“Machine.Config” ?

ANS: “Web.config” files apply settings to each web application, while “Machine.config” file
apply settings to all ASP.NET applications.

78)What is the difference between Authentication and
authorization?

ANS: This can be a tricky question. These two concepts seem altogether similar but there is
wide range of difference. Authentication is verifying the identity of a user and authorization
is process where we check does this identity have access rights to the system. In short we
can say the following authentication is the process of obtaining some sort of credentials
from the users and using those credentials to verify the user’s identity. Authorization is
the process of allowing an authenticated user access to resources. Authentication always
proceed to Authorization; even if your application lets anonymous users connect and use
the application, it still authenticates them as being anonymous.

79) What is impersonation in ASP.NET ?

ANS: By default, ASP.NET executes in the security context of a restricted user account on the
local machine. Sometimes you need to access network resources such as a file on a shared
drive, which requires additional permissions. One way to overcome this restriction is to
use impersonation. With impersonation, ASP.NET can execute the request using the
identity of the client who is making the request, or ASP.NET can impersonate a specific
account you specify in web.config.

80) Difference between ASP and ASP.NET?

ANS: ASP.NET new feature supports are as follows :-
Better Language Support
√New ADO.NET Concepts have been implemented.
√ASP.NET supports full language (C#, VB.NET, C++) and not simple scripting
like VBSCRIPT..
Better controls than ASP
√ASP.NET covers large set’s of HTML controls..
√Better Display grid like Datagrid, Repeater and datalist.Many of the display
grids have paging support.
Controls have events support
√All ASP.NET controls support events.
√Load, Click and Change events handled by code makes coding much simpler
and much better organized.
Compiled Code
The first request for an ASP.NET page on the server will compile the ASP.NET code and
keep a cached copy in memory. The result of this is greatly increased performance.
Better Authentication Support
ASP.NET supports forms-based user authentication, including cookie management and
automatic redirecting of unauthorized logins. (You can still do your custom login page
and custom user checking).
User Accounts and Roles
ASP.NET allows for user accounts and roles, to give each user (with a given role) access
to different server code and executables.
High Scalability
√Much has been done with ASP.NET to provide greater scalability.
√Server to server communication has been greatly enhanced, making it possible
to scale an application over several servers. One example of this is the ability
to run XML parsers, XSL transformations and even resource hungry session
objects on other servers.
Easy Configuration
√Configuration of ASP.NET is done with plain text files.
√Configuration files can be uploaded or changed while the application is running.
No need to restart the server. No more metabase or registry puzzle.
Easy Deployment
No more server restart to deploy or replace compiled code. ASP.NET simply redirects all
new requests to the new code.

81)What is Tracing in ASP.NET ?

ANS: Tracing allows us to view how the code was executed in detail.

82)Explain the differences between Server-side and Clientside
code?

ANS: Server side code is executed at the server side on IIS in ASP.NET framework, while
client side code is executed on the browser.

82) What are design patterns ?
Can you list down all patterns and their classification ?
Note :- This is advanced question because anyone who asks to list down all patterns can
only be crazy for what he is asking. But it is always a win-win situation for the interviewer.

ANS: Design patterns are recurring solution to recurring problems in software architecture.
There are three basic classification of patterns Creational, Structural and Behavioral
patterns.

Creational Patterns
√Abstract Factory:- Creates an instance of several families of classes
√Builder :- Separates object construction from its representation
√Factory Method:- Creates an instance of several derived classes
√Prototype:- A fully initialized instance to be copied or cloned
√Singleton:- A class in which only a single instance can exist
Note :- The best way to remember Creational pattern is by ABFPS (Abraham Became
First President of States).
Structural Patterns
√Adapter:-Match interfaces of different classes.
√Bridge:-Separates an object’s interface from its implementation.
√Composite:-A tree structure of simple and composite objects.
√Decorator :-Add responsibilities to objects dynamically.
√Façade:-A single class that represents an entire subsystem.
√Flyweight:-A fine-grained instance used for efficient sharing.
√Proxy:-An object representing another object.
Behavioral Patterns
√Mediator:-Defines simplified communication between classes.
√Memento:-Capture and restore an object's internal state.
√Interpreter:-A way to include language elements in a program.
√Iterator:-Sequentially access the elements of a collection.
√Chain of Resp:-A way of passing a request between a chain of objects.
√Command:-Encapsulate a command request as an object.
√State:-Alter an object's behavior when its state changes.
√Strategy:-Encapsulates an algorithm inside a class.
√Observer:-A way of notifying change to a number of classes.
√Template Method:-Defer the exact steps of an algorithm to a subclass.
√Visitor:-Defines a new operation to a class without change.

83)What is three tier architecture?

ANS: The three tier software architecture emerged in the 1990s to overcome the limitations of
the two tier architecture.
There are three layers when we talk about three tier architecture:-
User Interface (Client) :- This is mostly the windows user interface or the Web interface
but this has only the UI part.
Mid layer: - Middle tier provides process management where business logic and rules are
executed and can accommodate hundreds of users (as compared to only 100 users with
the two tier architecture) by providing functions such as queuing, application execution,
and database staging.
Data Access Layer: - This is also called by the famous acronym "DAL" component. It has
mainly the SQL statement which do the database operation part of the job.
The three tier architecture is used when an effective distributed client/server design is
needed that provides (when compared to the two tier) increased performance, flexibility,
maintainability, reusability, and scalability, while hiding the complexity of distributed
processing from the user.

84) What are different ways you can pass data between tiers?

ANS: There are many ways you can pass data between tiers :-
√Dataset the most preferred one as they maintain data in XML format.
√Datareader
√Custom classes.
√XML

85)What is the namespace in which .NET has the data
functionality classes ?

ANS: Following are the namespaces provided by .NET for data management :-
System.data
This contains the basic objects used for accessing and storing relational data, such as
DataSet,DataTable, and DataRelation. Each of these is independent of the type of data
source and the way we connect to it.
System.Data.OleDB
It contains the objects that we use to connect to a data source via an OLE-DB provider,
such as OleDbConnection, OleDbCommand, etc. These objects inherit from the common
base classes, and so have the same properties, methods, and events as the SqlClient
equivalents.
System.Data.SqlClient:
This contains the objects that we use to connect to a data source via the Tabular Data
Stream (TDS) interface of Microsoft SQL Server (only). This can generally provide better
performance as it removes some of the intermediate layers required by an OLE-DB
connection.
System.XML
This Contains the basic objects required to create, read, store, write, and manipulate
XML documents according to W3C recommendations.

86) Overview of ADO.NET architecture ?

ANS: The most important section in ADO.NET architecture is “Data Provider”. Data Provider
provides access to datasource (SQL SERVER, ACCESS, ORACLE).In short it provides
object to achieve functionalities like opening and closing connection, retrieve data and
update data. In the below figure you can see the four main sections of a data provider :-
√Connection.
√Command object (This is the responsible object to use stored procedures)
√Data Adapter (This object acts as a bridge between datastore and dataset).
√Datareader (This object reads data from data store in forward only mode).
Dataset object represents disconnected and cached data. If you see the diagram it is not
in direct connection with the data store (SQL SERVER, ORACLE etc) rather it talks
with Data adapter, who is responsible for filling the dataset. Dataset can have one or
more Datatable and relations.
“DataView” object is used to sort and filter data in Datatable.

87)What are the two fundamental objects in ADO.NET ?

ANS: Datareader and Dataset are the two fundamental objects in ADO.NET.

88)What is difference between dataset and datareader ?

ANS: Following are some major differences between dataset and datareader :-
√DataReader provides forward-only and read-only access to data, while the
DataSet object can hold more than one table (in other words more than one
rowset) from the same data source as well as the relationships between them.
√Dataset is a disconnected architecture while datareader is connected
architecture.
√Dataset can persist contents while datareader can not persist contents, they
are forward only.

89)What are major difference between classic ADO and
ADO.NET ?

ANS: Following are some major differences between both
√As in classic ADO we had client and server side cursors they are no more
present in ADO.NET. Note it's a disconnected model so they are no more
applicable.
√Locking is not supported due to disconnected model.
√All data persist in XML as compared to classic ADO where data
persisted in Binary format also.

90)What is the use of connection object ?

ANS: They are used to connect a data to a Command object.
√An OleDbConnection object is used with an OLE-DB provider
√A SqlConnection object uses Tabular Data Services (TDS) with MS SQL Server

91)What is the use of command objects ?

ANS: They are used to connect connection object to Datareader or dataset. Following are the
methods provided by command object :-
√ExecuteNonQuery :- Executes the command defined in the CommandText
property against the connection defined in the Connection property for a query
that does not return any row (an UPDATE, DELETE or INSERT). Returns
an Integer indicating the number of rows affected by the query.
√ExecuteReader :- Executes the command defined in the CommandText property
against the connection defined in the Connection property. Returns a "reader"
object that is connected to the resulting rowset within the database, allowing
the rows to be retrieved.
√ExecuteScalar :- Executes the command defined in the CommandText property
against the connection defined in the Connection property. Returns only
single value (effectively the first column of the first row of the resulting rowset)
any other returned columns and rows are discarded. It is fast and efficient
when only a "singleton" value is required

92)What is the use of dataadapter ?

ANS: These are objects that connect one or more Command objects to a Dataset object. They
provide logic that would get data from the data store and populates the tables in the
DataSet, or pushes the changes in the DataSet back into the data store.
√An OleDbDataAdapter object is used with an OLE-DB provider
√A SqlDataAdapter object uses Tabular Data Services with MS SQL Server.

93)What are basic methods of Dataadapter ?

ANS: There are three most commonly used methods of Dataadapter :-
Fill :- Executes the SelectCommand to fill the DataSet object with data from the data
source. It an also be used to update (refresh) an existing table in a DataSet with changes
made to the data in the original datasource if there is a primary key in the table in the
DataSet.
256
FillSchema :- Uses the SelectCommand to extract just the schema for a table from the
data source, and creates an empty table in the DataSet object with all the corresponding
constraints.
Update:- Calls the respective InsertCommand, UpdateCommand, or DeleteCommand for
each inserted, updated,or deleted row in the DataSet so as to update the original data
source with the changes made to the content of the DataSet. This is a little like the
UpdateBatch method provided by the ADO Recordset object, but in the DataSet it can
be used to update more than one table.

94)What is Dataset object?

ANS: The DataSet provides the basis for disconnected storage and manipulation of relational
data. We fill it from a data store,work with it while disconnected from that data store,
then reconnect and flush changes back to the data store if required.

95)What are the various objects in Dataset ?
ANS: Dataset has a collection of DataTable object within the Tables collection. Each DataTable
object contains a collection of DataRow objects and a collection of DataColumn objects.
There are also collections for the primary keys, constraints, and default values used in
this table which is called as constraint collection, and the parent and child relationships
between the tables. Finally, there is a DefaultView object for each table. This is used to
create a DataView object based on the table, so that the data can be searched, filtered or
otherwise manipulated while displaying the data.

96)What are the various methods provided by the dataset
object to generate XML?
Note:- XML is one of the most important leap between classic ADO and ADO.NET.
So this question is normally asked more generally how can we convert any data to XML
format. Best answer is convert in to dataset and use the below methods.

ANS: √ReadXML
Read’s a XML document in to Dataset.
√GetXML
This is a function which returns the string containing XML document.
√WriteXML
This writes a XML data to disk.

97) What is basic use of “DataView” ?

ANS: “DataView” represents a complete table or can be small section of rows depending on
some criteria. It is best used for sorting and finding data with in “datatable”.
Dataview has the following method’s :-
Find
It takes a array of values and returns the index of the row.
FindRow
This also takes array of values but returns a collection of “DataRow”.
If we want to manipulate data of “DataTable” object create “DataView” (Using the
“DefaultView” we can create “DataView” object) of the “DataTable” object and use the
following functionalities :-
AddNew
Adds a new row to the “DataView” object.
Delete
Deletes the specified row from “DataView” object.

98) What is the difference between “DataSet” and
“DataReader” ?

ANS: Following are the major differences between “DataSet” and “DataReader” :-
√“DataSet” is a disconnected architecture, while “DataReader” has live
connection while reading data. If we want to cache data and pass to a
different tier “DataSet” forms the best choice and it has decent XML support.
√When application needs to access data from more than one table “DataSet”
forms the best choice.
√If we need to move back while reading records, “datareader” does not support
this functionality.
√But one of the biggest drawbacks of DataSet is speed. As “DataSet” carry
considerable overhead because of relations, multiple tables etc speed is slower
than “DataReader”. Always try to use “DataReader” wherever possible, as
it’s meant specially for speed performance.

99)What is difference between Dataset. clone and Dataset.
copy ?

ANS: Clone: - It only copies structure, does not copy data.
Copy: - Copies both structure and data.

100)What are indexes? What is the difference between
clustered and nonclustered indexes?

ANS: Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrieve
the data quickly.
There are clustered and nonclustered indexes. A clustered index is a special type of index
that reorders the way in which records in the table are physically stored. Therefore table
can have only one clustered index. The leaf nodes of a clustered index contain the data
pages.
A nonclustered index is a special type of index in which the logical order of the index
does not match the physical stored order of the rows on disk. The leaf node of a
nonclustered index does not consist of the data pages. Instead, the leaf nodes contain
index rows.

101)What is the use of OLAP ?

ANS: OLAP is useful because it provides fast and interactive access to aggregated data and the
ability to drill down to detail.

102)What is the difference between DELETE TABLE and
TRUNCATE TABLE commands?

ANS: Following are difference between them :-
√DELETE TABLE syntax logs the deletes thus make the delete operation
slow. TRUNCATE table does not log any information but it logs information
about deallocation of data page of the table so TRUNCATE table is faster as
compared to delete table.
√DELETE table can have criteria while TRUNCATE can not.
√TRUNCATE table can not trigger.

103)What are advantages of SQL 2000 over SQl 7.0 ?

ANS:
√User-Defined Functions: User-Defined Functions (UDFs) -- one or more
Transact-SQL statements can be used to encapsulate code for reuse. Userdefined
functions cannot make a permanent change to the data or modify
database tables. UDF can change only local objects for a UDF, such as local
cursors or variables.
√Distributed Partitioned Views: Distributed partitioned views allow you to
partition tables horizontally across multiple servers. So, you can scale out one
database server to a group of database servers that cooperate to provide the
same performance levels as a cluster of database servers. Due to distributed
partitioned views, SQL Server 2000 now on the first place in the tpc-c tests.
√New Data Types: These include: bigint, an 8-byte integer type; sql_variant, a
data type that allows the storage of data of different data types; and the table
data type, which allows applications to store results temporarily for later use.
√INSTEAD OF and AFTER Triggers: There are INSTEAD OF and AFTER
Triggers in SQL Server 2000. INSTEAD OF triggers are executed instead of
the INSERT, UPDATE or DELETE triggering action. AFTER triggers are
executed after the triggering action.
√Cascading Referential Integrity Constraints: There are new ON DELETE and
ON UPDATE clauses in the REFERENCES clause of the CREATE TABLE
and ALTER TABLE statements. The ON DELETE clause controls what
actions are taken if you attempt to delete a row to which existing foreign keys
point. The ON UPDATE clause defines the actions that are taken if you
attempt to update a candidate key value to which existing foreign keys point.
√The ON DELETE and ON UPDATE clauses have two options:
NO ACTION :-NO ACTION specifies that the deletion/update
fail with an error.
CASCADE :-CASCADE specifies that all the rows with foreign
keys pointing to the deleted/updated row are also deleted and updated.
√32 CPU and 64GB Memory Support: SQL Server 2000 Enterprise Edition
running under Windows 2000 DataCenter can support up to 32 CPUs and up
to 64GB of physical memory (RAM) on a computer.
√XML Support: SQL Server 2000 can use XML to insert, update, and delete
values in the database, and the database engine can return data as Extensible
Markup Language (XML) documents

104)What is the difference between a HAVING CLAUSE
and a WHERE CLAUSE?

ANS: You can use Having Clause with the GROUP BY function in a query and WHERE
Clause is applied to each row before they are part of the GROUP BY function in a query.

105)What is the difference between Stored Procedure (SP)
and User Defined Function (UDF)?

ANS: Following are some major differences between a stored procedure and user defined
functions:-
√UDF can be executed using the “SELECT” clause while SP’s can not be.
√UDF can not be used in XML FOR clause but SP’s can be used.
√UDF does not return output parameters while SP’s return output parameters.
√If there is an error in UDF its stops executing. But in SP’s it just ignores the
error and moves to the next statement.
√UDF can not make permanent changes to server environments while SP’s can
change some of the server environment.

106) What is UML?

ANS: The Unified Modeling Language (UML) is a graphical language for visualizing, specifying,
constructing, and documenting the artifacts of a software-intensive system.UML provides
blue prints for business process, System function, programming language statements,
database schemas and reusable components.

107) How many types of diagrams are there in UML ?
Twist :- Explain in short all types of diagrams in UML ?

ANS: There are nine types of diagrams in UML :-
Use case diagram:
They describe "WHAT" of a system rather than "HOW" the system does it.They are
used to identify the primary elements and processes that form the system. The primary
elements are termed as "actors" and the processes are called "use cases". Use Case diagrams
shows "actors" and there "roles".
Class diagram:
From the use case diagram we can now go to detail design of system, for which the
primary step is class diagram. The best way to identify classes is to consider all "NOUNS"
in use cases as classes, "VERBS" as methods of classes, relation between actors can then
be used to define relation between classes. The relationship or association between the
classes can be either an "is-a" or "has-a" relationship which can easily be identified from
use cases.
Object diagram:
An object is an instance of a class. Object diagram captures the state of classes in the
system and their relationships or associations at a specific point of time.
State diagram:
A state diagram, as the name suggests, represents the different states that objects in the
system undergo during their life cycle. Object change in response to certain simulation so
this simulation effect is captured in state diagram. So basically it has a initial state and
final state and events that happen in between them. Whenever you think that some
simulations are complicated you can go for this diagram.
Sequence diagram:
Sequence diagrams can be used to explore the logic of a complex operation, function, or
procedure. They are called sequence diagrams because sequential nature is shown via
ordering of messages. First message starts at the top and the last message ends at bottom.
The important aspect of a sequence diagram is that it is time-ordered. This means that
the exact sequence of the interactions between the objects is represented step by step.
Different objects in the sequence diagram interact with each other by passing "messages".
Collaboration diagram:
A collaboration diagram groups together the interactions between different objects to
fulfill a common purpose.
Activity diagram:
Activity diagram is typically used for business process modeling, for modeling the logic
captured by a single use case, or for visualizing the detailed logic of a business
rule.Complicated process flows in the system are captured in the activity diagram. Similar
to a state diagram, an activity diagram also consists of activities, actions, transitions,
initial and final states, and guard conditions. But difference is state diagrams are in context
of simulation while activity gives detail view of business logic.
Deployment diagram:
Deployment diagrams show the hardware for your system, the software that is installed
on that hardware, and the middleware used to connect the disparate machines to one
another. It shows how the hardware and software work together to run a system. In one
line its shows the deployment view of the system.
Component diagram:
The component diagram represents the high-level parts that make up the system. From
.NET angle point of view they form the "NAMESPACES". This diagram depicts, at a
high level, what components form part of the system and how they are interrelated. Its
shows the logical grouping of classes or group of other components.

107)What is XML?

ANS: XML (Extensible markup language) is all about describing data. Below is a XML which
describes invoice data.


Shoes
12
100
10

An XML tag is not something predefined but it is something you have to define according
to your needs. For instance in the above example of invoice all tags are defined according
to business needs. The XML document is self explanatory, any one can easily understand
looking at the XML data what exactly it means.

108)What is the difference between XML and HTML?

ANS: XML describes data while HTML describes how the data should be displayed. So HTML
is about displaying information while XML is about describing information.

109)What is CSS?
ANS: With CSS you can format a XML document.

110)What is XSL?

ANS: XSL (the eXtensible Stylesheet Language) is used to transform XML document to some
other document. So its transformation document which can convert XML to some other
document. For instance you can apply XSL to XML and convert it to HTML document or
probably CSV files.
.
111)What is XSLT?

ANS: XSLT is a rule based language used to transform XML documents in to other file formats.
XSLT are nothing but generic transformation rules which can be applied to transform
XML document to HTML, CS, Rich text etc.
.

1.1 What is AJAX?
Ajax stands for Asynchronous Javascript & XML. It is a web technology through which a postback from a client (browser) to the server goes partially, which means that instead of a complete postback, a partial postback is triggered by the Javascript XmlHttpRequest object. In such a scenario, web-application users won't be able to view the complete postback progress bar shown by the browser. In an AJAX environment, it is Javascript that starts the communication with the web server. Ajax technology in a website may be implemented by using plain Javascript and XML. Code in such a scenario may tend to look little complex, for which the AJAX Framework in .NET can be embedded in ASP.NET web applications. In addition to XML & Javascript, AJAX is also based on DOM - the Document Object Model technology of browsers through which objects of the browser can be accessed through the memory heap using their address. JSON - Javascript Object Notation is also one of the formats used in AJAX, besides XML. So basically, in an AJAX-based web application, the complete page does not need to reload, and only the objects in context of ajaxification are reloaded. Ajax technology avoids the browser flickering.

1.2 Can Ajax be implemented in browsers that do not support the XmlHttpRequest object?
Yes. This is possible using remote scripts.

1.3 Can AJAX technology work on web servers other than IIS?
Yes, AJAX is a technology independent of web server the web application is hosted on. Ajax is a client (browser) technology.

1.4 Which browsers support the XmlHttpRequest object?
Internet Explorer 5.0+, Safari 1.2, Mozilla 1.0/Firefox, Opera 8.0 +, Netscape 7

1.5 How to we create an XmlHttpRequest object for Internet Explorer? How is this different for other browsers?
For Internet Explorer, an ActiveXObject is used for declaring an XmlHttpRequest object in Javascript. //Code as below for IE: xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP"); //For Other browsers, code as below: xmlHttpObject = new XMLHttpRequest(); Note that XmlHttpObject used above is simply a variable for the respective browsers.

1.6 What are the properties of the XmlHttpRequest object? What are the different types of readyStates in Ajax?
i) onreadyStateChange - This function is used to process the reply from the web server.ii) readyState - This property holds the response status of the web server. There are 5 states:1 - request not yet initialized2 - request now set3 - request sent 4 - request processing5 - request completes

1.7 What is the ASP.NET Ajax Framework? What versions have been released so far?
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 Controls2 - Support for all modern browsers3 - Access remote services and data from the browser without tons of complicated script. Versions of Ajax release 1 - ASP.NET Ajax Framework 1.0 (earlier release to this was called the Atlas) 2 - ASP.NET Ajax Framework 1.0 was available as a separate download for ASP.NET 2.0

1.8 What are Ajax Extensions?
The ASP.NET Ajax Extensions are set of Ajax-based controls that work in ASP.NET 2 (or above) based applications. Ofcourse,they also need the Ajax runtime which is actually the Ajax Framework 1.0. ASP.NET Ajax Extensions 1.0 have to be downloaded to run with ASP.NET 2.0 The new ASP.NET 3.5 Framework comes with the Ajax Library 3.5 (containing the Ajax Extensions 3.5). So in order to use the latest Ajax, simply download .NET 3.5 Framework.

1.9 What is the ASP.NET Control Toolkit?
Besides the Ajax Framework (which is the Ajax engine) and Ajax Extensions (which contain the default Ajax controls), there is a toolkit called the Ajax Control Toolkit available for use & download (for free). This is a collection of rich featured, highly interactive controls, created as a joint venture between Microsoft & the Developer Community.

1.10 What is Dojo?
Dojo is a third-party javascript toolkit for creating rich featured applications. Dojo is an Open Source DHTML toolkit written in JavaScript. It builds on several contributed code bases (nWidgets, Burstlib, f(m)), which is why we refer to it sometimes as a "unified" toolkit. Dojo aims to solve some long-standing historical problems with DHTML which prevented mass adoption of dynamic web application development.
1.11 How to handle multiple or concurrent requests in Ajax?
For concurrent requests, declare separate XmlHttpRequest objects for each request. For example, for request to get data from an SQL table1, use something like this...
xmlHttpObject1.Onreadystatechange = functionfromTable1();
and to get data from another table (say table2) at the same time, use
xmlHttpObject2.Onreadystatechange = functionfromTable2();
Ofcourse, the XmlHttpObject needs to be opened & parameters passed too, like as shown below...
xmlHTTPObject1.open("GET","http://"localhost// " + "Website1/Default1.aspx" true);
Note that the last parameter "true" used above means that processing shall carry on without waiting for any response from the web server. If it is false, the function shall wait for a response.

1.12- How to create an AJAX website using Visual Studio?
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). If using Visual Studio 2008 Web Developer Express or above, Ajax comes along with it (so no need of a separate installation).
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.

1.13 Can we override the EnablePartialRendering property of the ScriptManager class?
Yes. But this has to be done before the init event of the page (or during runtime after the page has already loaded). Otherwise an InvalidOperationException will be thrown.

1.14 How to use multiple ScriptManager controls in a web page?
No. It is not possible to use multiple ScriptManager control in a web page. In fact, any such requirement never comes in because a single ScriptManager control is enough to handle the objects of a web page.
1.15 - Whats the difference between RegisterClientScriptBlock, RegisterClientScriptInclude and RegisterClientScriptResource?
For all three, a script element is rendered after the opening form tag. Following are the differences:
1 - RegisterClientScriptBlock - The script is specified as a string parameter.
2 - RegisterClientScriptInclude - The script content is specified by setting the src attribute to a URL that points to a script file.
3 - RegisterClientScriptResource - The script content is specified with a resource name in an assembly. The src attribute is automatically populated with a URL by a call to an HTTP handler that retrieves the named script from the assembly.
1.16 What are type/key pairs in client script registration? Can there be 2 scripts with the same type/key pair name?
When a script is registered by the ScriptManager class, a type/key pair is created to uniquely identify the script. For identification purposes, the type/key pair name is always unique for dentifying a script. Hence, there may be no duplication in type/key pair names.
1.17 What is an UpdatePanel Control?
An UpdatePanel control is a holder for server side controls that need to be partial postbacked in an ajax cycle. All controls residing inside the UpdatePanel will be partial postbacked. Below is a small example of using an UpdatePanel.
As you see here after running the snippet above, there wont be a full postback exhibited by the web page. Upon clicking the button, the postback shall be partial. This means that contents outside the UpdatePanel wont be posted back to the web server. Only the contents within the UpdatePanel are refreshed.
1.18 How to control how long an Ajax request may last?
Use the ScriptManager's AsyncPostBackTimeout Property. For example, if you want to debug a web page but you get an error that the page request has timed out, you may set where the value specified is in seconds.
1.19 What are limitations of Ajax?
An Ajax Web Application tends to confused end users if the network bandwidth is slow, because there is no full postback running. However, this confusion may be eliminated by using an UpdateProgress control in tandem.
1.20 How to make sure that contents of an UpdatePanel update only when a partial postback takes place (and not on a full postback)?
Make use of ScriptManager.IsInAsyncPostBack property (returns a boolean value)
2.1 Which request is better with AJAX, Get or Post?
AJAX requests should use an HTTP GET request while retrieving data where the data does not change for a given URL requested. An HTTP POST should be used when state is updated on the server. This is in line with HTTP idempotency recommendations and is highly recommended for a consistent web application architecture.
2.2 Is the server or the client in control in AJAX?
It depends. With AJAX the answer is more in between. Control can be more centralized in a server-side component or as a mix of client-side and server-side controllers. Centralized server-side controller - When having a more centralized controller the key is to make sure the data in client-side page is in sync with that of the server. Some applications may keep all the state on the server and push all updates to client DOM via a simple JavaScript controller. Client and server-side controllers - This architecture would use JavaScript to do all presentation related control, event processing, page manipulation, and rendering of model data on the client. The server-side would be responsible for things such as business logic and pushing updated model data to the client. In this case the server would not have intimate knowledge of the presentation short of the initial page that would be sent to the client page request. There are some use cases where an entire AJAX application can be written in a single page. Keep in mind if you choose this type of architecture that navigation and bookmarking should be considered.
2.3 Does Java have support for Comet style server-side push?
Current AJAX applications use polling to communicate changes data between the server and client. Some applications, such as chat applications, stock tickers, or score boards require more immediate notifications of updates to the client. Comet is an event based low latency server side push for AJAX applications. Comet communication keeps one of the two connections available to the browser open to continously communicate events from the server to the client.
2.4 Who is Using Ajax ?
Google is making a huge investment in developing the Ajax approach. All of the major products Google has introduced over the last year — Orkut, Gmail, the latest beta version of Google Groups, Google Suggest, and Google Maps — are Ajax applications. (For more on the technical nuts and bolts of these Ajax implementations, check out these excellent analyses of Gmail, Google Suggest, and Google Maps.) Others are following suit: many of the features that people love in Flickr depend on Ajax, and Amazon’s A9.com search engine applies similar techniques. These projects demonstrate that Ajax is not only technically sound, but also practical for real-world applications. This isn’t another technology that only works in a laboratory. And Ajax applications can be any size, from the very simple, single-function Google Suggest to the very complex and sophisticated Google Maps. At Adaptive Path, we’ve been doing our own work with Ajax over the last several months, and we’re realizing we’ve only scratched the surface of the rich interaction and responsiveness that Ajax applications can provide. Ajax is an important development for Web applications, and its importance is only going to grow. And because there are so many developers out there who already know how to use these technologies, we expect to see many more organizations following Google’s lead in reaping the competitive advantage Ajax provides. Moving Forward The biggest challenges in creating Ajax applications are not technical. The core Ajax technologies are mature, stable, and well understood. Instead, the challenges are for the designers of these applications: to forget what we think we know about the limitations of the Web, and begin to imagine a wider, richer range of possibilities
2.5 Is it possible to set session variables from javascript?
It's not possible to set any session variables directly from javascript as it is purely a client side technology. You can use AJAX though to asyncronously... Cannot parse XML generated by JSP I am generating an XML using JSP, when i run the JSP in IE it shows the XML as per DOM, but when i try to parse it using Javascript , the command xmldoc.documentElement... This is working code I am using, it might help you. if (!isIE) xmldoc = req.responseXML; else { //IE does not take the responseXML as...
2.6 What do I need to know to create my own AJAX functionality?
If you plan not to reuse and existing AJAX component here are some of the things you will need to know. Plan to learn Dynamic HTML (DHTML), the technology that is the foundation for AJAX. DHTML enables browser-base real time interaction between a user and a web page. DHTML is the combination of JavaScript, the Document Object Model (DOM) and Cascading Style Sheets (CSS). * JavaScript - JavaScript is a loosely typed object based scripting language supported by all major browsers and essential for AJAX interactions. JavaScript in a page is called when an event in a page occurs such as a page load, a mouse click, or a key press in a form element. * DOM - An API for accessing and manipulating structured documents. In most cases DOM represent the structure of XML and HTML documents. * CSS - Allows you to define the presentation of a page such as fonts, colors, sizes, and positioning. CSS allow for a clear separation of the presentation from the content and may be changed programmatically by JavaScript. Understanding the basic request/response nature of HTTP is also important. Many subtle bugs can result if you ignore the differences between the GET and OIst methods when configuring an XMLHttpRequest and HTTP response codes when processing callbacks. JavaScript is the client-side glue, in a sense. JavaScript is used to create the XMLHttpRequest Object and trigger the asynchronous call. JavaScript is used to parse the returned content. JavaScript is used to analyze the returned data and process returned messages. JavaScript is used to inject the new content into the HTML using the DOM API and to modify the CSS.
2.7 Do I really need to learn JavaScript?
Basically yes if you plan to develop new AJAX functionality for your web application. On the other hand, JSF components and component libraries can abstract the details of JavaScript, DOM and CSS. These components can generate the necessary artifacts to make AJAX interactions possible. Visual tools such as Java Studio Creator may also use AJAX enabled JSF components to create applications, shielding the tool developer from many of the details of AJAX. If you plan to develop your own JSF components or wire the events of components together in a tool it is important that you have a basic understanding of JavaScript. There are client-side JavaScript libraries (discussed below) that you can call from your in page JavaScript that abstract browser differences. Object Hierarchy and Inheritance in JavaScript is a great resource for a Java developer to learn about JavaScript objects.
2.8 What is the difference between proxied and proxyless calls?
Proxied calls are made through stub objects that mimic your PHP classes on the JavaScript side. E.g., the helloworld class from the Hello World example. Proxyless calls are made using utility javascript functions like HTML_AJAX.replace() and HTML_AJAX.append().
2.9 Should I use XML or text, JavaScript, or HTML as a return type?
It depends. Clearly the 'X' in AJAX stands for XML, but several AJAX proponents are quick to point out that nothing in AJAX, per se, precludes using other types of payload, such as, JavaScript, HTML, or plain text. * XML - Web Services and AJAX seem made for one another. You can use client-side API's for downloading and parsing the XML content from RESTful Web Services. (However be mindful with some SOAP based Web Services architectures the payloads can get quite large and complex, and therefore may be inappropriate with AJAX techniqes.) * Plain Text - In this case server-generated text may be injected into a document or evaluated by client-side logic. * JavaScript - This is an extension to the plain text case with the exception that a server-side component passes a fragment of JavaScript including JavaScript object declarations. Using the JavaScript eval() function you can then create the objects on the client. JavaScript Object Notation (JSON), which is a JavaScript object based data exchange specification, relies on this technique. * HTML - Injecting server-generated HTML fragments directly into a document is generally a very effective AJAX technique. However, it can be complicated keeping the server-side component in sync with what is displayed on the client. Mashup is a popular term for creating a completely new web application by combining the content from disparate Web Services and other online API's. A good example of a mashup is housingmaps.com which graphically combines housing want-ads from craiglist.org and maps from maps.google.com.
2.10 Are there any frameworks available to help speedup development with AJAX?
There are several browser-side frameworks available, each with their own uniqueness...
2.11 Is Adaptive Path selling Ajax components or trademarking the name? Where can I download it?
Ajax isn’t something you can download. It’s an approach — a way of thinking about the architecture of web applications using certain technologies. Neither the Ajax name nor the approach are proprietary to Adaptive Path.
2.12 Should I use an HTTP GET or POST for my AJAX calls?
AJAX requests should use an HTTP GET request when retrieving data where the data will not change for a given request URL. An HTTP POST should be used when state is updated on the server. This is in line with HTTP idempotency recommendations and is highly recommended for a consistent web application architecture.
2.13 How do I debug JavaScript?
There are not that many tools out there that will support both client-side and server-side debugging. I am certain this will change as AJAX applications proliferate. I currently do my client-side and server-side debugging separately. Below is some information on the client-side debuggers on some of the commonly used browsers. * Firefox/Mozilla/Netscape - Have a built in debugger Venkman which can be helpful but there is a Firefox add on known as FireBug which provides all the information and AJAX developer would ever need including the ability to inspect the browser DOM, console access to the JavaScript runtime in the browser, and the ability to see the HTTP requests and responses (including those made by an XMLHttpRequest). I tend to develop my applications initially on Firefox using Firebug then venture out to the other browsers. * Safari - Has a debugger which needs to be enabled. See the Safari FAQ for details. * Internet Explorer - There is MSDN Documentation on debugging JavaScript. A developer toolbar for Internet Explorer may also be helpful. While debuggers help a common technique knowing as "Alert Debugging" may be used. In this case you place "alert()" function calls inline much like you would a System.out.println. While a little primitive it works for most basic cases. Some frameworks such as Dojo provide APIs for tracking debug statements.

2.14 How do I provide internationalized AJAX interactions?
Just because you are using XML does not mean you can properly send and receive localized content using AJAX requests. To provide internationalized AJAX components you need to do the following: * Set the charset of the page to an encoding that is supported by your target languages. I tend to use UTF-8 because it covers the most languages. The following meta declaration in a HTML/JSP page will set the content type: * In the page JavaScript make sure to encode any parameters sent to the server. JavaScript provides the escape() function which returns Unicode escape strings in which localized text will appear in hexadecimal format. For more details on JavaScript encoding see Comparing escape(), encodeURI(), and encodeURIComponent(). * On the server-side component set the character encoding using the HttpServletRequest.setCharacterEncoding() method. Before you access the localized parameter using the HttpServletRequest.getParameter() call. In the case of UTF this would be request.setCharactherEncoding("UTF-8");. A server-side component returning AJAX responses needs to set the encoding of the response to the same encoding used in the page. response.setContentType("text/xml;charset=;UTF-8"); response.getWriter().write(" invalid "); For more information on using AJAX with Java Enterprise Edition technologies see AJAX and Internationalization and for developing multi-lingual applications see Developing Multilingual Web Applications Using JavaServer Pages Technology.
2.15 Are Ajax applications easier to develop than traditional web applications?
Not necessarily. Ajax applications inevitably involve running complex JavaScript code on the client. Making that complex code efficient and bug-free is not a task to be taken lightly, and better development tools and frameworks will be needed to help us meet that challenge.
2.16 Whats with the -alpha in the install instructions?
HTML_AJAX hasn't had a stable release yet and the pear installer doesn't install non stable packages by default unless you specify a version.
2.17 How do I test my AJAX code?
There is a port of JUnit for client-side JavaScript called JsUnit
2.18 What exactly is the W3C DOM?
The W3C Document Object Model (DOM) is defined by the W3C as the following: The Document Object Model is a platform- and language-neutral interface...
2.19 When will HTML_AJAX have a stable release?
Once all the major features are complete and the API has been tested, the roadmap gives an idea of whats left to be done.
2.20 What parts of the HTML_AJAX API are stable?
We don't have a list right now, but most of the API is stable as of 0.3.0. There should be no major changes at this point, though there will be lots of new additions.
3.1 What Browsers does HTML_AJAX work with?
As of 0.3.0, all the examples that ship with HTML_AJAX have been verified to work with * Firefox 1.0+ * Internet Explorer 5.5+ (5.0 should work but it hasn't been tested) Most things work with * Safari 2+ * Opera 8.5+
3.2 Is Ajax just another name for XMLHttpRequest?
No. XMLHttpRequest is only part of the Ajax equation. XMLHttpRequest is the technical component that makes the asynchronous server communication possible; Ajax is our name for the overall approach described in the article, which relies not only on XMLHttpRequest, but on CSS, DOM, and other technologies.
3.3 How do I abort the current XMLHttpRequest?
Just call the abort() method on the request.
3.4 What is the minimum version of PHP that needs to be running in order to use HTML_AJAX?
The oldest PHP version i've fully tested HTML_AJAX is 4.3.11, but it should run on 4.2.0 without any problems. (Testing reports from PHP versions older then 4.3.11 would be appreciated.)
3.5 Why does HTML_AJAX hang on some server installs ?
If you run into an HTML_AJAX problem only on some servers, chances are your running into a problem with output compression. If the output compression is handled in the PHP config we detect that and do the right thing, but if its done from an apache extension we have no way of knowing its going to compress the body. Some times setting HTML_AJAX::sendContentLength to false fixes the problem, but in other cases you'll need to disabled the extension for the AJAX pages. I've also seen problems caused by debugging extensions like XDebug, disabling the extension on the server page usually fixes that. Questions dealing with Using HTML_AJAX, and general JavaScript development
3.6 How do I get the XMLHttpRequest object?
Depending upon the browser... if (window.ActiveXObject) { // Internet Explorer http_request = new ActiveXObject("Microsoft.XMLHTTP"); } else if...
3.7 Are there any security issues with AJAX?
JavaScript is in plain view to the user with by selecting view source of the page. JavaScript can not access the local filesystem without the user's permission. An AJAX interaction can only be made with the servers-side component from which the page was loaded. A proxy pattern could be used for AJAX interactions with external services. You need to be careful not to expose your application model in such as way that your server-side components are at risk if a nefarious user to reverse engineer your application. As with any other web application, consider using HTTPS to secure the connection when confidential information is being exchanged.
3.8 What about applets and plugins ?
Don't be too quick to dump your plugin or applet based portions of your application. While AJAX and DHTML can do drag and drop and other advanced user interfaces there still limitations especially when it comes to browser support. Plugins and applets have been around for a while and have been able to make AJAX like requests for years. Applets provide a great set of UI components and APIs that provide developers literally anything. Many people disregard applets or plugins because there is a startup time to initialize the plugin and there is no guarantee that the needed version of a plugin of JVM is installed. Plugins and applets may not be as capable of manipulating the page DOM. If you are in a uniform environment or can depend on a specific JVM or plugin version being available (such as in a corporate environment) a plugin or applet solution is great. One thing to consider is a mix of AJAX and applets or plugins. Flickr uses a combination of AJAX interactions/DHTML for labeling pictures and user interaction and a plugin for manipulating photos and photo sets to provide a great user experience. If you design your server-side components well they can talk to both types of clients.
3.9 Why did you feel the need to give this a name?
I needed something shorter than “Asynchronous JavaScript+CSS+DOM+XMLHttpRequest” to use when discussing this approach with clients.
3.10 10Techniques for asynchronous server communication have been around for years. What makes Ajax a “new” approach?
What’s new is the prominent use of these techniques in real-world applications to change the fundamental interaction model of the Web. Ajax is taking hold now because these technologies and the industry’s understanding of how to deploy them most effectively have taken time to develop.
3.11 Is Ajax a technology platform or is it an architectural style?
It’s both. Ajax is a set of technologies being used together in a particular way.
3.12 How does HTML_AJAX compare with the XAJAX project at Sourceforge?
XAJAX uses XML as a transport for data between the webpage and server, and you don't write your own javascript data handlers to manipulate the data received from the server. Instead you use a php class and built in javascript methods, a combination that works very similiar to the HTML_AJAX_Action class and haSerializer combo. XAJAX is designed for simplicity and ease of use. HTML_AJAX allows for multiple transmission types for your ajax data - such as urlencoding, json, phpserialized, plain text, with others planned, and has a system you can use to write your own serializers to meet your specific needs. HTML_AJAX has a class to help generate javascript (HTML_AJAX_Helper) similiar to ruby on rail's javascript helper (although it isn't complete), and an action system similiar to XAJAX's "action pump" that allows you to avoid writing javascript data handlers if you desire. But it also has the ability to write your own data handling routines, automatically register classes and methods using a server "proxy" script, do different types of callbacks including grabbing remote urls, choose between sync and async requests, has iframe xmlhttprequest emulation fallback capabilities for users with old browsers or disabled activeX, and is in active development with more features planned (see the Road Map for details) HTML_AJAX has additional features such as client pooling and priority queues for more advanced users, and even a javascript utility class. Although you can use HTML_AJAX the same way you use XAJAX, the additional features make it more robust, extensible and flexible. And it is a pear package, you can use the pear installer to both install and keep it up to date. If you're asking which is "better" - as with most php scripts it's a matter of taste and need. Do you need a quick, simple ajax solution? Or do you want something that's flexible, extensible, and looking to incorporate even more great features? It depends on the project, you as a writer, and your future plans.

3.13 What browsers support AJAX?
Internet Explorer 5.0 and up, Opera 7.6 and up, Netscape 7.1 and up, Firefox 1.0 and up, Safari 1.2 and up, among others.
3.14 Will HTML_AJAX integrate with other Javascript AJAX libraries such as scriptaculous ? How would this integration look like?
HTML_AJAX doesn't have specific plans to integrate with other JavaScript libraries. Part of this is because external dependencies make for a more complicated installation process. It might make sense to offer some optional dependencies on a library like scriptaculous automatically using its visual effects for the loading box or something, but there isn't a lot to gain from making default visuals like that flashier since they are designed to be easily replaceable.

3.15 When should I use an Java applet instead of AJAX?
Applets provide a rich experience on the client side and there are many things they can do that an AJAX application cannot do, such as custom data streaming, graphic manipulation, threading, and advanced GUIs. While DHTML with the use of AJAX has been able to push the boundaries on what you can do on the client, there are some things that it just cannot do. The reason AJAX is so popular is that it only requires functionality built into the browser (namely DHTML and AJAX capabilities). The user does not need to download and/or configure plugins. It is easy to incrementally update functionality and know that that functionality will readily available, and there are not any complicated deployment issues. That said, AJAX-based functionality does need to take browser differences into consideration. This is why we recommend using a JavaScript library such as Dojo which abstracts browser differences. So the "bottom line" is: If you are creating advanced UIs where you need more advanced features on the client where you want UI accuracy down to the pixel, to do complex computations on the client, use specialized networking techniques, and where you know that the applet plugin is available for your target audience, applets are the way to go. AJAX/DHTML works well for applications where you know the users are using the latest generation of browsers, where DHTML/AJAX "good enough" for you, and where your developers have JavaScript/DHTML/AJAX skills. Many amazing things can be done with AJAX/DHTML but there are limitations. AJAX and applets can be used together in the same UIs with AJAX providing the basic structure and applets providing more advanced functionality. The Java can communicate to JavaScript using the Live-Connect APIs. The question should not be should framed as do I use AJAX or applets, but rather which technology makes the best sense for what you are doing. AJAX and applets do not have to be mutually exclusive.

3.16 What kinds of applications is Ajax best suited for?
We don’t know yet. Because this is a relatively new approach, our understanding of where Ajax can best be applied is still in its infancy. Sometimes the traditional web application model is the most appropriate solution to a problem.

3.17 Does this mean Adaptive Path is anti-Flash?
Not at all. Macromedia is an Adaptive Path client, and we’ve long been supporters of Flash technology. As Ajax matures, we expect that sometimes Ajax will be the better solution to a particular problem, and sometimes Flash will be the better solution. We’re also interested in exploring ways the technologies can be mixed (as in the case of Flickr, which uses both).

3.18 Where can I find examples of AJAX?
While components of AJAX have been around for some time (for instance, 1999 for XMLHttpRequest), it really didn't become that popular until Google took...
3.19 What is the XMLHttpRequest object?
It offers a non-blocking way for JavaScript to communicate back to the web server to update only part of the web page.
3.20 How do I access data from other domains to create a mashup with Java?
From your JavaScript clients you can access data in other domains if the return data is provide in JSON format. In essence you can create a JavaScript client that runs operates using data from a different server. This technique is know as JSON with Padding or JSONP. There are questions as to whether this method is secure as you are retrieving data from outside your domain and allowing it to be excuted in the context of your domain. Not all data from third parties is accessible as JSON and in some cases you may want an extra level of protection. With Java you can provide a proxy to third party services using a web component such as a servlet. This proxy can manage the communication with a third party service and provide the data to your clients in a format of your choosing. You can also cache data at your proxy and reduce trips to service. For more on using a Java proxy to create mashups see The XmlHttpProxy Client for Java.
4.1 Is the XMLHttpRequest object part of a W3C standard?
No. Or not yet. It is part of the DOM Level 3 Load and Save Specification proposal.
4.2 What kinds of applications is Ajax best suited for?
We don’t know yet. Because this is a relatively new approach, our understanding of where Ajax can best be applied is still in its infancy. Sometimes the traditional web application model is the most appropriate solution to a problem.
4.3 Does this mean Adaptive Path is anti-Flash?
Not at all. Macromedia is an Adaptive Path client, and we’ve long been supporters of Flash technology. As Ajax matures, we expect that sometimes Ajax will be the better solution to a particular problem, and sometimes Flash will be the better solution. We’re also interested in exploring ways the technologies can be mixed (as in the case of Flickr, which uses both).
4.4 Where can I find examples of AJAX?
While components of AJAX have been around for some time (for instance, 1999 for XMLHttpRequest), it really didn't become that popular until Google took...
4.5 What is the XMLHttpRequest object?
It offers a non-blocking way for JavaScript to communicate back to the web server to update only part of the web page.
4.6 Does Ajax have significant accessibility or browser compatibility limitations? Do Ajax applications break the back button? Is Ajax compatible with REST? Are there security considerations with Ajax development? Can Ajax applications be made to work for users who have JavaScript turned off?
The answer to all of these questions is “maybe”. Many developers are already working on ways to address these concerns. We think there’s more work to be done to determine all the limitations of Ajax, and we expect the Ajax development community to uncover more issues like these along the way.
4.7 How do I access data from other domains to create a mashup with Java?
From your JavaScript clients you can access data in other domains if the return data is provide in JSON format. In essence you can create a JavaScript client that runs operates using data from a different server. This technique is know as JSON with Padding or JSONP. There are questions as to whether this method is secure as you are retrieving data from outside your domain and allowing it to be excuted in the context of your domain. Not all data from third parties is accessible as JSON and in some cases you may want an extra level of protection. With Java you can provide a proxy to third party services using a web component such as a servlet. This proxy can manage the communication with a third party service and provide the data to your clients in a format of your choosing. You can also cache data at your proxy and reduce trips to service. For more on using a Java proxy to create mashups see The XmlHttpProxy Client for Java.
4.8 Does Java have support for Comet style server-side push?
Current AJAX applications use polling to communicate changes data between the server and client. Some applications, such as chat applications, stock tickers, or score boards require more immediate notifications of updates to the client. Comet is an event based low latency server side push for AJAX applications. Comet communication keeps one of the two connections available to the browser open to continously communicate events from the server to the client. A Java based solution for Comet is being developed for Glassfish on top of the Grizzly HTTP connector. See Enabling Grizzly by Jean-Francois Arcand for more details.
4.9 Is the XMLHttpRequest object part of a W3C standard?
No. Or not yet. It is part of the DOM Level 3 Load and Save Specification proposal.
4.10 What AJAX framework do you recommend for PHP applications?
SAjax, NAjax, FAjax.All of them are ok, but it it best to make your own to suit your needs. What AJAX framework do you recommend for PHP applications? Answer SAjax, NAjax, FAjax.All of them are ok, but it it best to make your own to suit your needs.
5.1 Do Ajax applications always deliver a better experience than traditional web applications?
Not necessarily. Ajax gives interaction designers more flexibility. However, the more power we have, the more caution we must use in exercising it. We must be careful to use Ajax to enhance the user experience of our applications, not degrade it. What JavaScript libraries and frameworks are available? There are many libraries/frameworks out there (and many more emerging) that will help abstract such things as all the nasty browser differences. Three good libraries are The Dojo Toolkit, Prototype, and DWR.
* The Dojo Toolkit contains APIs and widgets to support the development of rich web applications. Dojo contains an intelligent packaging system, UI effects, drag and drop APIs, widget APIs, event abstraction, client storage APIs, and AJAX interaction APIs. Dojo solves common usability issues such as support for dealing with the navigation such as the ability to detect the browser back button, the ability to support changes to the URL in the URL bar for bookmarking, and the ability to gracefully degrade when AJAX/JavaScript is not fully support on the client. Dojo is the Swiss Army Knife of JavaScript libraries. It provides the widest range of options in a single library and it does a very good job supporting new and older browsers.
* Prototype focuses on AJAX interactions including a JavaScript AJAX object that contains a few objects to do basic tasks such as make a request, update a portion of a document, insert content into a document, and update a portion of a document periodically. Prototype JavaScript library contains a set of JavaScript objects for representing AJAX requests and contains utility functions for accessing in page components and DOM manipulations. Script.aculo.us and Rico are built on top of Prototype and provide UI effects, support for drag and drop, and include common JavaScript centric widgets. If you are just looking to support AJAX interactions and a few basic tasks Prototype is great. If you are looking for UI effects Rico and Script.aculo.us are good options.
* Yahoo UI Library is a utility library and set of widgets using the APIs to support rich clients. The utility library includes support for cross-browser AJAX interactions, animation, DOM scriptging support, drag and drop, and cross browser event support. The Yahoo UI Library is well documnented and contains many examples.
* DWR (Dynamic Web Remoting) is a client-side and server-side framework that focuses on allowing a developer to do RPC calls from client-side JavaScript to plain old Java objects in a Java Enterprise Edition web container. On the server side DWR uses a Servlet to interact with the Java objects and returns object representations of the Java objects or XML documents. DWR will be easy to get up and running and plays well with other Java technologies. If you are looking for a client-side and server-side framework that integrates well use DWR.
* Google Web Toolkit (GWT) is client/server framework provided by Google that allows a developer to write an AJAX application in pure Java. The GWT takes care of the details of generating all the client-side code using a Java-to-JavaScript compiler. One of the key benefits of the GWT Software Developer Kit (SDK) is that it allows you to debug your applications in what is known as GWT hosted mode using an embedded browser (IE on Windows and Mozilla/Gecko on Linux) that is tied to the toolkit. In GWT hosted mode you setup through the code and debug it as it is running on both the client and server. The GWT contains a default set of widgets and widget containers. An application is built by coding a set of widgets and containers together much like would be done in a Swing application. The GWT Software Developer Kit (SDK) is limited to Linux and Windows XP/2000 though the web applications it generates are compatible with the latest generation of the mainstream browsers. There are many new and emerging libraries for JavaScript and this list only reviews some of the more common libraries. When making a choice choose the library which suites your needs the best. While it might be better to choose one, there is nothing stopping you from using more than one framework. For a more extensive list of client-side frameworks see: Survey of AJAX/JavaScript Libraries.
5.2 Is AJAX code cross browser compatible?
Not totally. Most browsers offer a native XMLHttpRequest JavaScript object, while another one (Internet Explorer) require you to get it as an ActiveX object....
5.3 How do I create a thread to do AJAX polling?
JavaScript does not have threads. JavaScript functions are called when an event happens in a page such as the page is loaded, a mouse click, or a form element gains focus. You can create a timer using the setTimeout which takes a function name and time in milliseconds as arguments. You can then loop by calling the same function as can be seen in the JavaScript example below.
function checkForMessage() {
// start AJAX interaction with processCallback as the callback function
}
// callback for the request
function processCallback() {
// do post processing
setTimeout("checkForMessage()", 10000);
}

0 comments: