Sunday, November 14, 2010

Interview Questions

What is .Net framework?
.Net framework is a set of technologies that form an integral part of .Net. platform. .Net framework provide you a environment to write managed code. It has two main components.
CLR and FCL(Framework Class Library)

What is CLR ?
Common Language Run Time provides the common services to manage code like memory management,Exception Handling and Security.

.Net compiler(Different for different languages) convert source code to CIL(Common Intermediate Language). At run time CLR’s JIT convert CIL to machine code.

What is FCL?
FCL(Framework Class Library) is a set of common classes that is used to access common functionality.

What is CTS?
CTS is a component of CLS.CTS describes the common types used by managed code. It facilitates cross-language integration, type safety and high performance code execution.

What is CLS?
Common Language Specification defines the guidelines for languages to communicate to each other.

What is Manage Code?
To get the facilities of CLR every code should provide a minimum information to CLR. That code provide that information it is called managed code.

What is an Application Domain?
An Application domain is a boundary for a process. A process can contains multiple application domain. It is an isolation for process. An application domain can not communicate directly to other application domain. For that we need proxy.

What is Assembly?
An assembly is a collection of one or more exe or dll. An assembly contains a collection of types and resources that are built to work together and form a logical unit of functionality.

What an assembly contains?
A static assembly can contains four parts.
1) Manifest
2) Type Metadata- Binary information that describes a program
3) IL
4) A set of resources.

What is manifest?
Manifest describes the assembly itself.
Manifest contains the assembly metadata. An assembly manifest contains the information about the identity and version of the assembly. It also contains the information required to resolve references to type and resources.

What is Strong Name?
To place an assembly in GAC we need to assign a strong name to that assembly. Strong Name Include text name, version and culture information, a public and a digital signature signature generated over that assembly. There is a tool Sn.exe verification and key pair and signature generation.

Satellite Assembly
An assembly that contains only resources is called satellite assembly. It is used often to deploy language specific resources for an application.

Sleep,Suspend and Resume
Suspend allows you to block a thread until another thread call Thread.Resume.
Sleep allow you to block a thread for a specific time or for inifinite time.

.Net framework does not suspend a thread until it determine that it is in a safe place to suspend, while Sleep immediately put a thread into wait state.

Join wait for a previous thread to complete and after the completion of previous thread it is started.

Daemon Thread
A background thread is called daemon thread. we can do it by setting the property IsBackground=true. GC is an example of Daemon thread.

Can we use events with threads?
Yes events can be used with thread. This is one of the technique to synchronize one thread with other.

How can we know thread state?
ThreadState property can be used to determine the state of thread. It is an enumeration.

How to stop a long running thread?
Thread.Stop() method can be called for that.

How do you implement synchronization ?
lock and Synclock
Two thread can try to access the same variable at same time. This can create the problem.To avoid it you can use lock to lock a variable but if two threads lock a variable at same time it can be cause a deadlock problem.
Synclock x
//Do something
End Synclock

What is use of Interlocked class?
Interlocked class provides methods by which you can achieve following functionality?
1) Increment Value
2) Decrement Value
3) Exchange Value between variables
4) Compare Values from any thread in synchronize mode.

Monitor object
Monitor object are used to ensure that a block of code runs without interruption of other thread. This is a way of synchronization, code from other thread can not run until code written in synch block has finished.

What are wait handles?
1) WaitOne
2) WaitAny
3) WaitAll

When a thread wants to release a wait handle it can call set method.

Mutex Object
Mutex object is a synchronized object that can be used by only one thread at a time. If it is owned by a thread its state is signaled and if it is not owned by any thread its state is non signaled. Exapmle :- If you want that at a time only single instance of an application should run than you can use Mutex object

What is ManualResetEvent and AutoResetEvent?
Thread that called wait method of synchronize event must wait until another thread signal the event by calling Set method.

In case of ManualReset event we use Set method to signaled. Threads set the status of ManualResetEvent instances to non signaled using the Reset method or when control returns to waiting Waitone call.

Instances of AutoResetEvent class can also be set to Signaled using set, But they automatically return to non signaled as soon as a waiting thread is notified that the event become signaled.

Indexes are created on columns of table or views. The index provides a fast way to look up data based on the values within these columns.
For example if you create an index on the primary key and search a row based on that primary key, SQL server first find that values in the index and then uses that index to find the entire row.
Without the index, a table scan would have to be performed in order to locate the data.
You can not create index on large data type like image,text,varchar(max).

Clustered Index :-
Clustered index is unique for any given table and we can have only one clustered index on a table. The leaf level of a clustered index is the actual data and the data is resorted in case of clustered index.

Non Clustered Index :-
Whereas in case of non-clustered index the leaf level is actually a pointer to the data in rows so we can have as many non-clustered indexes as we can on the db(max 249).

No comments: