ASP.NET interview questions and answers

  1. Describe the difference between a Thread and a Process?
  2. What is a Windows Service and how does its lifecycle differ from a “standard” EXE?
  3. What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?
  4. What is the difference between an EXE and a DLL?
  5. What is strong-typing versus weak-typing? Which is preferred? Why?
  6. What’s wrong with a line like this? DateTime.Parse(myString
  7. What are PDBs? Where must they be located for debugging to work?
  8. What is cyclomatic complexity and why is it important?
  9. Write a standard lock() plus double check to create a critical section around a variable access.
  10. What is FullTrust? Do GAC’ed assemblies have FullTrust?
  11. What benefit does your code receive if you decorate it with attributes demanding specific Security permissions?
  12. What does this do? gacutil /l | find /i “about”
  13. What does this do? sn -t foo.dll
  14. What ports must be open for DCOM over a firewall? What is the purpose of Port 135?
  15. Contrast OOP and SOA. What are tenets of each
  16. How does the XmlSerializer work? What ACL permissions does a process using it require?
  17. Why is catch(Exception) almost always a bad idea?
  18. What is the difference between Debug.Write and Trace.Write? When should each be used?
  19. What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
  20. Does JITting occur per-assembly or per-method? How does this affect the working set?
  21. Contrast the use of an abstract base class against an interface?
  22. What is the difference between a.Equals(b) and a == b?
  23. In the context of a comparison, what is object identity versus object equivalence?
  24. How would one do a deep copy in .NET?
  25. Explain current thinking around IClonable.
  26. What is boxing?
  27. Is string a value type or a reference type?

Visit Scott Hanselman’s blog for more ASP.NET interview questions he asks.

This entry was posted in .NET, Web dev. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

92 Comments on ASP.NET interview questions and answers

  1. kavitha reddy
    Posted 11/16/2006 at 4:49 am | Permalink

    how to display graph charts for polling results?

  2. kavitha reddy
    Posted 11/16/2006 at 4:54 am | Permalink

    Difference Between Machine.config and Web.config:

    Machine.config->Configuration file for all the applications in the system.

    Web.config->Config file for single application.

  3. Jay Bahuguna
    Posted 11/17/2006 at 7:47 am | Permalink

    The IClonable interface is needed when you want to provide clonable
    functionality for a bunch of classes and don’t care what actually
    implements the class.

  4. Dipal Shah
    Posted 11/20/2006 at 12:55 am | Permalink

    Ans-1)

    Process:
    *Execution Context:
    1)Program COunter(PC)
    2)Stack Pointer
    3)Data Register
    *CODE
    *DATA
    *STACK
    *Process :Unit Of allocation(Resource,priviliges etc)
    *each process have one or more threads
    *Inter process communication is expensive:need to context swith
    *Secure:one process can not corrupt another process

    Thread:
    Execution Context:
    1)program counter
    2)stack pointer
    3)Data register
    *each thread belong to one process
    *Unit of execution(Pc,sp etc)
    *inter thread communication is chip:can use process memory and may not need to context switch
    *not secure:a thread can write the memory used by the another thread

    Ans-2)

  5. Dipal Shah
    Posted 11/20/2006 at 4:13 am | Permalink

    Ans-2)A windows service is an application that started when windows is booted and runs in background as long as windows running.it is very close concept of unix daeomn

    Windows services lifecycle is managed by “Service Control Manager” which is responsible for starting and stopping the service and the applications do not have a user interface or produce any visual output, but “Standard executable” doesn’t require Control Manager and is directly related to the visual output

  6. Dipal Shah
    Posted 11/20/2006 at 4:34 am | Permalink

    ans-3)Well since most people are still not using a 64 bit operating system, we are going to keep this discussion limited to a 32bit OS. In the NT Flavor of operating systems, 4GB of memory is available to each process but it is split 50/50 with with the operating system.

    So each process has 2GB of memory available for its private use. The other 2GB is used by the operating system, devices, graphics cards, etc.. Keep in mind, the 4GB/2GB size is regardless of how much RAM you have installed.

    This would affect system design if you are creating an application that uses very large data structures or applications like mail servers, database management servers etc.. To address the need for more memory space, you can use a /3GB switch which then splits the memory usage from 50/50 to 75/25. Allowing your application to use 3GB of the 4GB available.

  7. Dipal Shah
    Posted 11/22/2006 at 5:38 am | Permalink

    ans-27) String is a refrence type.Value types differ from reference types in that variables of the value types directly contain their data, whereas variables of the reference types store references to objects. With reference types, it is possible for two variables to reference the same object, and thus possible for operations on one variable to affect the object referenced by the other variable. With value types, the variables each have their own copy of the data, and it is not possible for operations on one to affect the other

  8. Dipal Shah
    Posted 11/22/2006 at 5:44 am | Permalink

    ans-26)convert value types into refrence types is called boxing.
    two types of boxing:
    1)implicit boxing
    2)explicit boxing

  9. Dipal Shah
    Posted 11/22/2006 at 5:53 am | Permalink

    ans-25)Icionable is preferable to using copying constructors because it is standardlised ans utilised by other portion of the ,net framework to generate object copies

  10. Dipal Shah
    Posted 11/22/2006 at 6:23 am | Permalink

    ans-24)implement icionable interface and define yr imlementation to execute deep copies of yr subobjects.alternatively serialize the object and deserialize the another object ,but this process is very slow comparable cloning interface.

  11. Dipal Shah
    Posted 11/22/2006 at 6:33 am | Permalink

    ans-23)

    1) two objects are identical if they share same address in memory.two objects are equivalent if they are instances of the same type and every field of the first object matches the fields of another object.

    2)object identical have only same instances.object equivalent have fields are same but the different instances only type are same.

  12. Dipal Shah
    Posted 11/23/2006 at 2:14 am | Permalink

    Ans-22)a==b is used for assifning.to check the refrence of two objects.

    a.equals(b) is used for comparision.comparing of two objects

  13. Dipal Shah
    Posted 11/23/2006 at 6:20 am | Permalink

    ans-21)

    Absteact class provides implementation for methods and properties.
    Interfaces only provides required declaration.

    In simple term all methods in an interface are abstract.In abstract class some methods are abstract

  14. Dipal Shah
    Posted 11/23/2006 at 6:28 am | Permalink

    Does JITting occur per-assembly or per-method? How does this affect the working set?

    Ans-20)Jit occuring per method.since method which are not called are not compiled at all.this reduces the working set.

  15. Dipal Shah
    Posted 11/23/2006 at 6:44 am | Permalink

    ans-19)

    In a debug build the complete symbolic debug information is emitted to help debug application and also the code optimization is not taken into account.

    while in release build symbolic debug info is not emmited and the code execution is optimised.
    because of the symbolic info is not include in release build,the size of the final executable is lesser than the debug executable.

  16. Dipal Shah
    Posted 11/23/2006 at 7:19 am | Permalink

    ans-18)

    debug.write call would not be compiled when the debugsymbol is not defined.trace.write can be compiled.debug.write is for only yr debug builds.trace.write is for when you want it in release buildas well.

  17. Dipal Shah
    Posted 11/25/2006 at 12:18 am | Permalink

    Why is catch(Exception) almost always a bad idea?

    ans-17)It’s a question of how your program is going to recover. Some exceptions are the fault of the program, which generally means the program should log the details and shut down.

    Others are due to unexpected user input, connection problems, files not where expected and your program may be able to recover, for example ask the user where the missing file is.

    It’s generally best to put a exception handler round the whole program, and every thread which may want to catch not just Exceptions but errors (like NullPointerException) and log the details. This is to field the unrecoverable errors.

  18. michel maddux
    Posted 1/2/2007 at 1:38 pm | Permalink

    Clarifications: on the response to thread vs. process above. While not entirely incorrect, this answer is inadequate. Threads exist within a process. A process can contain multiple threads. The operating system contains multiple processes. A process is associated with a specific job object; this object is used to define the data structures required for a process to become executable. A process is executable because one of the threads that it contains is executable. When the process is selected for execution, the data structures are mapped for the CPU and execution begins on the executable thread.
    The advantage of using threads is that slower operations, like network activity or disk I/O, can run in the background, while an event interface like the user interface can still be responsive for user commands.

  19. Praveen
    Posted 1/8/2007 at 1:42 am | Permalink

    what is web.config in .NET?, and what’s the main usage of it?

    It is a configuration file for asp.net web applications. It is written in xml.

    Inisde web.config file one can have:

    Database connections
    Session states
    Error handling code
    Security can also be enforced.

  20. Baliram Suryawanshi
    Posted 1/20/2007 at 3:00 pm | Permalink

    AS EJB technology enables rapid and simplified development of distributed, transactional, secure and portable applications based on Java technology
    which technology is available in .Net?

  21. suneel-sunny
    Posted 2/6/2007 at 6:23 am | Permalink

    Hi,
    Q) How can u say string as reference type?
    A) The explanation comes here..

    string one = “suneel”;
    string two = one;
    one = “sunny”;

    Now both strings one and two having the same value i.e. sunny.

    int x = 5;
    int y = x;
    x = 7;
    Now integer x having the value of 7.Where as integer y having the value of 5.

    Summary:
    Reference Type: Another copy of data will be created. A reference will be added to the existing one.
    Value type: Another copy of data will be created.

  22. sona Jha
    Posted 2/23/2007 at 12:20 am | Permalink

    Hi radhakrishnan,
    Machine config:it sets the base configuration for all the .net assemblies running on the server
    web config:This sets the base config for all the web app and override settings in machine configuration

  23. Chaud
    Posted 4/12/2007 at 6:04 pm | Permalink

    Q12:

    gacutil /l searches the GAC for all items.

    The “|” pipes the output of that command to the next command.

    find /i “about” searches all files for the word “about” without regard to case.

    The result is all items in the GAC are searched (case-insensitively) for the word “about”.

  24. Chaud
    Posted 4/12/2007 at 6:59 pm | Permalink

    13. What does this do? sn -t foo.dll

    Displays the public key token of foo.dll. foo.dll must be strong-named.

    Additionally, if -tp is used then the public key itself is also displayed.

  25. Srinivas Kolluru
    Posted 5/4/2007 at 10:28 am | Permalink

    Answer for 21. Wether to Choose VB.NET/C#.
    Both the languages ar using same classes and namespaces. Once it compile and generates MSIL, there is no meaning of which language it was written.

    But i observed that the no of lines in MSIL for the same code of C# is lesser compared to VB.net.

    So in my opinion C3 might be faster than vb.net, as the no execution line will be less in C# for the same functionality

  26. Vandana
    Posted 5/27/2007 at 12:20 pm | Permalink

    What is FullTrust? Do GAC’ed assemblies have FullTrust?

    When we write a code and place it any location, and run it from our local computer, the first thing the system does it to check in which zone the application is placed like Internet, Intranet, local etc. All zones receive certain trust levels. The permissions to run any assembly is based on its trust level. Under Full Trust level all assemblies can be run successfuly. All GAC asemblies have Full Trust as ever strong named assembly is Full Trust assembly.

  27. Sivakumar
    Posted 6/5/2007 at 10:54 pm | Permalink

    what is Boxing and Unboxing?
    Boxing is an implicit conversion of a value type to the type object
    int i = 123; // A value type
    Object box = i // Boxing
    ——————————————————————————–
    Unboxing is an explicit conversion from the type object to a value type
    int i = 123; // A value type
    Object box = i; // Boxing
    int j = (int)box; // Unboxing

    Thanks
    L.Siva
    http://www.dotnetanalyst.com

  28. H.Ashok
    Posted 8/6/2007 at 9:47 am | Permalink

    Diff -> Equals(), ==

    Please see this example:-
    using System;
    class test
    {
    public static void Main()
    {
    string str1=”Microsoft”;
    string str2=”Micorsoft”;
    Console.WriteLine(”Equals() Method=” + str1.Equals(str2));
    Console.WriteLine(”== Operator=” + str1==str2);
    }
    }

  29. Swati M
    Posted 9/25/2007 at 12:44 pm | Permalink

    What is the difference between a.Equals(b) and a == b?

    a.Equals(b) is generally used to compare objects,reference type.
    So a.Equals(b) gives a boolean result True if

  30. Pradeep
    Posted 10/17/2007 at 3:40 am | Permalink

    22. What is the difference between a.Equals(b) and a == b?

    a.Equals(b) -> equality is defined as object equality; that is, whether the references refer to the same object.

    a == b -> equality is defined as bitwise equality. The ValueType class supports value types.

    ref:http://msdn2.microsoft.com/en-us/library/aa329861(VS.71).aspx

  31. Manju
    Posted 12/3/2007 at 9:16 am | Permalink

    what will happen if i remove web.config from my application. what action is not possible to perform if web.config is removed.

  32. Afzal Aziz
    Posted 12/16/2007 at 10:44 am | Permalink

    q (6) What’s wrong with a line like this? DateTime.Parse(myString)

    Exactly there is nothing wrong with the above statement and can be especially when try validate whether the string is a valid Date.

    But the above DateTime.Parse(myString), will even convert invalid date like 45-nov-77 into date of the previous century so validating whether the string is a valid Date using DateTime.Parse(myStrin) is not recommended. Use DateTime.ParseExact() instead.

  33. Ashutosh MAlvade
    Posted 1/18/2008 at 4:55 am | Permalink

    What is the difference between a.Equals(b) and a == b?

    Dim a As Boolean = True
    Dim c As Integer = 1
    Dim s As String = “1″
    s.Equals(c) check for type as well as value of variables and follwing condition fail
    If s.Equals(c) Then
    s = “ok”
    End If
    s=c not check for type of variables and execute follwing condotion
    If s = c Then
    s = “ok”
    End If
    If s.Equals(a) Then
    s = “ok”
    End If

  34. shiv
    Posted 2/26/2008 at 12:31 pm | Permalink

    TO change from “value type” to “reference type” is known as “Boxing”

  35. padma
    Posted 4/22/2008 at 1:28 am | Permalink

    What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?

    The maximum amount of mem any single process on windows can address 4GB, 2 GB fo r the thread and & gb for the application.

    What is the difference between an EXE and a DLL?

    An EXE is portable and executable with a entry point but dll is not portable and executable since it has no entry point

    What is strong-typing versus weak-typing? Which is preferred? Why?

    strongly typed is nothing but the method that should support with the equal parametres ,ex, delegates

    What is boxing?
    converting value type into refernce type.

  36. Naresh Prakash
    Posted 6/27/2008 at 9:54 pm | Permalink

    24. Deep copy meaning that copy schema with data..

  37. Posted 7/2/2008 at 12:49 am | Permalink

    What is HashTable

  38. Posted 7/2/2008 at 12:50 am | Permalink

    What Is GAC

  39. Naresh Prakash
    Posted 7/2/2008 at 2:00 pm | Permalink

    HashTable, Collection of values with keys, in hashtable value not duplicate, find with values or with keys or with index… HastTable is very useful.

  40. Naresh Prakash
    Posted 7/2/2008 at 2:06 pm | Permalink

    GAC: Global assembly cache contains shared assemblies that are globally accessible to all .net application on the machine. Shared assembly is installed in the GAC.

  41. prasad
    Posted 7/25/2008 at 1:16 pm | Permalink

    What is the difference between a.Equals(b) and a == b?

    Both are used for comparison..but a.Equals(b) will work even if data type of a and b is different..

    To use a==b , you have to use same data type of a and b.

  42. rajendra
    Posted 1/20/2009 at 4:31 am | Permalink

    1)A process is an OS-level task or service. A thread runs “inside” a process and may be virtual or simulated. Generally speaking, threads share resources like memory, where processes each have their own separate memory area, and need to take more elaborate steps to share resources.
    Another name for thread is “lightweight process” to distinguish it from the “heavyweight” system processes.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*