Technical interview questions and answers are critical when preparing for an AJAX Interview because companies want to evaluate your understanding of asynchronous communication, XMLHttpRequest, JSON handling, DOM manipulation, and interactive web applications. AJAX is considered a core concept in modern web development, and many companies include it as part of their technical rounds for frontend and full-stack developer roles. Organizations like TCS, Infosys, Wipro, Cognizant, and Capgemini frequently ask AJAX-related questions to check whether candidates can build dynamic, responsive, and efficient web pages. This guide includes commonly asked AJAX interview questions with clear explanations to help freshers and job seekers strengthen their web development fundamentals. These questions will improve your preparation for placement interviews, coding rounds, and real-time project discussions.
1. When should AJAX NOT be used?
Answer: It would not be appropriate to use AJAX when the answer/result? can be determinded by the client. Generally, the purpose of AJAX is to submit a short request to the server,and process the response in such a way as to add value to the currently displayed page.It would also not be appropriate to use AJAX when the magnitude of the response is such that it would be easier, and more clear to redisplay the page.
Show Answer
Hide Answer
2. How do you know that an AJAX request has completed?
Answer: The XHR.readyState is 4 and the XHR.status is 200 (or zero if the request is to a local file). The callback function is called four times first with status=1, then 2,3, and finally 4.
Show Answer
Hide Answer
3. How does XML processing differ on the different browsers?
Answer: Its an ActiveX object on IE, but is native on the other browsers
Show Answer
Hide Answer
4. Is it possible to achieve similar results without the XmlHttpRequest object?
Answer: A hidden IFrame (actually an IFrame of size 0px * 0px due to a bug in IE) can be used to retrieve data, and its contents can then be processed in a similar manner to the response from an XHR call.
Show Answer
Hide Answer
6. What is AJAX?
Answer: In one sense, AJAX is simply an acronym for “Asynchronous JavaScript And XML” In another, it is a protocol for sending requests from a client (web page) to a server,and how the information is / should be communicated between the client and the server
Show Answer
Hide Answer
8. Why can/should AJAX be used?
Answer: AJAX is best suited for small (hopefully unobtrusive) updates to the current web page, based on information that is not available until it has been provided by the end user.
Show Answer
Hide Answer
9. Describe some things that cant be done with AJAX
Answer: Sending a request to a server outside of the domain from which the web page originated.
Show Answer
Hide Answer
10. How should AJAX objects be created?
Answer: In a browser general manner, if at all possible.
Show Answer
Hide Answer
11. For what error conditions should programs check?
Answer: The connection can not be established
The request does not complete in a timely fashion
Unexpected response
Show Answer
Hide Answer
12. Do Ajax applications always deliver a better experience than traditional web applications?
Answer: 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.
Show Answer
Hide Answer
13. What is the difference between proxied and proxyless calls?
Answer: 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().
Show Answer
Hide Answer
14. Are there any frameworks available to help speedup development with AJAX?
Answer: There are several browser-side frameworks available, each with their own uniqueness...
Show Answer
Hide Answer
15. Is Adaptive Path selling Ajax components or trademarking the name? Where can I download it?
Answer: Ajax isnt something you can download. Its 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.
Show Answer
Hide Answer
16. Should I use an HTTP GET or POST for my AJAX calls?
Answer: 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.
Show Answer
Hide Answer
17. Some of the Google examples you cite dont use XML at all. Do I have to use XML and/or XSLT in an Ajax application?
Answer: No. XML is the most fully-developed means of getting data in and out of an Ajax client, but theres no reason you couldnt accomplish the same effects using a technology like JavaScript Object Notation or any similar means of structuring data for interchange.
Show Answer
Hide Answer
18. Are Ajax applications easier to develop than traditional web applications?
Answer: 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.
Show Answer
Hide Answer
19. When do I use a synchronous versus a asynchronous request?
Answer: Good question. They don't call it AJAX for nothing! A synchronous request would block in page event processing and I don't see many use cases where a synchronous request is preferable.
Show Answer
Hide Answer
20. How do I test my AJAX code?
Answer: There is a port of JUnit for client-side JavaScript called JsUnit
Show Answer
Hide Answer
21. What exactly is the W3C DOM?
Answer: 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...
Show Answer
Hide Answer
22. When will HTML_AJAX have a stable release?
Answer: Once all the major features are complete and the API has been tested, the roadmap gives an idea of whats left to be done.
Show Answer
Hide Answer
23. What parts of the HTML_AJAX API are stable?
Answer: 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.
Show Answer
Hide Answer
24. What kinds of applications is Ajax best suited for?
Answer: We dont 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.
Show Answer
Hide Answer
25. Does this mean Adaptive Path is anti-Flash?
Answer: Not at all. Macromedia is an Adaptive Path client, and we have 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. Were also interested in exploring ways the technologies can be mixed (as in the case of Flickr, which uses both).
Show Answer
Hide Answer
26. Where can I find examples of AJAX?
Answer: 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...
Show Answer
Hide Answer
27. What is the XMLHttpRequest object?
Answer: It offers a non-blocking way for JavaScript to communicate back to the web server to update only part of the web page.
Show Answer
Hide Answer
28. Does Java have support for Comet style server-side push?
Answer: 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 bein
Show Answer
Hide Answer
30. Is it possible to have different access modifiers on the get/set methods of a property?
Answer: No. The access modifier on a property applies to both its get and set accessors. What you need to do if you want them to be different is make The property read-only (by only providing a get accessor) and create a private/internal set method that is separate from The property.
Show Answer
Hide Answer
31. Is it possible to have a static indexer in C#? allowed in C#.
Answer: No. Static indexers are not
Show Answer
Hide Answer
32. I was trying to use an out int parameter in one of my functions. How should I declare the variable that I am passing to it?
Answer: You should declare the variable as an int, but when you pass it in you must specify it as ‘out, like the following: int i; foo(out i); where foo is declared as follows:
[return-type] foo(out int o) { }
Show Answer
Hide Answer
33. How do I simulate optional parameters to COM calls?
Answer: You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.
Show Answer
Hide Answer
34. What do you know about .NET assemblies?
Answer: Assemblies are the smallest units of versioning and deployment in the .NET application. Assemblies are also the building blocks for programs such as Web services, Windows services, serviced components, and .NET remoting applications.
Show Answer
Hide Answer
35. Whats the difference between private and shared assembly?
Answer: Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.
Show Answer
Hide Answer
36. Whats a strong name?
Answer: A strong name includes the name of the assembly, version number, culture identity, and a public key token.
Show Answer
Hide Answer
37. How can you debug failed assembly binds?
Answer: Use the Assembly Binding Log Viewer (fuslogvw.exe) to find out the paths searched.
Show Answer
Hide Answer
39. How can you create a strong name for a .NET assembly?
Answer: With the help of Strong Name tool (sn.exe).
Show Answer
Hide Answer
40. Wheres global assembly cache located on the system?
Answer: Usually C:\winnt\assembly or C:\windows\assembly.
Show Answer
Hide Answer
41. Can you have two files with the same file name in GAC?
Answer: Yes, remember that GAC is a very special folder, and while normally you would not be able to place two files with the same name into a Windows folder, GAC differentiates by version number as well, so its possible for MyApp.dll and MyApp.dll to co-exist in GAC if the first one is version 1.0.0.0 and the second one is 1.1.0.0.
Show Answer
Hide Answer
42. Is there an equivalent of exit() for quitting a C# .NET application?
Answer: Yes, you can use System.Environment.Exit(int exitCode) to exit the application or Application.Exit() if it's a Windows Forms app.
Show Answer
Hide Answer
43. What is delay signing?
Answer: Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development.
Show Answer
Hide Answer
44. Can you prevent your class from being inherited and becoming a base class for some other classes?
Answer: Yes, that is what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It is the same concept as final class in Java.
Show Answer
Hide Answer
46. If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?
Answer: Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.
Show Answer
Hide Answer
47. I was trying to use an "out int" parameter in one of my functions. How should I declare the variable that I am passing to it?
Answer: You should declare the variable as an int, but when you pass it in you must specify it as 'out', like the following:
int i;
foo(out i);
where foo is declared as follows:
[return-type] foo(out int o) { }
Show Answer
Hide Answer
48. How do you specify a custom attribute for the entire assembly (rather than for a class)?
Answer: Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows:
using System;
[assembly : MyAttributeClass] class X {}
Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.
Show Answer
Hide Answer
49. How can you tell the application to look for assemblies at the locations other than its own install?
Answer: Use the directive in the XML .config file for a given application.
< probing privatePath=c:\mylibs; bin\debug />
should do the trick. Or you can add additional search paths in the Properties box of the deployed application.
Show Answer
Hide Answer
50. So lets say I have an application that uses MyApp.dll assembly, version 1.0.0.0. There is a security bug in that assembly, and I publish the patch, issuing it under name MyApp.dll 1.1.0.0. How do I tell the client applications that are already installed to start using this new MyApp.dll?
Answer: Use publisher policy. To configure a publisher policy, use the publisher policy configuration file, which uses a format similar app .config file. But unlike the app .config file, a publisher policy file needs to be compiled into an assembly and placed in the GAC.
Show Answer
Hide Answer
51. How do I make a DLL in C#?
Answer: You need to use the /target:library compiler option.
Show Answer
Hide Answer
53. Is there regular expression (regex) support available to C# developers?
Answer: Yes. The .NET class libraries provide support for regular expressions. Look at the documentation for the System.Text.RegularExpressions namespace.
Show Answer
Hide Answer
54. Is there a way to force garbage collection?
Answer: Yes. Set all references to null and then call System.GC.Collect(). If you need to have some objects destructed, and System.GC.Collect() doesn't seem to be doing it for you, you can force finalizers to be run by setting all the references to the object to null and then calling System.GC.RunFinalizers().
Show Answer
Hide Answer
55. What connections does Microsoft SQL Server support?
Answer: Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords)
Show Answer
Hide Answer
56. What is a satellite assembly?
Answer: When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.
Show Answer
Hide Answer
57. How is method overriding different from overloading?
Answer: When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.
Show Answer
Hide Answer
58. When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?
Answer: When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.
Show Answer
Hide Answer
59. Why would you use untrusted verification?
Answer: Web Services might use it, as well as non-Windows applications.
Show Answer
Hide Answer
60. What is the implicit name of the parameter that gets passed into the class set method?
Answer: Value, and its datatype depends on whatever variable we are changing.
Show Answer
Hide Answer
61. How do I register my code for use by classic COM clients?
Answer: Use the regasm.exe utility to generate a type library (if needed) and the necessary entries in the Windows Registry to make a class available to classic COM clients. Once a class is registered in the Windows Registry with regasm.exe, a COM client can use the class as though it were a COM class.
Show Answer
Hide Answer
62. How do I create a multi language, multi file assembly?
Answer: Unfortunately, this is currently not supported in the IDE. To do this from the command line, you must compile your projects into netmodules (/target:module on the C# compiler), and then use the command line tool al.exe (alink) to link these netmodules together.
Show Answer
Hide Answer
63. C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?
Answer: Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there is no implementation in
Show Answer
Hide Answer
64. What is the equivalent to regsvr32 and regsvr32 /u a file in .NET development?
Answer: Try using RegAsm.exe. The general syntax would be: RegAsm. A good description of RegAsm and its associated switches is located in the .NET SDK docs. Just search on "Assembly Registration Tool".Explain ACID rule of thumb for transactions.
Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no in-between case where something has been updated and something hasnot), Isolated (no tran
Show Answer
Hide Answer
65. Where is the output of TextWriterTraceListener redirected?
Answer: To the Console or a text file depending on the parameter passed to the constructor.
Show Answer
Hide Answer
66. How do I create a multilanguage, single-file assembly?
Answer: This is currently not supported by Visual Studio .NET.
Show Answer
Hide Answer
67. Why cannot you specify the accessibility modifier for methods inside the interface?
Answer: They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it is public by default.
Show Answer
Hide Answer
68. Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace?
Answer: There is no way to restrict to a namespace. Namespaces are never units of protection. But if you're using assemblies, you can use the 'internal' access modifier to restrict access to only within the assembly.
Show Answer
Hide Answer
69. Why do I get a syntax error when trying to declare a variable called checked?
Answer: The word checked is a keyword in C#.
Show Answer
Hide Answer
70. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
Answer: The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.
Show Answer
Hide Answer
71. What does the keyword virtual mean in the method definition?
Answer: The method can be over-ridden.
Show Answer
Hide Answer
72. What is the difference between the System.Array.CopyTo() and System.Array.Clone()?
Answer: The first one performs a deep copy of the array, the second one is shallow.
Show Answer
Hide Answer
73. What is the difference between const and static read-only?
Answer: The difference is that static read-only can be modified by the containing class, but const can never be modified and must be initialized to a compile time constant. To expand on the static read-only case a bit, the containing class can only modify it: -- in the variable declaration (through a variable initializer).
-- in the static constructor (instance constructors if it's not static).
Show Answer
Hide Answer
74. What does the parameter Initial Catalog define inside Connection String?
Answer: The database name to connect to.
Show Answer
Hide Answer
75. What is the difference between System.String and System.StringBuilder classes?
Answer: System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
Show Answer
Hide Answer
76. What is the top .NET class that everything is derived from?
Answer: System.Object.
Show Answer
Hide Answer
77. Can you allow class to be inherited, but prevent the method from being over-ridden?
Answer: Yes, just leave the class public and make the method sealed
Show Answer
Hide Answer
78. Can you change the value of a variable while debugging a C# application?
Answer: Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.
Show Answer
Hide Answer
79. Are private class-level variables inherited?
Answer: Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.
Show Answer
Hide Answer
80. Can you inherit multiple interfaces?
Answer: Yes. .NET does support multiple interfaces.
Show Answer
Hide Answer
81. From a versioning perspective, what are the drawbacks of extending an interface as opposed to extending a class?
Answer: With regard to versioning, interfaces are less flexible than classes. With a class, you can ship version 1 and then, in version 2, decide to add another method. As long as the method is not abstract (i.e., as long as you provide a default implementation of the method), any existing derived classes continue to function with no changes. Because interfaces do not support implementation inheritance, this same pattern does not hold for interfaces. Adding a method to an interface is like adding an abs
Show Answer
Hide Answer
82. Which one is trusted and which one is untrusted?
Answer: Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction
Show Answer
Hide Answer
83. What namespaces are necessary to create a localized application?
Answer: System.Globalization, System.Resources.
Show Answer
Hide Answer
84. Does Console.WriteLine() stop printing when it reaches a NULL character within a string?
Answer: Strings are not null terminated in the runtime, so embedded nulls are allowed. Console.WriteLine() and all similar methods continue until the end of the string.
Show Answer
Hide Answer
85. What is the advantage of using System.Text.StringBuilder over System.String?
Answer: StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it is being operated on, a new instance is created.
Show Answer
Hide Answer
86. What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
Answer: SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it is a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.
Show Answer
Hide Answer
87. Why do I get a security exception when I try to run my C# app?
Answer: Some security exceptions are thrown if you are working on a network share. There are some parts of the frameworks that will not run if being run off a share (roaming profile, mapped drives, etc.). To see if this is what's happening, just move the executable over to your local drive and see if it runs without the exceptions. One of the common exceptions thrown under these conditions is
System.Security.SecurityException.
To get around this, you can change your security policy for the intranet zo
Show Answer
Hide Answer
88. What is the difference between // comments, /* */ comments and /// comments?
Answer: Single-line, multi-line and XML documentation comments.
Show Answer
Hide Answer
89. How do you inherit from a class in C#?
Answer: Place a colon and then the name of the base class. Notice that it is double colon in C++.
Show Answer
Hide Answer
90. Can I define a type that is an alias of another type (like typedef in C++)?
Answer: Not exactly. You can create an alias within a single file with the "using" directive: using System; using Integer = System.Int32; // alias
But you can't create a true alias, one that extends beyond the file in which it is declared. Refer to the C# spec for more info on the 'using' statement's scope.
Show Answer
Hide Answer
91. Is it possible to have different access modifiers on the get/set methods of a property?
Answer: No. The access modifier on a property applies to both its get and set accessors. What you need to do if you want them to be different is make the property read-only (by only providing a get accessor) and create a private/internal set method that is separate from the property.
Show Answer
Hide Answer
92. Is it possible to have a static indexer in C#?
Answer: No. Static indexers are not allowed in C#.
Show Answer
Hide Answer
93. Does C# support #define for defining global constants?
Answer: No. If you want to get something that works like the following C code:
#define A 1
use the following C# code: class MyConstants
{
public const int A = 1;
}
Then you use MyConstants.A where you would otherwise use the A macro.
Using MyConstants.A has the same generated code as using the literal 1.
Show Answer
Hide Answer
94. Does C# support templates?
Answer: No. However, there are plans for C# to support a type of template known as a generic. These generic types have similar syntax but are instantiated at run time as opposed to compile time. You can read more about them here.
Show Answer
Hide Answer
95. Does C# support parameterized properties?
Answer: No. C# does, however, support the concept of an indexer from language spec. An indexer is a member that enables an object to be indexed in the same way as an array. Whereas properties enable field-like access, indexers enable array-like access. As an example, consider the Stack class presented earlier. The designer of this class may want to expose array-like access so that it is possible to inspect or alter the items on the stack without performing unnecessary Push and Pop operations. That is, S
Show Answer
Hide Answer
96. Does C# support C type macros?
Answer: No. C# does not have macros. Keep in mind that what some of the predefined C macros (for example, __LINE__ and __FILE__) give you can also be found in .NET classes like System.Diagnostics (for example, StackTrace and StackFrame), but they'll only work on debug builds.
Show Answer
Hide Answer
99. Can you declare the override method static while the original method is non-static?
Answer: No, you cannot, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override
Show Answer
Hide Answer
101. Can multiple catch blocks be executed?
Answer: No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.
Show Answer
Hide Answer
102. Can you override private virtual methods?
Answer: No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.
Show Answer
Hide Answer
103. What is a pre-requisite for connection pooling?
Answer: Multiple processes must agree that they will share the same connection, where every parameter is the same,
Show Answer
Hide Answer
104. What is the data provider name to connect to Access database?
Answer: Microsoft.Access.
Show Answer
Hide Answer
105. Why does my Windows application pop up a console window every time I run it?
Answer: Make sure that the target type set in the project properties setting is set to Windows Application, and not Console Application. If you're using the command line, compile with /target:winexe & not target:exe.
Show Answer
Hide Answer
106. What is the wildcard character in SQL?
Answer: Let us say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve La%.
Show Answer
Hide Answer
107. What is the role of the DataReader class in ADO.NET connections?
Answer: It returns a read-only dataset from the data source when the command is executed.
Show Answer
Hide Answer
108. What does the This window show in the debugger?
Answer: It points to the object that is pointed to by this reference. Objects instance data is shown.
Show Answer
Hide Answer
109. Describe the accessibility modifier protected internal?
Answer: It is available to derived classes and classes within the same Assembly (and naturally from the base class it is declared in).
Show Answer
Hide Answer
110. What is an interface class?
Answer: It is an abstract class with public abstract methods all of which must be implemented in the inherited classes.
Show Answer
Hide Answer
111. What is a multicast delegate?
Answer: It is a delegate that points to and eventually fires off several methods.
Show Answer
Hide Answer
112. What does assert() do?
Answer: In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
Show Answer
Hide Answer
113. Why do I get an error (CS1006) when trying to declare a method without specifying a return type?
Answer: If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a constructor. So if you are trying to declare a method that returns nothing, use void. The following is an example: // This results in a CS1006 error public static staticMethod (mainStatic obj) // This will work as wanted public static void staticMethod (mainStatic obj)
Show Answer
Hide Answer
114. What is the .NET datatype that allows the retrieval of data by a unique key?
Answer: HashTable.
Show Answer
Hide Answer
115. What is the difference between the Debug class and Trace class?
Answer: Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
Show Answer
Hide Answer
116. How can you overload a method?
Answer: Different parameter data types, different number of parameters, different order of parameters.
Show Answer
Hide Answer
117. What debugging tools come with the .NET SDK?
Answer: CorDBG - command-line debugger, and DbgCLR - graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.
Show Answer
Hide Answer
118. What does Dispose method do with the connection object?
Answer: Deletes it from the memory.
Show Answer
Hide Answer
119. How do you generate documentation from the C# file commented properly with a command-line compiler?
Answer: Compile it with a /doc switch.
Show Answer
Hide Answer
120. When you inherit a protected class-level variable, who is it available to?
Answer: Classes in the same namespace.
Show Answer
Hide Answer
121. How can I get the ASCII code for a character in C#?
Answer: Casting the char to an int will give you the ASCII value: char c = 'f'; System.Console.WriteLine((int)c); or for a character in a string: System.Console.WriteLine((int)s[3]); The base class libraries also offer ways to do this with the Convert class or Encoding classes if you need a particular encoding.
Show Answer
Hide Answer
122. Is there an equivalent to the instanceof operator in Visual J++?
Answer: C# has the is operator:
expr is type
Show Answer
Hide Answer
123. How do I create a Delegate/MulticastDelegate?
Answer: C# requires only a single parameter for delegates: the method address. Unlike other languages, where the programmer must specify an object reference and the method to invoke, C# can infer both pieces of information by just specifying the method's name. For example, let's use System.Threading.ThreadStart: Foo MyFoo = new Foo(); ThreadStart del = new ThreadStart(MyFoo.Baz); This means that delegates can invoke static class methods and instance methods with the exact same syntax!
Show Answer
Hide Answer
124. How can you sort the elements of the array in descending order?
Answer: By calling Sort() and then Reverse() methods.
Show Answer
Hide Answer
125. How do you debug an ASP.NET Web application?
Answer: Attach the aspnet_wp.exe process to the DbgClr debugger.
Show Answer
Hide Answer
126. How do you mark a method obsolete?
Answer: Assuming you've done a "using System;": [Obsolete]
public int Foo() {...}
or [Obsolete("This is a message describing why this method is obsolete")]
public int Foo() {...}
Note: The O in Obsolete is capitalized.
Show Answer
Hide Answer
127. How is the DLL Hell problem solved in .NET?
Answer: Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly
Show Answer
Hide Answer
128. What are the ways to deploy an assembly?
Answer: An MSI installer, a CAB archive, and XCOPY command.
Show Answer
Hide Answer
129. Why does DllImport not work for me?
Answer: All methods marked with the DllImport attribute must be marked as public static extern.
Show Answer
Hide Answer
130. What is a delegate?
Answer: A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.
Show Answer
Hide Answer
131. What is the difference between an interface and abstract class?
Answer: In the interface all methods must be abstract; in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.
Show Answer
Hide Answer
132. What is an abstract class?
Answer: A class that cannot be instantiated. A concept in C++ known as pure virtual method. A class that must be inherited and have the methods over-ridden. Essentially, it is a blueprint for a class without any implementation.
_break
Show Answer
Hide Answer
134. Who is a protected class-level variable available to?
Answer: It is available to any sub-class (a class inheriting this class).
Show Answer
Hide Answer
136. What does the term immutable mean?
Answer: The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.
Show Answer
Hide Answer
137. whats the difference between System.String and System.Text.StringBuilder classes?
Answer: System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
Show Answer
Hide Answer
138. whats the advantage of using System.Text.StringBuilder over System.String?
Answer: StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.
Show Answer
Hide Answer
139. Whats the difference between the System.Array.CopyTo() and System.Array.Clone()?
Answer: The first one performs a deep copy of the array, the second one is shallow. A shallow copy of an Array copies only the elements of the Array, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new Array point to the same objects that the references in the original Array point to. In contrast, a deep copy of an Array copies the elements and everything directly or indirectly referenced by the elements.
Show Answer
Hide Answer
140. Whats the .NET collection class that allows an element to be accessed using a unique key?
Answer: HashTable.
Show Answer
Hide Answer
142. Will the finally block get executed if an exception has not occurred?
Answer: Yes.
Show Answer
Hide Answer
143. Whats the C# syntax to catch any possible exception?
Answer: A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
Show Answer
Hide Answer
144. Can multiple catch blocks be executed for a single try statement?
Answer: No. Once the proper catch block processed, control is transferred to the finally block (if there are any).
Show Answer
Hide Answer
145. Explain the three services model commonly know as a three-tier application.
Answer: Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).
Show Answer
Hide Answer
146. What is the syntax to inherit from a class in C#?
Answer: Place a colon and then the name of the base class.
Example: class MyNewClass : MyBaseClass
Show Answer
Hide Answer
147. Can you prevent your class from being inherited by another class?
Answer: Yes. The keyword “sealed” will prevent the class from being inherited.
Show Answer
Hide Answer
148. Can you allow a class to be inherited, but prevent the method from being over-ridden?
Answer: Yes. Just leave the class public and make the method sealed.
Show Answer
Hide Answer
149. Whats an abstract class?
Answer: A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.
Show Answer
Hide Answer
150. When do you absolutely have to declare a class as abstract?
Answer: 1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
2. When at least one of the methods in the class is abstract.
Show Answer
Hide Answer
151. What is an interface class?
Answer: Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.
Show Answer
Hide Answer
152. Why cant you specify the accessibility modifier for methods inside the interface?
Answer: They all must be public, and are therefore public by default.
Show Answer
Hide Answer
153. What happens if you inherit multiple interfaces and they have conflicting method names?
Answer: Its up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares youre okay.
To Do: Investigate
Show Answer
Hide Answer
154. Whats the difference between an interface and abstract class?
Answer: In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers.
Show Answer
Hide Answer
155. What is the difference between a Struct and a Class?
Answer: Struts are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that struts cannot inherit.
Show Answer
Hide Answer
156. Whats the implicit name of the parameter that gets passed into the set method/property of a class?
Answer: Value. The data type of the value parameter is defined by whatever data type the property is declared as.
Show Answer
Hide Answer
157. What does the keyword virtual? declare for a method or property?
Answer: The method or property can be overridden.
Show Answer
Hide Answer
158. How is method overriding different from method overloading?
Answer: When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.
Show Answer
Hide Answer
159. Can you declare an override method to be static if the original method is not static?
Answer: No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override)
Show Answer
Hide Answer
160. What are the different ways a method can be overloaded?
Answer: Different parameter data types, different number of parameters, different order of parameters.
Show Answer
Hide Answer
161. If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?
Answer: Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.
Show Answer
Hide Answer
162. Whats a delegate?
Answer: A delegate object encapsulates a reference to a method.
Show Answer
Hide Answer
163. Whats a multicast delegate?
Answer: A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.
Show Answer
Hide Answer
164. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
Answer: The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.
Show Answer
Hide Answer
165. What are three test cases you should go through in unit testing?
Answer: 1. Positive test cases (correct data, correct output).
2. Negative test cases (broken or missing data, proper handling).
3. Exception test cases (exceptions are thrown and caught properly).
Show Answer
Hide Answer
166. Can you change the value of a variable while debugging a C# application?
Answer: Yes. If you are debugging via Visual Studio.NET, just go to Immediate window.
Show Answer
Hide Answer
167. What is the role of the DataReader class in ADO.NET connections?
Answer: It returns a read-only, forward-only rowset from the data source. A DataReader provides fast access when a forward-only sequential read is needed.What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix. OLE-DB.NET is a .NET layer on top of the O
Show Answer
Hide Answer
168. What is the wildcard character in SQL?
Answer: Lets say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%.
Show Answer
Hide Answer
169. What connections does Microsoft SQL Server support?
Answer: Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and password).
Show Answer
Hide Answer
170. Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted?
Answer: Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.
Show Answer
Hide Answer
171. What does the Initial Catalog parameter define in the connection string?
Answer: The database name to connect to.
Show Answer
Hide Answer
172. What does the Dispose method do with the connection object?
Answer: Deletes it from the memory.
Show Answer
Hide Answer
173. What is a pre-requisite for connection pooling?
Answer: Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings. The connection string must be identical.
Show Answer
Hide Answer
174. How is the DLL Hell problem solved in .NET?
Answer: Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.
Show Answer
Hide Answer
175. What namespaces are necessary to create a localized application?
Answer: System.Globalization and System.Resources.
Show Answer
Hide Answer
177. When should you call the garbage collector in .NET?
Answer: As a good rule, you should not call the garbage collector. However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory. However, this is usually not a good practice.
Show Answer
Hide Answer
179. ctype(123.34,integer) - should it throw an error? Why or why not?
Answer1
Answer: It would work fine. As the runtime type of 123.34 would be double, and Double can be converted to Integer.
Answer2
the ctype(123.34,integer) will work fine no errors
Show Answer
Hide Answer
180. directcast(123.34,integer) - should it throw an error? Why or why not?
Answer: It would throw an InvalidCast exception as the runtime type of 123.34 (double) doesnt match with Integer.
Show Answer
Hide Answer
181. Difference between a sub and a function.
Answer: A Sub does not return anything whereas a Function returns something.
Show Answer
Hide Answer
182. Difference between imperative and interrogative code.
Answer: There are imperative and interrogative functions. Imperative functions are the one which return a value while the interrogative functions do not return a value.
Show Answer
Hide Answer
183. Difference between value and reference type. what are value types and reference types?
Answer: Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap
Show Answer
Hide Answer
184. What are the two kinds of properties.
Answer: Two types of properties in .Net: Get and Set
Show Answer
Hide Answer
185. Explain constructor.
Answer: Constructor is a method in the class which has the same name as the class (in VB.Net its New()). It initializes the member attributes whenever an instance of the class is created.
Show Answer
Hide Answer
186. How can you clean up objects holding resources from within the code?
Answer: Call the dispose method from code for clean up of objects
Show Answer
Hide Answer
189. Which property of the textbox cannot be changed at runtime?
Answer: Locked Property.
Show Answer
Hide Answer
190. Which control cannot be placed in MDI?
Answer: The controls that do not have events.
Show Answer
Hide Answer
191. What is the difference between proc. sent BY VAL and BY SUB?
Answer: BY VAL: changes will not be reflected back to the variable.
By REF: changes will be reflected back to that variable.( same as & symbol in c, c++)
Show Answer
Hide Answer
192. Did Adaptive Path invent Ajax? Did Google? Did Adaptive Path help build Googles Ajax applications?
Answer: Neither Adaptive Path nor Google invented Ajax. Googles recent products are simply the highest-profile examples of Ajax applications. Adaptive Path was not involved in the development of Googles Ajax applications, but we have been doing Ajax work for some of our other clients.
Show Answer
Hide Answer
193. 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?
Answer: The answer to all of these questions is “maybe”. Many developers are already working on ways to address these concerns. We think theres 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.
Show Answer
Hide Answer