DotNet Interview Questions – Any developer

Everyone who writes code

  1. Describe the difference between a Thread and a Process?

Answer:

    1. Both are individual execution paths, but process timeslicing (and memory space) is enforced by the OS, while thread differentiation is enforced by applications.
    2. We can have multiple threads in a single process. Thus we can say threads are working units of a process.
    3. We can execute a process (EXE) but threads can be created and executed from inside a process
  1. What is a Windows Service and how does its lifecycle differ from a "standard" EXE?

Answer:

    1. Services are loaded by the operating system and run in contained process spaces detached from user interaction; users logging on and off the system have no impact on them.
    2. A service opens before you even get to the login screen, whereas a standard exe cannot open until after you have logged on.
    3. Windows Service applications are long-running applications that are ideal for use in server environments. The applications do not have a user interface or produce any visual output. Any user messages are typically written to the Windows Event Log. Services can be automatically started when the computer is booted. They do not require a logged in user in order to execute and can run under the context of any user including the system. Windows Services are controlled through the Service Control Manager where they can be stopped, paused, and started as needed.
    4. Windows service is a application that runs in the background. It is equivalent to a NT service.

The executable created is not a Windows application, and hence you can't just click and run it . it needs to be installed as a service, VB.Net has a facility where we can add an installer to our program and then use a utility to install the service. Where as this is not the case with standard exe.

  1. 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?

Answer:

Windows processes are allowed 4GB of virtual address space, regardless of the actual amount of memory on the machine. Windows x64 allows 16TB of address space.

Actually processes access virtual memory space, not physical memory. Applications never access RAM directly but only through the memory management interface of the processor. All processes have a 4GB virtual address space. The upper 2GB is common to all processes and is used by the system. The lower 2GB is private to each process and is inaccessable to all others. This is completely independent of the size of RAM or the pagefile. The system maps physical memory into this virtual address space according to both need and availability. At any given time the data in virtual memory space might be stored in RAM, on disk, or both. All of this is totally transparent to all applications. Frequently accessed data will be kept in RAM with the remainder left on disk.

  1. What is the difference between an EXE and a DLL?

Answer:

EXEs can be launched as processes by the operating system. DLL executable code must be invoked by an existing process.

DLL

    1. Its a Dynamic Link Library.
    2. DLL is inprocess.
    3. There are many entry points.
    4. The system loads a DLL into the context of an existing thread.
    5. In one windows Application, if any problem in DLL, just that specific form or part only will not work.but if any problem in Exe, entire application will not work.
    6. dll is the reusable software component.

EXE

  1. Executable file.
  2. exe is outprocess.
  3. There is only single main entry.
  4. When a system launches new exe, a new process is created.
  5. The entry thread is called in context of main thread of that process.

An EXE can run independently, whereas DLL will run within an EXE. DLL is an in-process file and EXE is an out-process file.

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

Answer:

Strong-typing refers to defining the specific type of a reference at compile time rather than at run time. This results in more efficient execution and memory optimizations at compile time, as well as reduces the chance of a programmer accidentally providing a value of a type another component wasn't expecting.

Strong type is checking the types of variables as soon as possible, usually at compile time. While weak typing is delaying checking the types of the system as late as possible, usually to run-time. Which is preferred depends on what you want. For scripts & quick stuff you’ll usually want weak typing, because you want to write as much less (is this a correct way to use Ensligh?) code as possible. In big programs, strong typing can reduce errors at compile time.

Strong type is checking the types of variables at compile time. weak typing is checking the types of the system at run-time. For scripts & quick stuff we’ll use weak typing, In big programs, strong typing can reduce errors at compile time.

  1. What is a PID? How is it useful when troubleshooting a system?

Answer:

(Ambiguous) This could refer to either a Microsoft Product ID -- the unique key that brands each activatable component installed on a system -- or to a Process ID, which is a means of referring to a specific process in calls to the Windows API.

PID stands for Process Identifier, a uniquely assigned integer that identifies a process in the operating system. In any system, applications use PID to identify the process uniquely. Also, it is used in diagnosing the problems with the process in Multi-Tasking systems.

PID is caleld process id, its used to usually track the resources that a process is using. In a case where a process is stuck and is using valuable resouces, it is killed based on the PID.

  1. How many processes can listen on a single TCP/IP port?

Answer: One

  1. What is the GAC? What problem does it solve?

Answer:

The Global Assembly Cache. It stores strongly-named assemblies in a single location, allowing for verification of code library uniqueness when executing.