What is garbage collection

interview questions of dot net

Posted on

Qu – What is the difference between a private assembly and a shared assembly?

  • Location and visibility

: A private assembly is normally used by a single application, and is stored in the application’s directory, or a sub -directory beneath. A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful, e.g. the .NET framework classes.

  • Versioning: The runtime enforces versioning constraints only on shared assemblies, not on private assemblies.

 

Qu – What is garbage collection?

Garbage collection is a heap -management strategy where a run-time component takes responsibility for managing the lifetime of the memory used by objects. This concept is not new to .NET-Java and many other languages/runtimes have used garbage collection for some time.

 

Qu -What is the difference between an event and a delegate?

An event is just a wrapper for a multicast delegate. Adding a public event to a class is almost the same as adding a public multicast delegate field. In both cases, subscriber objects can register for notifications, and in both cases the publisher object can send notifications to the subscribers. However, a public multicast delegate has the undesirable property that external objects can invoke the delegate, something we’d normally want to re

strict to the publisher. Hence events – an event adds public methods to the containing

class to add and remove receivers, but does not make the invocation mechanism public.

 

Qu- What size is a .NET object?

Each instance of a reference type has two fields maintained by the runtime -a method table pointer and a sync block. These are 4 bytes each on a 32-bit system, making a total of 8 bytes per object overhead. Obviously the instance data for the type must be added to this to get the overall size of the obj ect. So, for example, instances of the following class are 12 bytes each:

 

class MyInt

{

private int x;

}

However, note that with the current implementation of the CLR there seems to be a minimum object size of 12 bytes, even for classes with no data (e.g.System.Object).

Values types have no equivalent overhead.

 

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Advertisements