Wednesday, October 14, 2009
Asp.Net Interview Questions(61-70)
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.
61. Can you store multiple data types in System.Array?
No.
62. What is the smallest unit of execution in .NET?
An Assembly is the smallest unit of execution in .NET.
63. What’s the difference between the System.Array.CopyTo () and System.Array.Clone ()?
The Clone () method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo () method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identical object.
64. How can you sort the elements of the array in descending order?
By calling Sort () and then Reverse () methods.
65. What’s the .NET collection class that allows an element to be accessed using a unique key?
HashTable.
66. What class is underneath the SortedList class?
A sorted HashTable.
67. Will the finally block get executed if an exception has not occurred?
Yes.
68. What’s the C# syntax to catch any possible exception?
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 {}.
69. Can multiple catch blocks be executed for a single try statement?
No. Once the proper catch block processed, control is transferred to the finally block (if there are any).
70. Does the .NET Framework have in-built support for serialization?
There are two separate mechanisms provided by the .NET class library
1. XmlSerializer (for Web Services)and
2.SoapFormatter/BinaryFormatter.( for remoting.)
Tuesday, October 13, 2009
Asp.Net Interview Questions(51-60)
Server side code will execute at server end all the business logic will execute at server end
where as client side code will execute at client side at browser end.
52. How does VB.NET/C# achieve polymorphism?
Function overloading.
Operator overloading
Does C# support multiple-inheritance?
No.we go for interface.
53. Who is a protected class-level variable available to?
It is available to any sub-class (a class inheriting this class).
54. Are private class-level variables inherited?
Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.
55. Describe the accessibility modifier “protected internal”.
It is available to classes that are within the same assembly and derived from the specified base class.
56. What’s the top .NET class that everything is derived from?
System.Object.
57. What does the term immutable mean?
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.
58.Explain the three services model commonly know as a three-tier application.
Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).
59. What’s the difference between System.String and System.Text.StringBuilder classes?
System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
60. What’s the advantage of using System.Text.StringBuilder over System.String?
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.
Asp.Net Interview Questions-(41-50)
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.
42. What’s the difference between the Debug class and Trace class?
Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
43.What are the different ways a method can be overloaded?
Different parameter data types, different number of parameters, different order of parameters with the same name.
44. Is XML case-sensitive?
Yes it is case sensitive.
45. What does the keyword “virtual” declare for a method or property?
It means that the particular method or property can be overridden.
46. What is a satellite assembly?
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.
47. How do you convert a value-type to a reference-type?
We can convert a value-type to a reference-type by Use Boxing.
48. What does the term immutable mean?
Immutable means you can't change the current data, but if you perform some operation on that data, a new copy is created.
The operation doesn't change the data itself. Like let's say you have a string object having "Dotnet" value. Now if you say temp = temp + "new value" a new object is created, and values is saved in that. The temp object is immutable, and can't be changed.
49. Does Array.CopyTo make a deep copy?
No.
50. What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?
Server.Transfer will prevent round trip. it will redirect pages which or in the same directory. NO way to pass the query strings. Thru http context we can able to get the previous page control values.
Response.Redirect: There is a round trip to process the request. We can redirect to any page external / internal other than aspx. We can pass the query string thru which we can man age sessions.
Asp.Net Interview Questions(31-40)
No. Currently no simple way to stop code being reverse-engineered from IL. In future it is likely that IL obfuscation tools will become available, either from MS or from third parties.
If you are writing web services then reverse-engineering is not a problem as clients do not have access to your IL.
32. Can I write IL programs directly?
Yes. Simple example to the DOTNET mailing list:
.assembly MyAssembly {}
.class MyApp {
.method static void Main() {
.entrypoint
ldstr "Hello, IL!"
call void System.Console:: WriteLine (class System.Object)
ret
}
}
Just put this into a file called dotnet.il, and then run ilasm dotnet.il. An exe assembly will be generated.
33. Can I do things in IL that I can't do in C#?
Yes. A couple of simple examples are that you can throw exceptions that are not derived from System.Exception, and you can have non-zero-based arrays.
34. How does .NET remoting work?
.NET remoting involves sending messages along channels.
Two of the standard channels are HTTP and TCP. TCP is intended for LANs only - HTTP can be used for LANs or WANs (internet).
Support is provided for multiple message serialization formats. Examples are SOAP (XML-based) and binary. By default, the HTTP channel uses SOAP (via the .NET runtime Serialization SOAP Formatter), and the TCP channel uses binary (via the .NET runtime Serialization Binary Formatter). But either channel can use either serialization format.
There are a number of styles of remote access:
• SingleCall. Each incoming request from a client is serviced by a new object. The object is thrown away when the request has finished.
• Singleton. All incoming requests from clients are processed by a single server object.
• Client-activated object. This is the old stateful (D) COM model whereby the client receives a reference to the remote object and holds that reference (thus keeping the remote object alive) until it is finished with it.
35. How do I read from a text file?
First, use a System.IO.FileStream object to open the file:
FileStream fs = new FileStream( @"c:\test.txt", FileMode.Open, FileAccess.Read );
FileStream inherits from Stream, so you can wrap the FileStream object with a StreamReader object. This provides a nice interface for processing the stream line by line:
StreamReader sr = new StreamReader( fs );
string curLine;
while( (curLine = sr.ReadLine()) != null )
Console.WriteLine( curLine );
Finally close the StreamReader object:
sr.Close();
Note that this will automatically call Close() on the underlying Stream object, so an explicit fs.Close() is not required.
36. How do I write to a text file?
First, use a System.IO.FileStream object to open the file:
FileStream fs = new FileStream( @"c:\test.txt", FileMode.Open, FileAccess.Read );
FileStream inherits from Stream, so you can wrap the FileStream object with a StreamReader object. This provides a nice interface for processing the stream line by line:
StreamWriter sr = new StreamWriter ( fs );
string curLine;
while( (curLine = sr.ReadLine()) != null )
Console.WriteLine( curLine );
Finally close the StreamWriter object:
sr.Close();
Note that this will automatically call Close() on the underlying Stream object, so an explicit fs.Close() is not required.
37. How do I read/write binary files?
Similar to text files, except wrap the FileStream object with a BinaryReader/Writer object instead of a StreamReader/Writer object.
38. will dotnet supports regular expressions?
Yes . Using the class regex in the namespace System.Text. RegularExpressions.
39. Give me the Code to Export DataGrid to Excel in web application
Response.Clear();
Response.Buffer true;
Response.ContentType "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition" "attachment;filename ReviewDesignation.xls");//This
lets you always open the Excel window when exporting whether you click on open or save.
Response.Charset "";
this.EnableViewState false;
System.IO.StringWriter oStringWriter new
System.IO.StringWriter();System.Web.UI.HtmlTextWriter oHtmlTextWriter
new System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(dGrid);
dGrid.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
40. What debugging tools come with the .NET SDK?
1. CorDBG – command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch.
2. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR.
Asp.Net Interview Questions and Answers(21-30)
Limitation:-
XmlSerializer has severe limitations such as
the requirement that the target class has a parameterless constructor,
and only public read/write properties and fields can be serialized.
Advantage:-
However, on the plus side, XmlSerializer has good support for customizing the XML document that is produced or consumed. XmlSerializer's features mean that it is most suitable for cross-platform work, or for constructing objects from existing XML documents.
22. Explain the Limitation and advantage of SoapFormatter/BinaryFormatter?
SoapFormatter and BinaryFormatter have fewer limitations than XmlSerializer. They can serialize private fields, for example. However they both require that the target class be marked with the [Serializable] attribute, so like XmlSerializer the class needs to be written with serialization in mind. Also there are some quirks to watch out for - for example on Deserialization the constructor of the new object is not invoked.
The choice between SoapFormatter and BinaryFormatter depends on the application. BinaryFormatter makes sense where both serialization and Deserialization will be performed on the .NET platform and where performance is important. SoapFormatter generally makes more sense in all other cases, for ease of debugging if nothing else.
23. Can the serialization process can be customized?
Yes. XmlSerializer supports a range of attributes that can be used to configure serialization for a particular class.
For example, a field or property can be marked with the [XmlIgnore] attribute to exclude it from serialization. Another example is the [XmlElement] attribute, which can be used to specify the XML element name to be used for a particular property or field.
Serialization via SoapFormatter/BinaryFormatter can also be controlled to some extent by attributes. For example, the [NonSerialized] attribute is the equivalent of XmlSerializer's [XmlIgnore] attribute.
But the Ultimate control of the serialization process can be achieved by implementing the ISerializable interface on the class whose instances are to be serialized.
24. Why is XmlSerializer so slow?
There is a once-per-process-per-type overhead with XmlSerializer. So the first time you serialize or deserialize an object of a given type in an application, there is a significant delay. This normally doesn't matter, but it may mean,
for example
That XmlSerializer is a poor choice for loading configuration settings during startup of a GUI application.
25. Can I serialize a Hash table with XmlSerializer?
Any class that implements Idictionary will by be refused XmlSerializer.
e.g. Hashtable.
Soap Formatter and BinaryFormatter do not have this restriction.
26. What is CAS?
CAS-Code Access Security
CAS is the part of the .NET security model that determines
- whether a piece of code is allowed to runor not and
- what resources it can use when it is running.
27. How does CAS work?
The CAS security policy revolves around two key concepts –
Code groups and permissions.
Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a named permission set.
28. Who defines the CAS code groups?
Default groups are defined by microsoft,but you are allowed to modify and even create your own. To see the code groups defined on your system, run 'caspol -lg' from the command-line. On my system it looks like this:
Level = Machine
29. Can I look at the IL for an assembly?
Yes. A microsoft tool called Ildasm which can be used to view the metadata and IL for an assembly.
30. Whether source code be reverse-engineered from IL?
Yes, it is often relatively straightforward to regenerate high-level source (e.g. C#) from IL.
Thursday, October 8, 2009
Asp.Net Interview Questions and Answers-(11-20)
Managed code:
CLR is responsible for managing the execution code.
The code that satisfies the CLR at runtime inorder to execute is reffered to as managed code. Compilers that are compatible to the .NET platform genrate managed code.
12.What is JIT.what is the main work of JIT?
JIT-Just In Time Compiler.
The main work of JIT is to convert the IL code to naive machine code. Then the machine code is sent to runtime manager for execution.
13. What is reflection?
All .NET compilers produce data about the types defined in the modules they produce called metadata.
This metadata can be acessed by mechanism called reflection.
The namepsace system.reflection contains classes that can be used to interrogate the types for a module/assembly.
14.What is Garbage Collection ?
Garbage collection is a concept of runtime object managing the lifetime of objects and the heap memory that they occupy.
15. Is it true that objects don't always get destroyed immediately when the last reference goes away?
Yes. The garbage collector offers no guarantees about the time when an object will be destroyed and its memory reclaimed.
16. Do We have any control over the garbage collection algorithm?
Ya not fully but we can control a little. We have a name space System.GC which has many functions to control the garbage collector.
For ex;
Collect method - this forces the garbage collector to collect all unreferenced objects.
17. Can I find out what the garbage collector is doing?If yes How?
Yes .We can find out it by using the .NET CLR performance counters.
You can view them by performance monitor.
18.Define Serialization ?
Serialization is the process of converting an object into a stream of bytes.
19.Define Deserialization?
Deserialization is nothing but the opposite process of creating an object from a stream of bytes.
20.When the Serialization and Deserialization is used?
Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database).
Monday, October 5, 2009
Dotnet Interview Questions and answers (1-10)
According to Microsoft, .NET is a "revolutionary new platform, built on open Internet protocols and standards, with tools and services that meld computing and communications in new ways".
.NET is a
- Environment for developing and running software applications,
-Featuring ease of development of web-based services,
-Rich standard run-time services available to components written in a variety of programming languages, and inter-language and inter-machine interoperability.
2.Does .NET only apply to people building web-sites?
No. You can develop windows applications ie the stand alone application For your need and also the mobile applications. But .NET has lots to interest you in web applications(ASP.NET).
3.When was the first version of .NET released?
The first version of the .NET 1.0 SDK was made available to public around 6pm PST on 15-Jan-2002. At the same time, the version of Visual Studio.NET was made available to MSDN subscribers.
4.What platforms does the .NET Framework run on?
.Net Framework runs on Windows XP, Windows 2000, NT4 SP6a and Windows ME/98.
Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on Windows XP and Windows 2000. Windows 98/ME cannot be used for development.
The Mono project is attempting to implement the .NET framework on Linux.
5. What languages does the .NET Framework support?
Micro Soft provides compilers for C#, C++, VB and Jscript and its said as .NET Framework supports more than 40 languages.
6.What is the CLR?
CLR - Common Language Runtime.
- It is the heart and soul of the .NET Framework.
- Program written in c# and other .NET languages are executed in C#.
- It also supports cross language interoperability.
Services Of CLR :-
To load and execute programs.
To Islolate memory for applications.
To Verifying type safety
To Compile of IL into native executable code.
To provide metadata.
To mange memory(Garbage collection)
To enforce Security
To mange exceptions and errors.
7. What is the CTS?
CTS - Common Type System.
CTS supports various types and operations found in most prograaming languages and therefore calling one language from other does not require type conversions.so we can program in other languages.
The CTS is a superset of the CLS.
8. What is the CLS?
CLS -Common Language Specification.
- This is a subset of the CTS.
-The idea is that any program which uses CLS-compliant types can interoperate with any .NET program written in any language.
-In theory this allows very tight interop between different .NET languages - for example allowing a C# class to inherit from a VB class.
9. What is IL?
IL - Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language).
All the .NET source code (of any language) is compiled to IL. Then the IL is converted to machine code at run-time by a Just-In-Time (JIT) compiler.
10. What is C#?
C# is aa language designed by Microsoft to work with the .NET framework.
Microsoft describes C# as follows:
"C# is a simple, modern, object oriented, and type-safe programming language derived from C and C++. C# (pronounced “C sharp”) is firmly planted in the C and C++ family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++."
Wednesday, September 9, 2009
Asp.Net Interview Questions Part V
1.Features of a dataset?
2.How do you do role based security?
3. Difference between Response.Expires and Expires.Absolute?
4. Types of object in asp?
5. About duration in caching technique?
6. Types of configuration files and ther differences?
7.Difference between ADO and ADO.net?
8.About Postback?
9.Types of authentications in IIS?
10.Disadvantages of COM components?
Asp.Net Interview Questions Part IV
1.Difference between asp and asp.net?
2. Whis is stateless asp or asp.net?
3. Authentication mechanism in dotnet?
4.- State management in asp.net?
5. Types of values mode can hold session state in web.config?
6. About WebService?
7. What are Http handler?
8.What is view state and how this can be done and was this there in asp?
9. Types of optimization and name a few and how do u do?
Asp.Net Interview QuestionsPart III
1.Types of authentications in ASP.NET?
2.difference between Trace and Debug?
3. Difference between Dataset and DataReader?
4.- What is custom tag in web.config?
5.- How do you define authentication in web.Config?
6.What is sequence of code in retrieving data from database?
7. About DTS package?
8. What provider ADO.net use by default?
9. Where does web.config info stored? Will this be stored in the registry?
10. How do you register the dotnet component or assembly?
Asp.Net Interview Questions Part-II
1. What is difference between machine.config and web.config?
2. What is shared and private assembly?
3. What are asynchronous callbacks?
4.How to write unmanaged code and how to identify whether the code is managed / unmanaged.?
5. How to authenticate users using web.config?
6. What is strong name and which tool is used for this?
7. What is gacutil.exe. Where do we store assemblies?
8. Should sn.exe be used before gacutil.exe?
9. What does assemblyinfo.cs file consists of?
10. What is boxing and unboxing?
Asp.Net Interview Questions Part-1
2. How do you do exception management?
3. If you are using components in your application, how can you handle exceptions raised in a component?
4. Can we throw exception from catch block?
5. How do you relate an aspx page with its code behind page?
6. What are the types of assemblies and where can u store them and how?
7. What is difference between value and reference types?
8. Is array reference type / value type?
9. Is string reference type / value type?
10. What is web.config. How many web.config files can be allowed to use in an application?
Asp.Net Questions For Practice
1.Difference between asp and asp.net?
2.How do you do exception management?
3.If you are using components in your application, how can you handle exceptions raised in a component?
4.Can we throw exception from catch block?
5.How do you relate an aspx page with its code behind page?
6.What are the types of assemblies and where can u store them and how?
7.What is difference between value and reference types?
8.Is array reference type / value typ?
9.Is string reference type / value type?
10.What is web.config. How many web.config files can be allowed to use in an application?
11.What is difference between machine.config and web.config?
12.What is shared and private assembly?
13.What are asynchronous callbacks?
14.How to write unmanaged code and how to identify whether the code is managed / unmanaged.?
15.How to authenticate users using web.config?