marquee
LATEST DOTNET INTERVIEW QUESTIONS
Wednesday, 27 November 2013
Tuesday, 26 November 2013
Explain what a DiffGram is, and a good use for one?
- Explain what a DiffGram is, and a good use for one?
A DiffGram is an XML format that is used to identify current and original versions of data elements. When sending and retrieving a DataSet from an XML Web service, the DiffGram format is implicitly used.
The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order.
DiffGram Format
The DiffGram format is divided into three sections: the current data, the original (or "before") data, and an errors section, as shown in the following example.
<?xml version="1.0"?>
<diffgr:diffgram
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<DataInstance>
</DataInstance>
<diffgr:before>
</diffgr:before>
<diffgr:errors>
</diffgr:errors>
</diffgr:diffgram>
<diffgr:diffgram
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<DataInstance>
</DataInstance>
<diffgr:before>
</diffgr:before>
<diffgr:errors>
</diffgr:errors>
</diffgr:diffgram>
The DiffGram format consists of the following blocks of
data:
<DataInstance>
The name of this element, DataInstance, is
used for explanation purposes in this documentation. A DataInstance
element represents a DataSet or a row of a DataTable. Instead of DataInstance,
the element would contain the name of the DataSet or DataTable.
This block of the DiffGram format contains the current data, whether it has
been modified or not. An element, or row, that has been modified is identified
with the diffgr:hasChanges annotation.
<diffgr:before>
This block of the DiffGram format contains the original
version of a row. Elements in this block are matched to elements in the DataInstance
block using the diffgr:id annotation.
<diffgr:errors>
This block of the DiffGram format contains error information
for a particular row in the DataInstance block. Elements in this
block are matched to elements in the DataInstance block using the
diffgr:id annotation.
Monday, 25 November 2013
What is the use of sessionstate tag in the web.config file?
What is the use of sessionstate tag in the web.config file?
Configuring session state: Session state features can be configured via the <sessionState> section in a web.config file. To double the default timeout of 20 minutes, you can add the following to the web.config file of an application:
<sessionState timeout="40"/>
What are the different modes for the sessionstates in the web.config file?
What are the different modes for the sessionstates in the
web.config file?
Off
|
Indicates that session state is not enabled.
|
Inproc
|
Indicates that session state is stored locally.
|
StateServer
|
Indicates that session state is stored on a remote server.
|
SQLServer
|
Indicates that session state is stored on the SQL Server.
|
Sunday, 24 November 2013
How to find 6th highest salary
SELECT TOP 1 salary
FROM (SELECT DISTINCT TOP 6 salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
What is Index? It’s purpose?
Indexes in databases are similar to indexes in books. In a database, an index allows the database program to find data in a table without scanning the entire table. An index in a database is a list of values in a table with the storage locations of rows in the table that contain each value. Indexes can be created on either a single column or a combination of columns in a table and are implemented in the form of B-trees. An index contains an entry with one or more columns (the search key) from each row in a table. A B-tree is sorted on the search key, and can be searched efficiently on any leading subset of the search key. For example, an index on columns A, B, C can be searched efficiently on A, on A, B, and A, B, C.
Disadvantage of index?
Every index increases the time in takes to perform INSERTS, UPDATES and DELETES, so the number of indexes should not be very much.
What is sorting and what is the difference between sorting & clustered indexes?
The ORDER BY clause sorts query results by one or more columns up to 8,060 bytes. This will happen by the time when we retrieve data from database. Clustered indexes physically sorting data, while inserting/updating the table.
Difference between char and nvarchar / char and varchar data-type?
-
char[(n)] - Fixed-length non-Unicode character data with length of n
bytes. n must be a value from 1 through 8,000. Storage size is n bytes.
The SQL-92 synonym for char is character.
nvarchar(n) - Variable-length Unicode character data of n characters. n must be a value from 1 through 4,000. Storage size, in bytes, is two times the number of characters entered. The data entered can be 0 characters in length. The SQL-92 synonyms for nvarchar are national char varying and national character varying.
varchar[(n)] - Variable-length non-Unicode character data with length of n bytes. n must be a value from 1 through 8,000. Storage size is the actual length in bytes of the data entered, not n bytes. The data entered can be 0 characters in length. The SQL-92 synonyms for varchar are char varying or character varying.
What are the data types in SQL
bigint
|
Binary
|
bit
|
char
|
cursor
|
datetime
|
Decimal
|
float
|
image
|
int
|
money
|
Nchar
|
ntext
|
nvarchar
|
real
|
smalldatetime
|
Smallint
|
smallmoney
|
text
|
timestamp
|
tinyint
|
Varbinary
|
Varchar
|
uniqueidentifier
|
What is the difference between text and image data type?
Text and image. Use text for character data if you need to store more than 255 characters in SQL Server 6.5, or more than 8000 in SQL Server 7.0. Use image for binary large objects (BLOBs) such as digital images. With text and image data types, the data is not stored in the row, so the limit of the page size does not apply.All that is stored in the row is a pointer to the database pages that contain the data.Individual text, ntext, and image values can be a maximum of 2-GB, which is too long to store in a single data row.
What are the differences between UNION and JOINS?
What are the differences between UNION and JOINS?
A join selects columns from 2 or more tables. A union selects rows.
A join selects columns from 2 or more tables. A union selects rows.
What is self join?
What is self join?
A table can be joined to itself in a self-join
A table can be joined to itself in a self-join
How many types of Joins?
- How many types of Joins?
Joins can be categorized as:
- Inner joins (the typical join
operation, which uses some comparison operator like = or <>). These
include equi-joins and natural joins.
Inner joins use a comparison operator to match rows from two tables based on the values in common columns from each table. For example, retrieving all rows where the student identification number is the same in both the students and courses tables. - Outer joins. Outer joins can
be a left, a right, or full outer join.
Outer joins are specified with one of the following sets of keywords when they are specified in the FROM clause: - LEFT JOIN or LEFT OUTER JOIN -The result set of a left outer join includes all the rows from the left table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When a row in the left table has no matching rows in the right table, the associated result set row contains null values for all select list columns coming from the right table.
- RIGHT JOIN or RIGHT OUTER JOIN - A right outer join is the reverse of a left outer join. All rows from the right table are returned. Null values are returned for the left table any time a right table row has no matching row in the left table.
- FULL JOIN or FULL OUTER JOIN - A full outer join returns all rows in both the left and right tables. Any time a row has no match in the other table, the select list columns from the other table contain null values. When there is a match between the tables, the entire result set row contains data values from the base tables.
- Cross joins - Cross joins return all rows from the left table, each row from the left table is combined with all rows from the right table. Cross joins are also called Cartesian products. (A Cartesian join will get you a Cartesian product. A Cartesian join is when you join every row of one table to every row of another table. You can also get one by joining every row of a table to every row of itself.)
What are joins?
- What are joins?
Sometimes we have to select data from two or more tables to make our result complete. We have to perform a join.
What is serialization?
What is serialization?
Serialization is the
process of converting an object into a stream of bytes. Deserialization is the
opposite process of creating an object from a stream of bytes.
Serialization/Deserialization is mostly used to transport objects (e.g. during
remoting), or to persist objects (e.g. to a file or database).
What is garbage collection?
What is garbage collection?
Garbage collection is a
system whereby a run-time component takes responsibility for managing the
lifetime of objects and the heap memory that they occupy. This concept is not
new to .NET - Java and many other languages/runtimes have used garbage
collection for some time.
singleton and singlecall.
singleton and singlecall.
Singleton types never have more than one instance at any one time. If an instance exists, all client requests are serviced by that instance.
Single Call types always have one instance per client request. The next method invocation will be serviced by a different server instance, even if the previous instance has not yet been recycled by the system
What base class do all Web Forms inherit from
What base class do all Web Forms inherit from?
System.Web.UI.Page
Thursday, 21 November 2013
How do I select 2nd highest salaried employee from my EMPLOYEE table?
How do I select 2nd highest salaried
employee from my EMPLOYEE table?
Ans.
Ans.
SELECT
EMPLOYEE.*,
MAX(EMPLOYEE.Salary) AS SalarySecondHighest
FROM EMPLOYEE
WHERE EMPLOYEE.Salary<
(SELECT
MAX(EMPLOYEE.Salary)
AS SalaryFirstHighest
FROM EMPLOYEE)
|
Which date function is used to find the difference between two dates?
Which date function is used to find
the difference between two dates?
Ans.
SELECT DATEDIFF(dd,'10-10-2010','15-10-2010')
|
OUTPUT: 5
more=>http://msdn.microsoft.com/en-us/library/ms189794.aspx
more=>http://msdn.microsoft.com/en-us/library/ms189794.aspx
Thursday, 14 November 2013
Generics
Generics
Generics
is a new concept in .net 2.0 and this is similar to templates in C++. By using
generics, you can create generic methods and generic classes.
Generic
Methods
A
generic method is a method that can operate on any type of data. For most of the
algorithms, logic is same whatever the type of data is. Hence instead of
creating one method for every data type, you can create only one method that can
accept any type of arguments, which is called as generic method. To create a
method as generic method, syntax is as follows.
[Access
Modifier] returntype MethodName<GenericTypes>([Parameters])
{
}
After
creating a generic method, to call the generic method syntax is as follows.
MethodName<DataType>([Arguments])
Example : The
following example creates a method Swap() as a generic method that can swap two
values that can be of any type.
namespace Generics
{
class
Program
{
public
static void
Swap<MyType>(ref MyType X, ref MyType Y)
{
MyType T;
T = X;
X = Y;
Y = T;
}
static
void Main(string[]
args)
{
int
A = 10, B = 20;
float
F1 = 3.5F, F2 = 5.5F;
string
S1 = "Naresh", S2 = "Microsoft";
Swap<int>(ref A, ref B);
Swap<float>(ref F1, ref F2);
Swap<string>(ref S1, ref S2);
Console.WriteLine("After Swap ...");
Console.WriteLine("A = {0}\tB = {1}", A, B);
Console.WriteLine("F1 = {0}\tF2 = {1}", F1, F2);
Console.WriteLine("S1 = {0}\tS2 = {1}", S1, S2);
}
}
}
Constraints
On Generic Types
A
generic type by default can accept any type of data. But there are some
situations where you have to restrict your generic type to accept only certain
types and for this you have to specify constraints on generic types. To specify
constraints on generic types, you have to use the keyword where at the end of the method declaration as follows
[Access Modifier] returntype
MethodName<GT>([Parameters]) where GT : constraints
{
}
You
can specify the following constraints on generics.
- Struct : this makes the generic type accept only value types.
- Class : this makes the generic type accept only reference types.
- <classname> : this makes the generic type accept only that particular class and its derived classes.
- <interfacename> : this makes the generic type accept only the types that implement that interface.
- You can specify multiple constraints on generic types by separating them with comma(,). But combination of constraints like struct and class are not allowed as there is no type in .net that is both value type and reference type.
Example : The
following example creates a method Sort() as generic method that can sort any
type of array.
namespace Generics
{
class
GenSort
{
public
static void
Sort<MyType>(params MyType[] A) where MyType : IComparable
{
MyType T;
for
(int i = 0; i < A.GetLength(0); i++)
{
for (int j = i + 1; j
< A.GetLength(0); j++)
{
if (A[i].CompareTo(A[j]) > 0)
{
T = A[i];
A[i] = A[j];
A[j] = T;
}
}
}
}
static
void Main()
{
int[]
A = { 23, 9, 17, 12, 3 };
float[]
F = { 27.32F, 56.66F, 32.21F, 17.76F, 21.21F };
string[]
S = { "Microsoft", "Sun", "Oracle",
"Adobe", "Ibm"
};
Sort<int>(A);
Sort<float>(F);
Sort<string>(S);
Console.WriteLine("After Sort Values In Arrays Are...");
foreach
(int n in A)
{
Console.Write("{0}\t",
n);
}
Console.WriteLine();
foreach
(float n in F)
{
Console.Write("{0}\t",
n);
}
Console.WriteLine();
foreach
(string n in S)
{
Console.WriteLine(n);
}
}
}
}
Multiple
Generic Types
There
may be a situation where you have to take more than one parameter for a generic
method that are of different type. In this case generic method can be created
with more than one generic type. Syntax is as follows.
[Access Modifier] returntype
MethodName<GT1,GT2,…>([Parameters])
{
}
After
creating a generic method with multiple generic types, to call the generic
method syntax is as follows.
MethodName<DataType1,DataType2,…>([Arguments])
Example : The
following example creates a method with the name Print() as a generic method
that accepts two parameters of two different types.
namespace Generics
{
class
MultiGen
{
public
static void
Print<MyType1, MyType2>(MyType1 X, MyType2 Y)
{
Console.WriteLine("X = {0}\tY = {1}", X, Y);
}
static
void Main()
{
Print<int, float>(10,
14.5F);
Print<float, string>(23.34F,
"Naresh");
Print<string, string>("Microsoft", "Naresh");
}
}
}
Generic
Methods With Parameters of Standard types
When
the method is declared as generic method then it is not compulsory that every
parameter of that method must be of generic type. A generic method can have the
parameters of standard type and for these parameters you must pass only that
particular type of arguments.
Example : the
following example creates a method with the name “Print” as a generic method
that takes one generic type parameter and one int parameter.
namespace Generics
{
class StandardTypes
{
static void
Print<MyType>(MyType X, int N)
{
for (int i = 0; i <
N; i++)
{
Console.Write("{0}\t", X);
}
Console.WriteLine();
}
static void Main()
{
Print<int>(3, 5);
Print<string>("*", 5);
Print<double>(5.7,
3);
}
}
}
Generic
Classes
Not
only methods, classes can also be created as generic classes. A generic class
is a class whose instances each can work on a different type of data. For
creating a class as generic class syntax is as follows.
[Access Modifier] class classname<generictypes>
{
}
After
creating generic class, to create an instance for the generic class, syntax is
as follows.
Classname<Datatypes>
ObjName = new classname<datatypes>();
Example : The
following example creates a class with the name Test as generic class
namespace Generics
{
class
Test<MyType>
{
MyType A, B;
public
Test(MyType X, MyType Y)
{
A = X;
B = Y;
}
public
void Print()
{
Console.WriteLine("A = {0}\tB = {1}", A, B);
}
}
class
GenricClass
{
static
void Main()
{
Test<int> T1 = new Test<int>(10,
20);
Test<float> T2 = new Test<float>(3.5F,
4.5F);
Test<string> T3 = new Test<string>("C#.Net", "VB.Net");
T1.Print();
T2.Print();
T3.Print();
}
}
}
You
can specify constraints on generic types in generic classes also and for this
purpose syntax is as follows.
[Access Modifier] class classname<GT> where GT : constraints
{
}
A
generic class can also be created with more than one generic type same as a generic
method and has the following syntax.
[Access Modifier] class classname<GT1,GT2,…>
{
}
When
a generic class is created with more than one generic type then an instance is
created for that class as follows.
Classname<DT1,DT2,…> Objname
= new classname<DT1,DT2,…>();
Subscribe to:
Posts (Atom)
Popular Posts
-
ASP.NET QUESTIONS 1) On which of the operating system below ASP.NET can run? a) Windows XP Professional ...
-
T-SQL Queries 2 tables Employee Phone empid empname salary mgrid empid phnumber Select all employees...
-
76) Select the control which does not have any visible interface a) Datalist b) DropdownList ...
-
1. What is a Web service ? How it is different from remoting? 2. Diiferent life cycle events phases in asp.net web form. 3. OOPS conc...
-
56) Which of the following is true ? a) IsPostBack is a method of System.UI.Web.Page class b) IsPostBa...
-
Interview Questions .NET Windows Forms 1) Write a simple Windows Forms MessageBox statement? 2) Can you write a class witho...
-
126) Which of the following denote ways to manage state in an ASP.Net Application? a) Session objects b)...
-
Asp.net Page Life cycle This is a transcript of a programming manual, to refresh my memory, and it’s always good to RTFM. As a contro...
-
1. What is caching.? 2. Types of cahing? 3. What is cache Block? 4. What are indexers? 5. What is difference between Namespace and assembl...
-
21) To set page title dynamically in ASP.NET which of the following is used ? a) None of the above b) ...