Web Service & Remoting

Web Services are applications delivered as a service on the Web. Web services allow for programmatic access of business logic over the Web. Web services typically rely on XML-based protocols, messages, and interface descriptions for communication and access. Web services are designed to be used by other programs or applications rather than directly by end user. Programs invoking a Web service are called clients. SOAP over HTTP is the most commonly used protocol for invoking Web services.

  1. Are Web Services a replacement for other distributed computing platforms?
    No. Web Services is just a new way of looking at existing implementation platforms.
  2. In a WebService, need to display 10 rows from a table. So DataReader or DataSet is best choice?
    A: WebService will support only DataSet.
  3. How to generate WebService proxy? What is SOAP, WSDL, UDDI and the concept behind Web Services? What are various components of WSDL? What is the use of WSDL.exe utility?
    SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet, for example using request and reply messages or sending entire documents. SOAP is simple, easy to use, and completely neutral with respect to operating system, programming language, or distributed computing platform.
    After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise), a better way was needed to describe the messages and how they are exchanged. The Web Services Description Language (WSDL) is a particular form of an XML Schema, developed by Microsoft and IBM for the purpose of defining the XML message, operation, and protocol mapping of a web service accessed using SOAP or other XML protocol. WSDL defines web services in terms of "endpoints" that operate on XML messages. The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly, so they can be mapped to multiple physical implementations. The current WSDL spec describes how to map messages and operations to SOAP 1.1, HTTP GET/POST, and MIME. WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages. The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using "ports").
    The Universal Description, Discovery, and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information, including the web services a business exposes to the Internet. UDDI is an independent consortium of vendors, founded by Microsoft, IBM, and Ariba, for the purpose of developing an Internet standard for web service description registration and discovery. Microsoft, IBM, and Ariba also are hosting the initial deployment of a UDDI service, which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses). UDDI uses a private agreement profile of SOAP (i.e. UDDI doesn't use the SOAP serialization format because it's not well suited to passing complete XML documents (it's aimed at RPC style interactions). The main idea is that businesses use the SOAP APIs to register themselves with UDDI, and other businesses search UDDI when they want to discover a trading partner, for example someone from whom they wish to procure sheet metal, bolts, or transistors. The information in UDDI is categorized according to industry type and geographical location, allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact. Once a specific business is chosen, another call to UDDI is made to obtain the specific contact information for that business. The contact information includes a pointer to the target business's WSDL or other XML schema file describing the web service that the target business publishes.
    • How to generate proxy class other than .net app and Wsdl tool?
      To access an XML Web service from a client application, you first add a Web reference, which is a reference to an XML Web service. When you create a Web reference, Visual Studio creates an XML Web service proxy class automatically and adds it to your project. This proxy class exposes the methods of the XML Web service and handles the marshalling of appropriate arguments back and forth between the XML Web service and your application. Visual Studio uses the Web Services Description Language (WSDL) to create the proxy.

  1. What is a proxy in web service? How do I use a proxy server when invoking a Web service?
  2. Asynchronous web service means?
  3. What are the events fired when web service called?
  4. How will do transaction in Web Services?
  5. How does SOAP transport happen and what is the role of HTTP in it? How you can access a web service using soap?
  6. What are the different formatters can be used in both? Why?.. binary/soap
  7. How you will protect / secure a web service?
    For the most part, things that you do to secure a Web site can be used to secure a Web Service. If you need to encrypt the data exchange, you use Secure Sockets Layer (SSL) or a Virtual Private Network to keep the bits secure. For authentication, use HTTP Basic or Digest authentication with Microsoft® Windows® integration to figure out who the caller is.
    these items cannot:
    • Parse a SOAP request for valid values
    • Authenticate access at the Web Method level (they can authenticate at the Web Service level)
    • Stop reading a request as soon as it is recognized as invalid
  8. How will you expose/publish a webservice?
  9. What is disco file?
  10. What’s the attribute for webservice method? What is the namespace for creating webservice?
    [WebMethod]

    using System.Web;
    using System.Web.Services;
  11. What is Remoting?
    The process of communication between different operating system processes, regardless of whether they are on the same computer. The .NET remoting system is an architecture designed to simplify communication between objects living in different application domains, whether on the same computer or not, and between different contexts, whether in the same application domain or not.
  12. Difference between web services & remoting?
  13. Can you pass SOAP messages through remoting?
  14. CAO and SAO.
    Client Activated objects are those remote objects whose Lifetime is directly controlled by the client. This is in direct contrast to SAO. Where the server, not the client has complete control over the lifetime of the objects.
    Client activated objects are instantiated on the server as soon as the client request the object to be created. Unlike as SAO a CAO doesn’t delay the object creation until the first method is called on the object. (In SAO the object is instantiated when the client calls the method on the object)
  15. Singleton and single call.
    Singleton
    types never have more than one instance at any one time. If an instance exists, all client requests are serviced by that instance.
    Single Call types always have one instance per client request. The next method invocation will be serviced by a different server instance, even if the previous instance has not yet been recycled by the system.
  16. What is Asynchronous Web Services?
  17. Web Client class and its methods?
  18. Flow of remoting?

Where on the Internet would you look for Web services?

UDDI.org - Universal Description, Discovery language.

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

HTTP is prefered for Soap while tcp for binary ie.

HTTP is used in web services and tcp works well in remoting.

C# Interview Questions/Answers

1. What is the CLR?
The Common Language Runtime is the platform for .NET applications that allow developing application in any .NET languages (C#, Visual Basic etc.) and have those all run seamlessly on a single platform.
2. What are the four types of applications you can build in .NET?
Console, Windows, Web, and Web Services
3. What is the .NET Framework?
//The Framework specifies how .NET constructs intrinsic types, classes, interfaces, etc.
4. What is the FCL?
The Framework Class Library provides a very large suite of predefined classes that you can use in building application.
5. What does it mean to say that C# is a "safe" language?
This refers to "type safety". The ability of the compiler to ensure that the objects created is of the expected type.
6. What is a keyword?
Keywords are reserved for use by the language and cannot be used to identify objects or methods you create.
7. What is a namespace?
Namespaces are used to ensure that identifiers are unique across libraries of classes.
8. What does the compiler do?
The job of the compiler is to turn your source code into MSIL.
9. What is MSIL?
The Microsoft Intermediate Language is the native language for .NET and is compiled into an executable application by the JIT.
10. What is the JIT?
The Just in Time compiler turns your MSIL code into an application in memory.
11. What is the difference between a project and a solution?
A project results in the production of an executable or a library. Most solutions consist of a single project, but many consist of two or more.
12. How do you move windows in the IDE?
Click and drag on the title bar; use the indicators for placement.
13. What does the pushpin do on a window?
Toggles between lock in place, and hide as a tab.
14. What is the difference between pressing F5 and Ctrl-F5 from within Visual Studio 2005?
F5 indicates run with debugging; Ctrl-F5 indicates run without debugging.
15. What is the Clipboard Ring?
Allows you to store more than one item on the clipboard
16. How do you retrieve items from the clipboard ring?
Ctrl-Shift-V cycles through all the selections.
17. What is "Find Symbol" for?
Allows you to search for symbols (namespaces, classes, and interfaces) and their members (properties, methods, events, and variables)
18. What are bookmarks?
A tool for returning to a specific place in your code
19. What is IntelliSense?
An editing tool to help you find the right method and/or the correct parameters and much more
20. What is a code snippet?
A complete outline of a commonly used programming structure with replaceable items to speed development
21. What values can a bool type have?
True or False
22. What is the difference between an int and an Int32?
Int is the C# alias for the .NET Int32 type. They can be used interchangeably.
23. Which of the following code statements will compile?
int myInt = 25;
long myLong = myInt;
int newInt = myLong;

All except the last, this requires an explicit cast:
int newInt = (int) myLong;
24. What is the difference between an int and a uint?
A uint is an unsigned int and can hold only positive numbers, but it can hold a positive value twice as big as an int (4 million+ rather than 2 million+).

25. What is the difference between a float and a double?
A float takes four bytes and double takes eight bytes, and thus a double can represent much larger values with greater precision.
26. Explain definite assignment.
In C, if you wish to use a variable of any type (pass it as a parameter to a method), you must assign it a value.
27. Given the following declaration, how would you refer to the constant for LightJacketWeather and what would its value be?
Enum Temperatures
{
WickedCold = 0, FreezingPoint = 32, LightJacketWeather, SwimmingWeather = 72, BoilingPoint = 212,
}
You refer to the constant like this:
Temperatures.LightJacketWeather

Its value is 33.
28. What is an expression?
Any statement that evaluates to a value
29. What is the output of these operations?
4 * 8
(4 + 8) / (4 - 2)
4 + 8 / 4 – 2
The output of the operations is:
32
6
4
30. Set x = 25 and y = 5. What do these expressions evaluate to?
1. (x “= y) 2. (x “= y * 5) 3. (X == y) 4. (x = y) 5.(x “= y) && (y “= x)
The expressions evaluate to: 1) True 2) True 3) False 4) 5 5.)True
The fourth expression evaluates to 5, not to true. Thus, if you write: z = x = y; and y has the value 5, then the order of operations is that the value in y (5) is assigned to x, and the value of the expression x=y, which is 5, is assigned to z.
31. Describe the difference between the prefix and postfix operators.
The prefix operator increments the original value, and then assigns the new value to the result. The postfix operator assigns the original value to the result and then increments the original value.
32. Arrange these operators in order of precedence:
&
!=
?:
&&
++
The correct order of operations is:
++
%
!=
&&
?:
33. What statements are generally used for conditional branching?
If, else, switch.
34. True or false: an if statement's condition must evaluate to an expression.
False. In C#, an if statement's condition must evaluate to a Boolean expression
34. Why should you use braces when there is only one statement following the if?
The braces make maintenance easier. If you add a second statement later, you are less likely to create a logic error because it is obvious what "block" of statements the if refers to.
35. What kind of expression can be placed in a switch statement?
Either a numeric value or a string
36. True or false: you can never fall through in a switch statement.
False. If the statement has no body, then you can fall through. For example:
Case morning:
Case afternoon:
SomeAction ( );
Break;
37. Name two uses of goto.
Two uses of goto are:
• To go to a label in your code
• To go to a different case statement in a switch statement
38. What is the difference between while and do...while?
Do...while evaluates its condition at the end of the statement rather than at the beginning, and thus is guaranteed to run at least once.

39. What does the keyword continue do?
In a loop, it causes the remainder of the body of the loop to be skipped and the next iteration of the loop to begin immediately.
40. What are two ways to create a loop that never ends until you hit a break statement?
Two ways of creating an infinite loop are:
For (;;)
While (true)
41. How do you create a user-defined type in C#?
New (user-defined) types are most often created in C# with the keyword class.
42. What is the difference between a class and an object?
A class defines a new type; an object is an instance of that type.
43. Why should member fields be private?
Making your member fields private allows you to change how you store that data (as a member variable, in a database) without breaking your client's code.
44. What is encapsulation?
Encapsulation is the principle of keeping each class discreet and self-contained, so you can change the implementation of one class without affecting any other class.
45. What is specialization and how is it implemented in C#?
Specialization allows a new class to "inherit" many of the characteristics of an existing class, and to be used polymorphically with that class. Specialization is implemented in C# through inheritance.
46. What is polymorphism?
Polymorphism is the ability to treat derived classes as if they were all instances of their base class, yet have each derived class specialize its own implementation of the base class's methods.
47. What is the difference between is-a and has-a relationship?
The is-a relationship is established through inheritance. The has-a relationship is implemented through aggregation (making one type a member variable of another type).
48. What are access modifiers?
Access modifiers indicate which class' methods have access to a given field, property or method of a class. Public members are available to methods of any class; private members are available only to methods of instances of the same class.
49. Describe the differences between state, capabilities, and responsibilities
State is the current conditions and values of an object, and is implemented with properties and member variables. Capabilities are what the object can do, exposed through public methods. Responsibilities are the promises a well-designed class makes to the clients of that class.
50. What is a use-case scenario?
A use-case scenario is a tool for the analysis of a problem. In a use-case scenario, you walk through the details of how your product will be used by one user to accomplish one task, noting which classes interact and what their responsibilities are.
51. What is the difference between a class and an object?
A class defines a new type; an object is a single instance of that type.

52. Where is reference types created?
Instances of classes are reference types and are created on the heap.
53. Where is value types created?
Intrinsic types (such as integers) and structs are value types and are created on the stack.
54. What does the keyword private do?
Access is limited to methods of the defining class.
55. What does the keyword public do?
Access is available to methods in any class.
56. What method is called when you create an object?
The class's constructor is called.
57. What is a default constructor?
A default constructor is a constructor that takes no parameters. If you do not create any constructor at all for your class, a default constructor is implicitly created.
58. What types can a constructor return?
None. A constructor is not defined to return a type, and is not marked void.
59. How do you initialize the value of a member variable in a class?
Either in the constructor, using assignment, or when the member variable is created:
Private Int myVariable = 88;
Technically, only the latter is truly initialization; assigning it in the constructor is not as efficient.
60. What does the keyword this refers to?

This refers to the object itself, the current instance of the class.
61. What is the difference between a static method and an instance method?
A static method has no this reference. It does not belong to an instance; it belongs to the class and can only call other static methods. You access a static method through the name of the class:
Dog myDog = new Dog ( );
myDog.InstanceMethod ( );
Dog.StaticMethod ( );
Of course, from within any method (including static methods), you can instantiate a class, and then call methods on that instance.
You can even instantiate an instance of your own class, and then call any non-static method of that object, as we did with [static] Main( ) calling [non-static] Test( ).
62. What does the using statement do?
The using statement automatically calls the dispose method on the object once the statement completes.
63. What is method overloading and how must the overloaded methods differ?
Method overloading allows the author of the class to create a method with varying (number and/or type of) parameters, rather than having to have many methods with similar but different names.
64. What is the signature of a method?
The signature of a method is its name and its parameter list.
65. What are properties?
Properties are public accessors to your encapsulated data. Properties appear to the class creator as methods, but to the class's clients as fields.
66. How do you create a read-only property?
Do not implement the set part of the property. No special notation is required.
67. How do you retrieve more than one return value from a method?
By passing in parameters by reference and getting the results back in those parameters.
68. Where must you use the keyword ref?
If you want to pass a value object (variable) by reference, you can use the keyword ref in the call to the method and in the declaration of the method.
69. What is the keyword out used for?
If you want to pass a value object by reference, but do not want to initialize it, you must use the keyword out in the call to the method and in the declaration of the method.
70. What is the easiest way to set a breakpoint?
Go to the line where you want execution to stop, and click in the margin. A red dot will appear on the line.
71. How do you step over or into a method?
Pressing F10 steps over a method; F11 steps into the method.
72. How can you disable breakpoints, and set conditions on breakpoints?
Right-click on the line and choose breakpoints and then disable breakpoint, or right-click on the breakpoint and choose disable.
73. What is the difference between the Locals window and the Autos window?
The Locals window shows all the variables that are in scope. The Autos window shows variables used in the current and previous statement.
74. What is the easiest way to set a watch on a variable?
Either right-click on the variable and choose "Add to Watch window" or just click and drag the variable directly onto the Watch window.
75. How do you open a QuickWatch window?
Right-click on the variable and choose "QuickWatch," or select Debug QuickWatch.
76. What does the call stack show and why is it useful?
The call stack shows which method called the current method, and which method called that method, etc. This allows you to determine the exact path your code followed to bring you to the current method.

77. What is the index of the seventh member of an array?
6. Arrays always begin with index (or offset) zero.
78. Are arrays type-safe?
Yes. Every array declares the type of objects it will hold. You can undermine the type-safety by creating an array of objects (which will hold anything, because everything derives from objects), but that is not advised.
79. Are arrays reference or value types? And where are they created?
Arrays are reference types and created on the heap.
80. Where are the elements of the array created?
If the elements of the array are of value types, they are created in the allocated memory for the array; otherwise, they are created elsewhere on the heap and a reference is stored in the array.
81. What are the two ways to initialize an array of three values?
You can explicitly call new or just imply the size of the array. For example, if you have three employee objects named Moe, Larry, and Corley:
Employee [] myEmpArray = new Employee [3] = {Moe, Larry, Corley};
Or: Employee [] myEmpArray = {Moe, Larry, Corley};
82. What does the params keyword do?
Allows you to pass in an indefinite number of parameters, all of the same type, which will be treated as an array. You can, if you wish, also pass in an array.
83. What are the two types of multidimensional arrays and what is the difference between them?
A rectangular array is a multidimensional array; a jagged array is an array of arrays.

84. What is the relationship between specialization and generalization?
This relationship is reciprocal: if you have three types with similar functionality, you can refactor that similarity out of the three types into a generalized type. At the same time, each of the three types are now specialized forms of the more generalized type.
Inheritance is also implicitly hierarchical: you can imagine a tree with the most generalized type at the top and each level of specialization descending from levels above. A generalized type may have many specializations, but each specialized type may have only one generalization.
85. How is specialization implemented in C#?
Through inheritance
86. What is the syntax for inheritance in C#?
Class “identifier” : “base class”
87. How do you implement polymorphism?
Create a virtual method in the base class, and then override it in the derived class.
88. What are the two meanings of the keyword new?
The more usual meaning is to allocate memory on the heap. The special meaning in inheritance is that you are not overriding a base method; you are creating a new method that intentionally hides and replaces the base class method.
89. How do you call a base class constructor from a derived class?
After the parameter list, but before the opening brace, put a colon followed by the keyword base and two parentheses. Pass the parameters for the base class constructor within the parentheses.
90. What is the difference between public, protected, and private?
A member of class A is visible to class B if it is marked public or if it is marked protected and class B derives directly or indirectly from A. If the member is marked private in A, it is always invisible to class B.

91. What is an abstract method?
An abstract method has no implementation in the base class, but must be overridden and implemented in any derived class that does not itself want to be abstract. Any class with an abstract method (even if inherited) is itself abstract and may not be instantiated.
92. What is a sealed class?
A sealed class is one that the compiler will not let you derive from. Classes are marked sealed when the designer of the class does not want anyone to create a derived version.
93. What is the base class of Int32?
Object (which is the ultimate base class (root) of all types in C#)
94. What is the base class of any class you create if you do not otherwise indicate a base class?
Object.
95. What is boxing?
If you use a value type where an Object is expected, the value type will be automatically and invisibly wrapped in an Object and will take on reference characteristics.
96. What is unboxing?
When you return a boxed type back to its original type, you must unbox it and explicitly cast it.
97. What is operator overloading?
The process of writing methods for your class that allows clients of your class to interact with your class using standard operators (+, ==).
98. Are operators implemented as properties, static methods, or instance methods?
Static methods

99. How does the compiler translate?
Fraction f3 = f2 + f1;
Assuming that f2 and f1 are Fraction objects and you have overloaded the + operator for the Fraction class?
Call to: public static Fraction operator+ (f2, f1)
100. What should you also do if you overload the == operator?
Overload the Equals ( ) method.
101. What is the difference between implicit and explicit conversion?
Use implicit conversion when you know the conversion will succeed without the risk of losing information. Use explicit conversion if information might be lost.
102. What is the difference between an interface and a class that implements an interface?
The interface defines the methods, properties, etc. that the implementing class must provide. The implementing class provides these members and, optionally, additional members.
103. What is the difference between an interface and an abstract base class?
Every class has exactly one base class, but may implement zero, one, or more interfaces. An abstract base class serves as the base to a derived class that must implement all its abstract methods or that derived class is also abstract.
104. How do you indicate that class MyClass derives from class MyBase and implements the interfaces ISuppose and IDo?
Class MyClass: MyBase, ISuppose, IDo {}
Note that the base class must come first after the colon.
105. What two operators can tell you if an object's class implements an interface?
The is and the as operator.

106. What is the difference between is and as operators?
Is returns false if the interface is not implemented; as returns null. Using the as operator can be more efficient.
107. What does it mean to "extend" an interface?
Extending an interface is very much like deriving a class. The new interface inherits all the members of the parent interface, and can also include additional methods.
108. What is the syntax for extending an interface?
ExtendedInterface: OriginalInterface
For example, read:
ILoggedCompressible: Incompressible

As "ILogged Compressible extends ICompressible"
109. What does it mean to override an interface implementation?
The class implementing a method of the interface can mark that method virtual, and the implementation of the method can be overridden in derived classes.
110. What is explicit interface implementation and why would you use it?
Explicit interface implementation identifies the member of the interface by naming the interface itself (e.g., IStorable.Write ( )). This is done to differentiate implementation methods when there might otherwise be an ambiguity, such as when implementing more than one interfaces that have methods with the same signature.
111. What is the convention for naming an indexer?
Indexers are unnamed. You use this keyword to create an indexer:
Public string this [int index]
112. What types can be used in an indexer to index a collection?
Any type can be used, although it's most common to use integers.
113. What are the preconditions for calling Sort ( ) on an array?
The elements of the array must implement IComparable.
114. What is the purpose of generics?
Generics allow you to create type-safe collections without specifying the type the collection will hold when you create the collection.
115. What is the IEnumerable”T” interface?
It allows your collection to support a foreach loop.
116. What is the principal difference between a List”T” and an array?
The size of an array is fixed when you create it. A List”T” expands dynamically when you add more elements.
117. What is the difference between a List, a Stack, a Queue, and a Dictionary?
A List is like an expandable array. A Stack is a "Last In, First Out" collection, a Queue is a "First In, First Out" collection, and a Dictionary is a collection of key/value pairs where you can retrieve the value given a key.
118. What is the difference between string and String (lower- and uppercase)?
string (lowercase) is the C# keyword that maps to the .NET Framework String class. They may be used interchangeably.
119. Some of the interfaces implemented by the string are: IComparable, ICloneable, IConvertible and IEnumerable. What do these guarantees to you as a client of the String class?
IComparable: Guarantees that strings can be sorted
ICloneable: Guarantees that you can call the Clone method on a string object and get back a new duplicate string
IConvertible: Allows strings to be converted to other types (such as integers)
IEnumerable: Guarantees that strings can be iterated over in foreach loops
120. What is a string literal?
A quoted string, provided by the programmer, such as "Hello"
121. What is the purpose of escape characters? Give two examples.
An escape character embedded in a string indicates that the character or punctuation that follows is to be treated as an instruction rather than as part of the string. \n indicates a new line. \" indicates that the quote symbol is in the string, not terminating it.
122. What are verbatim strings?
Verbatim strings are taken "as is" and thus do not require escape characters. Where \\ would indicate a single backslash in a normal string, in a verbatim string, it indicates two backslashes.
123. What does it mean that strings are immutable?
Strings cannot be changed. When you appear to change a string, what actually happens is that a new string is created and the old string is destroyed by the garbage collector if it is no longer referenced.
124. What does it mean that the String class is sealed?
It is not possible to derive from the String class (or any other sealed class).
125. What are the two ways to concatenate strings?
You can call the Concat method of the String class, but it is more common to use the overloaded + operator.
126. What does Split ( ) do?
Given an array of delimiters, Split ( ) returns the substrings of the original string.
127. what is the StringBuilder class, why is it used, and how do you create a string with one?
StringBuilder objects are mutable. When the StringBuilder has the complete set of characters you want, you call ToString ( ) to get back a string object.
128. What are regular expressions?
Regular expressions constitute a language for identifying and manipulating strings using both literal and metacharacters.
129. What is an exception?
An exception is an object (derived from System.Exception) that contains information about a problematic event. The framework supports throwing exceptions to stop processing and catching events to handle the problem and resume processing.
130. What does the framework do if no exception handler is found in the method that throws an event?
The stack is unwound until a handler is found, or else the exception is handled by the CLR, which terminates the program.
131. How do you create a handler?
You create a try/catch block; the catch part is the exception handler.
132. What is the syntax for throwing a new ArgumentNull exception?
The syntax is:
Throw new Sytem.ArgumentNullException ( )
133. How do you write code to handle various exceptions differently?
You can write multiple exception handlers to handle different exceptions; the first handler that catches the thrown exception will prevent further handling. Beware of inheritance complications in the ordering of your handlers.
134. What is the finally statement?
If you have code that must run whether or not an exception is thrown (to close a file, for example), place that code in the finally block. You must have a try for the finally, but a catch is optional.
135. Define an event to signal that the phone has rung.
The following is the standard way to define a delegate:
Public delegate void PhoneRangHandler
(Object sender, EventArgs e);
Public event PhoneRangHandler PhoneRang;
136. Are delegates value types or reference types?
Reference types
137. What is the purpose of a delegate?
To decouple the method(s) called from the calling code. It allows the designer of an object to define the delegate, and the user of the object to define which method will be called when the delegate is invoked.
138. How do you instantiate a delegate, such as the OnPhoneRings delegate described in the first question?
You instantiate a delegate like this:
OnPhoneRings myDelegate = new OnPhoneRings (myMethod);
139. Give an example of how you might call the delegated method through the delegate.
Here is how to call a delegated method:
OnPhoneRings (object this, new EventArgs ( ));
140. What is multicasting?
The ability for more than one method to be called through a single delegate
141. What does the event keyword do?
Limits the use of the delegate in the following ways:
• You can only add a method using +=.
• You can only remove a method using -=.
• The delegate can only be invoked by the class that defines it.
142. If you want to pass information into the method that is called through the event, how do you do so?
Define the delegate to take, as its second parameter, an object of a type derived from EventArgs. Pass the information through properties of that object.
143. What properties or methods does System.EventArgs have?
None
144. How can you create delegated methods anonymously?
Rather than creating a method that matches the delegate's signature and then assigning the name of that method to the delegate, you can directly assign an unnamed delegate method by providing the implementation in line with the assignment.
145. How can you set the properties of a control?
Click on the control on the form, and then set the properties in the Properties window.
146. How do you make a button respond to being clicked?
Implement an event handler.
147. Name two ways to create an event handler.
The two ways to create an event handler are as follows:
• Go to the Properties window, click on the lightning button to open the events, then fill in a name or double-click next to the event to let Visual Studio 2005 create the name.
• Double-click on the control to create the default handler with a name provided by Visual Studio 2005.
148. What is recursion?
A method calling itself (such as calling Method A ( ) from within the body of Method A ( ))

149. What are the XML documentation comments?
XML documentation comments are preceded with three slashes, and are used to generate XML documents that can be used to document the application.
150. How do you see the code created by Visual Studio 2005 to create and initialize the controls on the form?
Click the ShowAllFiles button on the Solution Explorer and examine the “FormName”.Designer file.
151. What are the two most significant and commonly used namespaces for ASP.NET?
System.Web and System.Web.UI.Page
152. Where does ASP.NET code run?
On the server (though occasionally some Web Controls will write script to run on the client)
153. How do you ensure that a radio button selection or checkbox selection will be immediately posted to the server?
Making a non-postback event into a postback event is accomplished simply by setting the AutoPostBack property to true.
154. What is view state?
View state is the ability of ASP.NET pages to store the state of their controls during a post-back; the net effect is that the programmer does not have to write code to maintain the state of controls when a page is posted back to the server.
155. If you rename your class, all references to the class name will be updated, except that you will be warned that the reference in "markup" will not be changed. What does this mean?
You must update the Page directive to ensure that the Inherits property is set to the new class name.
156. If you click F5 to run your program, you may see a dialog box saying that debugging is not enabled. What should you do?
Click "Add a new web.config file with debugging enabled," and Visual Studio 2005 will create a web.config file for you, or alternatively, you can create the file yourself (by hand) and then add it to the project.

157. What are the three ways to add Server Controls to your form?
The three ways are as follows:
• Drag them from the toolbox.
• Write the code in the HTML markup window.
• Add them programmatically.
158. What property must every Server Control have?
Every Server Control must have this property:
Runat="Server"
159. Which control is used to enable data binding from a database to controls on a Web Form?
The DataSource control
160. When you create an “ASP: RadioButtonList” with “ASP: RadioButtonList” controls in it, what is sent to the browser?
A series of “input” elements of type "radio" with associated “label” controls all contained within a “table”.
161. How do you ensure that an action you want to take happens only the first time the page is shown, and does not happen if the user clicks a button or takes another action to post the page back to the server for processing?
Test for the IsPostBack property of the page. If true, the page has been posted back.

1) How to prevent a class from being inherited/ sub classed?

Use "Sealed"

2) Is it possible to create a private constructor in C#?

Yes,but no useful

3) Can you declare an override method to be static if the original method is not static?

No

5) Can you mark a method as protected in an interface

No,its default value is Public.

6) Will the finally block get executed if an exception has not occurred?

Yes.

(Note:Due to problem of tag,In some places I replaced open tag by " and close tag by ")

ASP

What is ASP (Active Server Pages)?
ASP is a server side-scripting environment for building dynamic and interactive web pages. Since the scripts run on the server side, the web server does all the processing.

What is an .ASP file?
It is a Text File that contains the combination of the following:
• Text
• HTML tags
• Script Commands

What is the difference between ASP and HTML? Or Why ASP is better than HTML?
• ASP executes code on the server side whereas the browser interprets HTML.
• ASP can use any scripting languages
• Gets feedback from the user and return information to the user
• Create pages that will be customized to display only things that will be of interest to a particular user
• Can edit contents of a web page by updating a text file or a database rather than the HTML code itself

What are the differences between ASP and ASP.NET and is ASP.NET backward compatible to ASP.
ASP page is non compiled version ie the ASP compiler (interpreter) executes each line of ASP page when the request for a particular page is made...
Where as ASP.NET page is the pre-compiled version. When we compile the ASP.NET page, the .NET compiler compiles the ASP.NET page to the UI assemply.

How can you change the primary scripting language for a page?
Specify <%@ LANGUAGE = Scripting language %>
How are scripts executed?
ASP provides scripting engines that execute the corresponding scripting languages on the server side. Scripts should be encoded within the <%…. %>Delimiters.

What are the advantages of using ASP?
• Minimizes network traffic by limiting the need for the browser and server to talk to each other
• Makes for quicker loading time since HTML pages are only downloaded
• Allows to run programs in languages that are not supported by the browser
• Can provide the client with data that does not reside on the client’s machine
• Provides improved security measures since the script cannot be viewed by the browser

What is a "Virtual Directory"?
Virtual directories are aliases for directory paths on the server. It allows moving files on the disk between different
folders, drives or even servers without changing the structure of web pages. It avoids typing an extremely long URL each time to access an ASP page.

What are the browsers that can access ASP pages?
• Internet Explorer (supports VBScript, JavaScript)
• Netscape Communicator/ Navigator (supports only JavaScript, VBScript can be also added too)

How does the server identify and execute the server-side scripts within HTML code?
• Including the RUNAT=SERVER attribute in the
tag
• Use <% … %>server script delimiter

What is the difference between Cookies collection and Form/Querystring collection?
Cookie collection does not have the Count property.
Cookies can have multiple values for the same cookie name but each value can be referred using a key whereas in a Form/Querystring cookie each value has to be referred using an index value.


What is ServerVariables collection?
The ServerVariables collection holds the entire HTTP headers and also additional items of information about the server.

What are the collections of Session Object?
• Contents collection – contains all the variables established for a session without using thetag.
• Static collection – contains all the objects created with thetag within session scope.

What are the collections of Application Object?
* Contents collection – contains all variables added via scripts in global.asa.
* Static collection – contains the names of all objects added via thetag in global.asa.

What are the attributes of the
tags? What are their functions?
The two attributes are ACTION and METHOD
The ACTION gives the name of the ASP file that should be opened next by which this file can access the information given in the form
The METHOD determines which of the two ways (POST or GET) the browser can send the information to the server.

What is ServerVariables collection?
The ServerVariables collection holds the entire HTTP headers and also additional items of information about the server.

What is Querystring collection?
This collection stores any values that are provided in the URL. This can be generated by three methods:
• By clicking on an anchor tag

• By sending a form to the Server by the GET method
• Through user-typed HTTP address

What is ClientCertificate collection?
A ClientCertificate is an encrypted number that is stored in a file on the user’s computer. This stores details of any security certificates included with the request.

What is Request Object?
Gets information from the user. It has five collections by which values can be accessed. They are: Querystring, Form, Cookies, Server Variables & ClientCertificate.

What is a FileSystemObject object?
It provides access to the physical file system of the web server. It gets and manipulates information about
all drives in a server, folders and sub-folders on a drive and files inside a folder.

What are the properties of Session Object?
• SessionID – returns the session identification number for each user.
• Timeout – sets the timeout period assigned to the Session object for any application, in minutes.
• CodePage – determines the code page that will be used to display content.
• LCID – a locale identifier, which determines time zone and language, rules for the system.

Explain the POST & GET Method or Explain the difference between them.
POST METHOD:
The POST method generates a FORM collection, which is sent as a HTTP request body. All the values typed in
the form will be stored in the FORM collection.
GET METHOD:
The GET method sends information by appending it to the URL (with a question mark) and stored as A Querystring collection. The Querystring collection is passed to the server as name/value pair.
The length of the URL should be less than 255 characters.

What are the methods by which output stream is controlled?
• Flush – sends previous buffered output to the client immediately, but continues processing the script.
• Clear – erases any already-buffered HTML.
• End – causes the server

What are the properties used to control the expiration of the page?

• Expires – specifies the number of minutes before a page cached on a browser expires.
• ExpiresAbsolute – sets the date and time at which a page cached on a browser expires.

What are the ASP Scripting Objects?
The Dictionary object, the FileSystemObject object, TextStream object.

What is the difference between server.trasfer, server.execute and Response.redirect?
Is Response.trasfer is valid in ASP.
server.execute stops the execution of the current page and transfers the control to the URL passed in as a parameter. After that page has finished execution control passes back to the original page and execution resumes at the statement after the execute method call.

server.transfer is similar to server.execute but unlike that methos the execution does not resume to the original page but end when the new page completes executing

response.redirect transfers the control to the given url but there is server round trip.
In response.redirect the new url can be seen , but in server.execute and transfer the new page url is not seen even though the control is passed to the new page.

Performance is better in server.execute and transfer nut they cannot be used with server-side include #exec directive.

What is the function of Buffer in Response Object?
Buffer controls the HTML output stream manually.
Respose.buffer=False/True
Buffer is used to send the information to the browser.

How to Retrieve a Cookie Value?
The "Request.Cookies" command is used to retrieve a cookie value. <% fname=Request.Cookies("firstname") response.write("Firstname=" & fname) %>

When does a Session Start?
A session starts when:
• A new user requests an ASP file, and the Global.asa file includes a Session_OnStart procedure
• A value is stored in a Session variable
• A user requests an ASP file, and the Global.asa file uses thetag to instantiate an object with session scope

When does a Session End?
A session ends if a user has not requested or refreshed a page in the application for a specified period. By default, this is 20 minutes.
If you want to set a timeout interval that is shorter or longer than the default, you can set the Timeout property.

What happens to ASP pages?
The browser makes a HTTP request; the server does the processing and gives a HTML response to the browser.

What are LOCAL and GLOBAL variables?
Local variables lifetime ends when the Procedure ends. Global variables lifetime begins at the start of the
script and ends at the end of the script and it can be used by any procedure within the script. Declaring a
variable by using the keyword PRIVATE makes the variable global within the script, but if declared using PUBLIC, then all scripts can refer the variable.

How to handle Error in ASP ?
Using On Error Goto.

Can two different applications use the same GLOBAL.ASA File?
No,each application can have their own Global.asa file but it can't be shared.

What is the Default ScriptTimeOut for Server Object?
The ScriptTimeout property specifies the amount of runtime in seconds for a script before it terminates. The default value is 90 seconds.

What is the difference between Server-side validation and Client-side validation?
1. Client-side is faster than server-side as the networking time from client to server is saved
2. server-side is done on the server. Then the server converts the data into an html page and sends to the browser.
3. server-side is more secure as the user cannot see the code even he does a view-source.

What is a Dictionary object?
It lets you store and retrieve information in a flexible data structure. Each value or information stored in a Dictionary is associated with a key through which the information can be retrieved.

What purpose is served by the Application.Lock method?
It locks the Application object, preventing other clients from altering any values in the Contents collection.

Which is the default Scripting Language on the client side?
JavaScript.

What is Extranet?
An area of a web site available only to a set of registered visitors.

Which is the default Scripting Language of ASP on the Server side?
VBScript.