Posts

Showing posts from March, 2015

Difference between array, arraylist, List, Hashtable, Dictionary and SortedList in c#

Basic difference is that arrays are of fixed size. Whereas an ArrayList implements the list data structure and can dynamically grow. While arrays would be more performance that a list, a list would be far more flexible since you don't need to know the required size initially. Array - represents an old-school memory array - kind of like a alias for a normal type[] array. Can enumerate. Can't grow automatically. I would assume very fast insertion, retrieve and speed. ArrayList - automatically growing array. Adds more overhead. Can enum., probably slower than a normal array but still pretty fast. These are used a lot in .NET List - one of my favorites - can be used with generics, so you can have a strongly typed array, e.g. List . Other than that, acts very much like ArrayList. Hashtable - plain old hashtable. O(1) to O(n) worst case. Can enumerate the value and keys properties, and do key/val pairs. Dictionary - same as above only strongly typed via generics, such a...

what is foreign key in sql

What is FOREIGN KEY? A FOREIGN KEY constraint prevents any actions that would destroy links between tables with the corresponding data values.  A foreign key in one table points to a primary key in another table. Foreign keys prevent actions that would leave rows with foreign key values when there are no primary keys with that value.  The foreign key constraints are used to enforce referential integrity.

sql interview questions and answers part 2

What is the difference between a HAVING CLAUSE and a WHERE CLAUSE? They specify a search condition for a group or an aggregate. But the difference is that HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause. Having Clause is basically used only with the GROUP BY function in a query whereas WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.

sql interview questions and answer part 1

What's the difference between a primary key and a unique key? Both primary key and unique key enforces uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a non-clustered index by default. Another major difference is that, primary key doesn't allow Nulls, but unique key allows one NULL only.

differences between function and stored procedure?

1) Function returns only one value but procedure returns one or more than one value. 2) Function can be utilized in select statements but that is not possible in procedure. 3) Procedure can have an input and output parameters but function has only input parameters only. 4) Exceptions can be handled by try catch block in procedures but that is not possible in function.

What is HashTable?

A Hashtable is a collection of key-value pairs. Entries in this are instance of DictionaryEntry type.  It implements IDictionary, ISerilizable, IDeserializable collback interface.

What is BitArray?

The BitArray collection is a composite of bit values. It stores 1 or 0 where 1 is true and 0 is false.  This collection provides an efficient means of storing and retrieving bit values.

What is ArrayList in c sharp?

ArrayList is a dynamic array. Elements can be added and removed from an arraylist at the runtime.  In this elements are not automatically sorted.

What is Array in C sharp?

An array is a collection of related instance either value or reference types. Array posses an immutable structure in which the number of dimensions and size of the array are fixed at instantiation. C# Supports Single, Mult dimensional and Jagged Array. Single Dimensional Array: it is sometimes called vector array consists of single row. Multi-Dimensional Array: are rectangular & consists of rows and columns. Jagged Array: also consists of rows & columns but in irregular shaped (like row 1 has 3 column and row 2 has 5 column)

Features of c# .net

Boolean Conditions Automatic Garbage Collection Standard Library Assembly Versioning Properties and Events Delegates and Events Management Easy-to-use Generics Indexers Conditional Compilation Simple Multithreading LINQ and Lambda Expressions Integration with Windows

What is a Constructor in c#?

It is the first method that are called on instantiation of a type. It provides way to set default values for data before the object is available for use. Performs other necessary functions before the object is available for use.

What is linq (Language Integrated Query)

LINQ is a set of extensions to .NET Framework that encapsulate language integrated query, set and other transformation operations. It extends VB, C# with their language syntax for queries. It also provides class libraries which allow a developer to take advantages of these features.

What is an Event in c sharp?

When an action is performed, this action is noticed by the computer application based on which the output is displayed. These actions are called events. Examples of events are pressing of the keys on the keyboard, clicking of the mouse. Likewise, there are a number of events which capture your actions.

What is an Exception in dotNET?

Exceptions are errors that occur during the runtime of a program. The advantage of using exceptions is that the program doesn’t terminate due to the occurrence of the exception. Whenever an exception is occurred the .NET runtime throws an object of specified type of Exception. The class ‘Exception’ is the base class of all the exceptions..

What are generics in C#.NET?

Generic types to maximize code reuse, type safety, and performance. They can be used to create collection classes. Generic collection classes in the System.Collections.Generic namespace should be used instead of classes such as ArrayList in the System.Collections namespace.

What’s the advantage of using System.Text.StringBuilder over System.String?

StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text.  Strings are immutable, so each time it’s being operated on, a new instance is created

What is ACID rule for transactions in Database

Following is the important ACID rule for transactions in relational Database Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions) Transaction must be Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t) Transaction must be Isolated (no transaction sees the intermediate results of the current transaction) Transaction must be Durable (the values persist if the data had been committed even if the system crashes right after)

What is an abstract class in C#

A class that cannot be instantiated. A concept in C++ known as pure virtual method.  A class that must be inherited and have the methods over-ridden.  Essentially, it’s a blueprint for a class without any implementation.