Get Paid By Click

Mginger Mobile Money

Jul 27, 2010

SQL SERVER Interview Questions and answers


Which is the true with View:
     a Hide data complexity
     b Organise data From Hetrogenious sources
     c Reduce Object Size
     d Usuful for Combine multiple logical table
     e All are True
Ans:a
Which one is true with View:
     a It is a permanet table
     b It is a temporaray table
     c It Is a logical table 
     d It is a physical table
Which Type of Parameter is not found in Stored Procedure?
     a Input
     b Output
     c Ref 
     d All
Temporary stored Procedure Is found in :
     a Master Database
     b Model Database
     c Msdb Database
     d Temp Database 
Which two are the fundamental object of ADO.Net?
     a Dataset ,Dataadapter
     b DataReader ,DataSet
     c DataAdapter ,DataTable
     d DataSet ,DataReader 
select correct option-the .Net namespaces with the data functionality classes?
     a System.Data
     b System.Data.OleDB
     c System.XML
     d All 
Which isolation level is used for COM+ object?
     a READ COMMITTED
     b READ UNCOMMITTED
     c SERIALIZABLE 
     d None
What is full form of T-SQL?
     a Transfer-SQL
     b Transaction-SQL
     c Transact-SQL 
     d None
What is the full form of KPI?
     a Key Procedure Indicators
     b Key Process Indicators
     c Key Performance Indicators 
What are the various lock types ?
     a Shared
     b update
     c exclusive
     d all 
Ans:d
What is the use of CHAR function?
     a Convert numeric to char type 
     b Convert char to numeric type
     c convert char to char
     d none
Can we create Web service in SQL Server 2005?
we can create web service in sql server 2005 by using an HTTP EndPoint
     a No
     b Yes 
     c May be yes
What is the result of "SELECT 2/2/4" in SQL ? 
     a  0.25
     b  0.5
     c  4
     d  0 
How we can check the database permission for any user?
    a SELECT * FROM fn_my_permissions (null, 'DATA');
    b SELECT * FROM fn_my_permissions (null, 'Table
    c SELECT * FROM fn_my_permissions ('DATABASE');
    d SELECT * FROM fn_my_permissions (null, 'DATABASE'); 
Can we restore the database forcefully when it is in use via SQL script?
    a No
    b Yes 
    c I dont know
How Many maximum parameter can be used with per stored procedure ?
   a 1024
   b 1096
   c 2100 
   d Can not say
How many maximum columns can be used with per select
    a Unlimited
    b 32
    c 4096 
    d 1024
    e 64
Is this statement true or false:
A cursor is a pointer that identifies a specific working row within a set
     a False
     b True 
     c May be False
Which one of the following must be specified in every DELETE statement?
     a set
     b where
     c Inner join
     d Table Name 
Which of the following is not a valid datatype in SQL Server?
    a varchar
    b datetime
    c char
    d vartext 
What Will be Output
If we execute the following query then what will be output??
SELECT * FROM EMPLOYEE_MAST WHERE 1=2
    a It will Display All the Records
    b It will Display All the Columns
    c It will Display Only Stucture 
    d It will Display 2nd Record
Which one is not true with stored Procedure?
     a Pre Compiled Code
     b Reduced Client Server Traffic
     c Implenet reusebility
     d Enhance Security
     e Support SQL Injection   
A trigger can be nested up to
     a 12 Level
     b 24 Level
     c 32 Level 
     d 44 Level
What is the page size in SQL Server?
    a 8954 
    b 4005
    c 2000
    d 8192
SELECT * FROM EMPLOYEE_MAST WHERE 1 =1
   a It will display 1st record
   b It will display 1st Column
   c It will display All Records 
   d It Will display No Records
What happen when if SET NO-COUNT ON
    a It will Show number of effected row. after query execution
    b it Will Count number of effected row. after query execution
    c it Will not Count number of effected row. after query execution
   d It will not Show number of effected row. after query execution
Write a query to find the total number of rows in a table?
   select count(*) from employee
What is the difference between IN and BETWEEN, that are used inside a WHERE clause?
  The BETWEEN clause is used to fetch a range of values, whereas the IN clause fetches data   from a list of specified values.
Write a query to eliminate duplicate records in the results of a table
 select distinct * from  employee
Write a query to insert a record into a table
insert into emp values ('ramu','22445')
Write a query to delete a record from a table
delete from emp where name='ramu.
Write a query to fetch the highest record in a table, based on a record, say salary field in the t_salary table
Select max(salary) from t_salary;
Diff b/w function and sp?
Primarily, the main difference between a Stored Procedure and a Function in SQL is that a Function has the ability to return a value to the calling routine, where as a Stored Procedure may or may not return a value, depending on how it is programmed. A Function should have a minimum of one return type.
Also, the results of a function may be assigned to a Select statement; this isn't possible with Stored Procs.
Write a query to concatenate two fields, say Designation and Department belonging to a table t_employee
Ans: Select Designation + ‘ ‘ + Department from t_employee;
What is the difference between UNION and UNION ALL in SQL?
Ans - UNION is an SQL keyword used to merge the results of two or more tables using a Select statement, containing the same fields, with removed duplicate values. UNION ALL does the same, however it persists duplicate values.
What is the difference between IN and BETWEEN, that are used inside a WHERE clause?
Ans - The BETWEEN clause is used to fetch a range of values, whereas the IN clause fetches data from a list of specified values.
What is the difference between where clause and having clause?
Ans:
The difference is that WHERE operates on individual rows, while HAVING operates on groups.
You can have WHERE without HAVING, you can have HAVING without WHERE, you can have both WHERE and HAVING, and you can have neither WHERE nor HAVING. But you can't have HAVING without grouping, even if the group consists of the entire result set.
diff b/w OrderBy and groupby
Ans:
Order by :just sorts a column data.
Group by : Groups it by similar data. Used for aggregation. Order by could be used inside the Grouped Items
 In a table t_employee, the department column is nullable. Write a query to fetch employees which are not assigned a department yet.
Ans.  Select empid, firstname, lastname from t_employee where department is null;
 What are the large objects supported in MS SQL?
Ans:  the data types are image and varbinary.
Whats the capacity of the image data type in MS SQL?
Ans - Variable-length binary data with a maximum length of 2^31 - 1 (2,147,483,647) bytes.
 Whats the capacity of varbinary data type in MS SQL?
Ans - Variable-length binary data with a maximum length of 8,000 bytes.
 What’s the difference between a primary key and a unique key?
 Both Primary key and Unique key enforce the uniqueness of a column on which they are defined. However, a Primary key does not allow nulls, whereas unique key allow nulls.
Outer Join - In an Outer join, each record of a table does not really need to match with a record in the corresponding table. Outer joins maybe Left Outer Joins or Right Outher Joins. Outer Joins are always explicit.
Left Outer Join - This join contains all records from the left table, and matching records in the other table. However, if there are no matching records in the other table, it will still return a result, where in the records of the other table will be NULL.
Right Outer Join - This join fetches all records from the right table and only matching records from the left table. By saying left table, it means the table who's name is to the left of the Join Clause.
Full Outer Join - A full outer join merges the result fetched from Left and Right Outer joins
Cross Join - Also called Cartesian Join. It is the result of joining each row of a table with each row of the other table.
Inner Join - in this type of join, every record in the tables being joined have a matching record. The condition based on which the records are matched is called the join predicate.
What is a Self join?
Ans - A join created by joining two or more instances of a same table.
Query:  Select A.firstname , B.firstname
from t_employee A, t_employee B
where A.supervisor_id = B.employee_id;
How to create a table in SQL? How to set a default value for a column?
create table emp(id int primary key,name varchar(20),city varchar(10) default '123')
what is DDL?
In SQL, DDL stands for Data Definition Language. It is the part of SQL programming language that deals with the construction and alteration of database structures like tables, views, and further the entities inside these tables like columns. It may be used to set the properties of columns as well.
The three popular commands used in DDL are:
Create - Used to create tables, views, and also used to create functions, stored procedures, triggers, indexes etc.
Drop - Used to totally eliminate a table, view, index from a database - which means that the records as well as the total structure is eliminated from the database.
DROP TABLE t_students;
Alter - Used to alter or in other words, change the structure of a table, view, index. This is particularly used when there is a scenario wherein the properties of fields inside a table, view, index are supposed to be updated.
DML - stands for Data Manipulation Language, its the part of SQL that deals with querying, updating, deleting and inseting records in tables, views.
insert,delete,select,update
what is Schema?
The relationships between different tables in a database are often referred to as Database Schema.
What are ACID Rules of transaction in a database? Atomicity, Consistency, Isolation, Durability
The ACID rules of transaction in any database assure the reliability of data in all transactions in the database.
Atomicity - this rule states that either the complete transaction takes place, or none. Even if a part of a transaction fails to work, the complete transaction will fail.
Consistency - this rule ensures that the database is stable, before and after the transaction, even if a transaction fails.
Isolation - this rule states that when a process is going on in a transaction, the data remains in isolation of other entities in the database.
Durability - this rule states that when a transaction completes successfully, it remains in stable state and is persisted in the database.
What is a NULL entity in SQL?
Null is an entity in SQL that is used to specify that a value does not exist. It is a reserved keyword in SQL.
Most SQL languages use the expression IS NULL in the where clause for matching records with NULL values, instead of comparing with NULL using an equality operator. See code example below:
SELECT FIRSTNAME FROM T_STUDENTS WHERE LASTNAME IS NULL;
Following functions handle Null values:
Coalesce - This function returns the first non NULL value from a list of values.
NullIf - This function accepts 2 paramaters. If both parameters are equal, NULL is returned, else the first paramater's value is returned.
What is the difference between a Table, View and Synonym in SQL?
A Table is a repository of data, where in the table itself is a physical entity. The table resides physically in the database.
A View is not a part of the database's physical representation. It is precompiled, so that data retrieval behaves faster, and also provide a secure accessibility mechanism.
The advantages of using a view are as follows:
- It may access data from a table, multiple tables, view, multiple views, or a combination of these
- A view connects to the data of its base table(s).
- Provides a secure mechanism of data accessibility
Synonym is alternate name assigned to a table, view, sequence or program unit.
- It may be used to shadow the original name and owner of the actual entity
- Extends the reach of tables, by allowing public access to the synonym

SQL KEYWORDS
 ORDER BY
  • used to sort the result-set by a specified column.
  • sort the records in ascending order by default.
  • If you want to sort the records in a descending order, you can use the DESC keyword.
Syntax
SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DESC
 TOP
·        The TOP clause is used to specify the number of records to return.
Syntax
SELECT  TOP number|percent column_name(s) FROM table_name
SELECT  TOP 2 * FROM Persons
SELECT  TOP 50 PERCENT * FROM Persons
LIKE
·        The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
Syntax
SELECT column_name(s) FROM table_name WHERE column_name LIKE pattern
SELECT * FROM Persons WHERE City LIKE 's%'
SQL Wildcards
·        SQL wildcards can substitute for one or more characters when searching for data in a database.
·        SQL wildcards must be used with the SQL LIKE operator.
With SQL, the following wildcards can be used:
The IN Operator
  • The IN operator allows you to specify multiple values in a WHERE clause.
Syntax
SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...)
The BETWEEN Operator
  • selects a range of data between two values. The values can be numbers, text, or dates.
Syntax
SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2
SQL Alias
  • You can give a table or a column another name by using an alias. This can be a good thing to do if you have very long or complex table names or column names.
  • An alias name could be anything, but usually it is short.
SQL Alias Syntax for Table
SELECT column_name(s) FROM table_name AS alias_name
SQL Alias Syntax for Columns
SELECT column_name AS alias_name FROM table_name
SQL Constraints
  • Constraints are used to limit the type of data that can go into a table.
  • Constraints can be specified when a table is created (with the CREATE TABLE statement) or after the table is created (with the ALTER TABLE statement).
constraints:
     NOT NULL
     UNIQUE
    PRIMARY KEY
     FOREIGN KEY
     CHECK
     DEFAULT
NOT NULL
The NOT NULL constraint enforces a column to NOT accept NULL values.
The following SQL enforces the "P_Id" column and the "LastName" column to not accept NULL values:
UNIQUE
The UNIQUE constraint uniquely identifies each record in a database table.
 PRIMARY KEY
  • The PRIMARY KEY constraint uniquely identifies each record in a database table.
  • Primary keys must contain unique values.
  • A primary key column cannot contain NULL values.
  • Each table should have a primary key, and each table can have only ONE primary key.
CREATE TABLE Persons
(
P_Id int NOT NULL PRIMARY KEY,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)
FOREIGN KEY
  • A FOREIGN KEY in one table points to a PRIMARY KEY in another table.
  • The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables.
  • The FOREIGN KEY constraint also prevents that invalid data form being inserted into the foreign key column, because it has to be one of the values contained in the table it points to.
  Check
  • The CHECK constraint is used to limit the value range that can be placed in a column.
  • If you define a CHECK constraint on a single column it allows only certain values for this column.
DEFAULT
  • The DEFAULT constraint is used to insert a default value into a column.
  • The default value will be added to all new records, if no other value is specified.
Index
  • The CREATE INDEX statement is used to create indexes in tables.
  • Indexes allow the database application to find data fast; without reading the whole table.
  • An index can be created in a table to find data more quickly and efficiently.
  • The users cannot see the indexes, they are just used to speed up searches/queries.
  • Updating a table with indexes takes more time than updating a table without (because the indexes also need an update). So you should only create indexes on columns (and tables) that will be frequently searched against.
Syntax
Creates an index on a table. Duplicate values are allowed:
CREATE INDEX index_name
ON table_name (column_name)
SQL CREATE UNIQUE INDEX Syntax
Creates a unique index on a table. Duplicate values are not allowed:CREATE UNIQUE INDEX index_name
ON table_name (column_name)
DROP
Indexes, tables, and databases can easily be deleted/removed with the DROP statement.
ALTER
  • The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
To add a column in a table
ALTER TABLE table_name
ADD column_name datatype
To delete a column in a table
ALTER TABLE table_name
DROP COLUMN column_name
To change the data type of a column in a table
ALTER TABLE table_name
ALTER COLUMN column_name datatype
AUTO-INCREMENT
  • allows a unique number to be generated when a new record is inserted into a table.
  • the primary key field to be created automatically every time a new record is inserted.
  • The MS SQL Server uses the IDENTITY keyword to perform an auto-increment feature.
  • By default, the starting value for IDENTITY is 1, and it will increment by 1 for each new record 
 VIEW
·        An Index is a data structure that is created to improve the performance of the data fetch operations on a table
·        A view is similar to a table but may contain data from one or more tables connected to one another through a business logic. A view can be created to implement business logic or to conceal the underlying table implementation from everyone
·        view is a virtual table based on the result-set of an SQL statement.
Date  functions
GETDATE()
returns the current date and time from the SQL Server.
Example:
SELECT GETDATE() AS CurrentDateTime
      DATEPART()
      to return a single part of a date/time, such as year, month, day, hour, minute, etc.
      Syntax
      DATEPART(datepart,date)
 Where date is a valid date expression and datepart can be one of the following:
DATEADD()
 adds or subtracts a specified time interval from a date.
Syntax:
DATEADD(datepart,number,date)
Where date is a valid date expression and number is the number of interval you want to add. The     number can either be positive, for dates in the future, or negative, for dates in the past.
DATEDIFF()
returns the time between two dates.
CONVERT
The CONVERT() function can be used to display date/time data in different formats.
Syntax:
CONVERT(data_type(length),data_to_be_converted,style)
Where data_type(length) specifies the target data type (with an optional length), data_to_be_converted contains the value to be converted, and style specifies the output format for the date/time.




What is heap table in SQL SERVER ?
A table that doesnot contains cluster and non cluster index is heap table because there is no indexing there on to the table.

What is SQL Cache Dependency in ASP.NET 2.0?
Answer:
SQL cache dependencies is new technique in ASP.NET 2.0 which can automatically invalidate a cached data object just like a Dataset. when the related data is modified in the database. So for instance if you have a dataset which is tied up to a database tables any changes in the database table will invalidate the cached data object which can be a dataset or a data source.To enable this we need a syntax that is as follows:- aspnet_regsql -ed -E -d Northwind

How many kind of User-Defined Functions can be created in Sql Server-2000 ?
Answer: There are three types of User-Defined functions in SQL Server 2000 and they are Scalar, Inline Table-Valued and Multi-statement Table-valued.A Scalar user-defined function returns one of the scalar data types.An Inline Table-Value user-defined function returns a table data type.A Multi-Statement Table-Value user-defined function returns a table.

How many types of local tables in SQL SERVER ?
Answer:
There are 2 types of temporary tables, local and global. Local temporary tables are created using a single pound (#) sign and are visible to a single connection and automatically dropped when that connection ends. Global temporary tables are created using a double pound (##) sign and are visible across multiple connections and users and are automatically dropped when all SQL sessions stop referencing the global temporary table.

How to load .NET code in SQL SERVER 2005 ?
Answer:
First of all write managed code and compile it to DLL/Assembly.Now we can load the assembly in SQL SERVER.Here i have given a example of SQL SERVER. CREATE ASSEMBLY percode FROM 'c:/percode.dll'

Where .NET CLR and SQL SERVER run ?
Answer:
All .net realtes application and Sql Server runs in same process or we can say that on same address because there is no issue of speed because if these two process are run in different process then there may be a speed issue created one process goes fast and other slow may create the problem.

What are Checkpoint in SQL Server ?


Answer:
When we done operation on SQL SERVER that is not commited directly to the database.All operation must be logged in to Transaction Log files after that they should be done on to the main database.CheckPoint are the point which alert Sql Server to save all the data to main database if no check point is there then log files get full we can use Checkpoint command to commit all data in the SQL SERVER.When we stop the SQL Server it will take long time because Checkpoint is also fired.

Can You explain integration between SQL Server 2005 and Visual Studio 2005 ?
Answer:
This intergration provide wider range of development with the help of CLR for database server.Becasue CLR helps developers to get flexibility for developing database applications and also provides language interoperability just like Visual C++, Visual Basic .Net and Visual C# .Net. The CLR helps developers to get the arrays, classes and exception handling available through programming languages such as Visual C++ or Visual C# which is use in stored procedures, functions and triggers for creating database application dynamically and also provide more efficient reuse of code and faster execution of complex tasks. We particularly liked the error-checking powers of the CLR environment, which reduces run-time errors

What is the diffrence between SQL and Pl/Sql ?
Answer:
We can get modify, Retrieve by single command or statement in SQL but PL/SQL process all SQL statements one at a time. With PL/SQL, an entire block of statements process in a single command line.sql is structured query language ,various queries are used to handle the database in a simplified manner. while pl/sql is procedural language contains various types of variable,functions and procedures and other major diffrence is Sql as the name suggest it is just structured query language wheareas PLSQL is a commbination of Programming language & SQL.

What is DTS in SQL Server ?
Answer:
If a organization is big then it is also there that there is multiple option to store data some people are using EXCEL some are using ACCESS and some of they are using SQL SERVER and in some other format also but there a problem is arise that how to merge that data into one format there is diffrent tool are there for doing this funtion. One of product of SQL SERVER-2000 DTS helps in this problem it provides a set of tool from that tool we can customise are database acording to our need DTSRun is a command-prompt utility used to execute existing DTS packages.

What is the difference between UNION ALL Statement and UNION ?
Answer:-
The main difference between UNION ALL statement and UNION is UNION All statement is much faster than UNION,the reason behind this is that because UNION ALL statement does not look for duplicate rows, but on the other hand UNION statement does look for duplicate rows, whether or not they exist.

Write some disadvantage of Cursor ?
Answer:-
Cursor plays there row quite nicely but although there are some disadvantage of Cursor .
Because we know cursor doing roundtrip it will make network line busy and also make time consuming methods. First of all select query gernate output and after that cursor goes one by one so roundtrip happen.Another disadvange of cursor are ther are too costly because they require lot of resources and temporary storage so network is quite busy.

What is Log Shipping and its purpose ?
Answer:
In Log Shipping the transactional log file from one server is automatically updated in backup database on the other server and in the case when one server fails the other server will have the same DB and we can use this as the DDR(disaster recovery) plan.

What are the null values in SQL SERVER ?
Answer:
Before understand the null values we have some overview about what the value is. Value is the actual data stored in a particular field of particular record. But what is done when there is no values in the field.That value is something like .Nulls present missing information. We can also called null propagation.

What is difference between OSQL and Query Analyzer ?
Answer:
Both are same for functioning but there is a little difference OSQL is command line tool which execute query and display the result same a Query Analyzer do but Query Analyzer is graphical.OSQL have not ability like Query Analyzer to analyze queries and show statistics on speed of execution .And other useful thing about OSQL is that its helps in scheduling which is done in Query Analyzer with the help of JOB.

SQL SERVER Query
Write a Role of Sql Server 2005 in XML Web Services? 
Answer:
- SQL Server 2005 create a standard method for getting the database engine using SOAP via HTTP. By this method, we can send SOAP/HTTP requests to SQL Server for executing T-SQL batch statements, stored procedures, extended stored procedures, and scalar-valued user-defined functions may be with or without parameters.

What are the different types of Locks ?
Answer:
There are three main types of locks that SQL Server
(1)Shared locks are used for operations that does not allow to change or update data, such as a SELECT statement.
(2)Update locks are used when SQL Server intends to modify a page, and later promotes the update page lock to an exclusive page lock before actually making the changes.
(3)Exclusive locks are used for the data modification operations, such as UPDATE, INSERT, or DELETE.

 Explain some SQL Server 2000 Query? 
Answer: Here are some sql server 2000 query like Sql Insert Query, Delete Sql Query, Update Sql Query and Sql Create Query:
1) Sql Insert Query:
a) How to encrypt data by using Sql Insert Query.
--: insert into table_name(Tablecolumn1, tablecolumn2,. . . . .) values ('value1', pwdencrypt('value'),. . . .)
b) How to copy data from one table to another with the help of Sql Insert Query.
--: insert into table_name(column1,column2,. . . . ) select column1, column2, . . . . from table_name2
c) Sql Insert Query using where clause
--: insert into tablename(column1,column2) select column1,column2 from tablename2 where id=value.

 
 What is 'Write-ahead log' in Sql Server 2000 ?
Answer: Before
understanding it we must have an idea about the transaction log files. These files are the files which holds the data for change in database .
Now we explain when we are doing some Sql Server 2000 query or any Sql query like Sql insert query,delete sql query,update sql query and change the data in sql server database it cannot change the database directly to table .Sql server extracts the data that is modified by sql server 2000 query or by sql query and places it in memory.Once data is stores in memory user can make changes to that a log file is gernated this log file is gernated in every five mintues of transaction is done. After this sql server writes changes to database with the help of transaction log files. This is called Write-ahead log.

 
What do u mean by Extents and types of Extends ?
Answer:
An Extent is a collection of 8 sequential pages to hold database from becoming fregmented. Fragment means these pages relates to same table of database these also holds in indexing. To avoid for fragmentation Sql Server assign space to table in extents. So that the Sql Server keep upto date data in extents. Because these pages are continously one after another. There are usually two types of extends:-Uniform and Mixed.
Uniform means when extent is own by a single object means all collection of 8 ages hold by a single extend is called uniform.
Mixed mean when more then one object is comes in extents is known as mixed extents.

 
What is different in Rules and Constraints ?
Answer:
Rules and Constraints are similar in functionality but there is a An little diffrence between them.Rules are used for backward compatibility . One the most exclusive diffrence is that we an bind rules to a datatypes whereas constraints are bound only to columns.So we can create our own datatype with the help of Rules and get the input according to that.

What is defaults in Sql Server and types of Defaults ?
Answer:
Defaults are used when a field of columns is allmost common for all the rows for example in employee table all living in delhi that value of this field is common for all the row in the table if we set this field as default the value that is not fill by us automatically fills the value in the field its also work as intellisense means when user inputing d it will automatically fill the delhi . There are two types of defaults object and definations.
Object deault:-These defaults are applicable on a particular columns . These are usually deined at the time of table designing.When u set the object default field in column state this column in automatically field when u left this filed blank.
Defination default:-When we bind the datatype with default let we named this as dotnet .Then every time we create column and named its datatype as dotnet it will behave the same that we set for dotnet datatype.


What Is Database ?
Answer:
A database is similar to a data file in that it is a storage place for data. Like a data file, a database does not present information directly to a user; the user runs an application that accesses data from the database and presents it to the user in an understandable format.Database systems are more powerful than data files in that data is more highly organized. In a well-designed database, there are no duplicate pieces of data that the user or application must update at the same time. Related pieces of data are grouped together in a single structure or record, and relationships can be defined between these structures and records.When working with data files, an application must be coded to work with the specific structure of each data file. In contrast, a database contains a catalog that applications use to determine how data is organized. Generic database applications can use the catalog to present users with data from different databases dynamically, without being tied to a specific data format. A database typically has two main parts: first, the files holding the physical database and second, the database management system (DBMS) software that applications use to access data. The DBMS is responsible for enforcing the database structure, including: · Maintaining relationships between data in the database. Ensuring that data is stored correctly, and that the rules defining data relationships are not violated. · Recovering all data to a point of known consistency in case of system failures.

what is Relational Database ?
Answer: Although there are different ways to organize data in a database, relational databases are one of the most effective. Relational database systems are an application of mathematical set theory to the problem of effectively organizing data. In a relational database, data is collected into tables (called relations in relational theory). A table represents some class of objects that are important to an organization. For example, a company may have a database with a table for employees, another table for customers, and another for stores. Each table is built of columns and rows (called attributes and tuples in relational theory). Each column represents some attribute of the object represented by the table. For example, an Employee table would typically have columns for attributes such as first name, last name, employee ID, department, pay grade, and job title. Each row represents an instance of the object represented by the table. For example, one row in the Employee table represents the employee who has employee ID 12345. When organizing data into tables, you can usually find many different ways to define tables. Relational database theory defines a process called normalization, which ensures that the set of tables you define will organize your data effectively.

What is COMMIT & ROLLBACK statement in SQL ?
Answer: Commit statement helps in termination of the current transaction and do all the changes that occur in transaction persistent and this also commits all the changes to the database.COMMIT we can also use in store procedure.
ROLLBACK do the same thing just terminate the currenct transaction but one another thing is that the changes made to database are ROLLBACK to the database.

What is diffrence between OSQL and Query Analyzer ? 
Answer:-Both are the same but ther eis little diffrence OSQL is command line tool whic is execute qery and display the result same a query analyzer but query analyzer is graphical and OSQL is a command line tool.OSQL have not ability like query analyzer to analyze queries and show statics on speed of execution and other usefull thing about OSQL is that its helps in scheduling.


 
What is Data Integrity and it's categories ?
Answer:
Enforcing data integrity ensures the quality of the data in the database. For example, if an employee is entered with an employee_id value of 123, the database should not allow another employee to have an ID with the same value. If you have an employee_rating column intended to have values ranging from 1 to 5, the database should not accept a value of 6. If the table has a dept_id column that stores the department number for the employee, the database should allow only values that are valid for the department numbers in the company. Two important steps in planning tables are to identify valid values for a column and to decide how to enforce the integrity of the data in the column. Data integrity falls into these categories:
1) Entity integrity
2) Domain integrity
3) Referential integrity
4) User-defined integrity

Entity Integrity: Entity integrity defines a row as a unique entity for a particular table. Entity integrity enforces the integrity of the identifier column(s) or the primary key of a table (through indexes, UNIQUE constraints, PRIMARY KEY constraints, or IDENTITY properties).
Domain Integrity: Domain integrity is the validity of entries for a given column. You can enforce domain integrity by restricting the type (through data types), the format (through CHECK constraints and rules), or the range of possible values (through FOREIGN KEY constraints, CHECK constraints, DEFAULT efinitions, NOT NULL definitions, and rules).
Referential Integrity: Referential integrity preserves the defined relationships between tables when records are entered or deleted. In Microsoft® SQL Server™ 2000, referential integrity is based on relationships between foreign keys and primary keys or between foreign keys and unique keys (through FOREIGN KEY and CHECK constraints). Referential integrity ensures that key values are consistent across tables. Such consistency requires that there be no references to nonexistent values and that if a key value changes, all references to it change consistently throughout the database. When you enforce referential integrity, SQL Server prevents users from:
· Adding records to a related table if there is no associated record in the primary table.
· Changing values in a primary table that result in orphaned records in a related table.
· Deleting records from a primary table if there are matching related records.
For example, with the sales and titles tables in the pubs database, referential integrity is based on the relationship between the foreign key (title_id) in the sales table and the primary key (title_id) in the titles table.
User-Defined: Integrity User-defined integrity allows you to define specific business rules that do not fall into one of the other integrity categories. All of the integrity categories support user-defined integrity (all column- and table-level constraints in CREATE TABLE, stored procedures, and triggers).


 What is the use of DBCC commands?
Answer:
DBCC stands for database consistency checker. We use these commands to check the consistency of the databases, i.e., maintenance, validation task and status checks.DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC CHECKALLOC To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any damage.


When do you use SQL Profiler?
Answer:
SQL Profiler utility allows us to basically track Connections to the SQL Server and also determine activities such as which SQL Scripts are running, failed jobs etc.

Can you explain the role of each service?
Answer:
SQL SERVER - is for running the databases SQL AGENT - is for automation such as Jobs, DB Maintenance, Backups DTC - Is for linking and connecting to other SQL Servers.

What is Normalization ?
Answer:
The logical design of the database, including the tables and the relationships between them, is the core of an optimized relational database. A good logical database design can lay the foundation for optimal database and application performance. A poor logical database design can impair the performance of the entire system.
Normalizing a logical database design involves using formal methods to separate the data into multiple, related tables. A greater number of narrow tables (with fewer columns) is characteristic of a normalized database. A few wide tables (with more columns) is characteristic of an nonnomalized database. Reasonable normalization often improves performance. When useful indexes are available, the Microsoft® SQL Server™ 2000 query optimizer is efficient at selecting rapid, efficient joins between tables.

Some of the benefits of normalization include:
     ·Faster sorting and index creation.
     ·A larger number of clustered indexes. For more information, Narrower and more compact indexes. 
     ·Fewer indexes per table, which improves the performance of INSERT, UPDATE, and DELETE                     statements.
     ·Fewer null values and less opportunity for inconsistency, which increase database compactness. 

As normalization increases, so do the number and complexity of joins required to retrieve data. Too many complex relational joins between too many tables can hinder performance. Reasonable normalization often includes few regularly executed queries that use joins involving more than four tables.
Sometimes the logical database design is already fixed and total redesign is not feasible. Even then, however, it might be possible to normalize a large table selectively into several smaller tables. If the database is accessed through stored procedures, this schema change could take place without affecting applications. If not, it might be possible to create a view that hides the schema change from the applications.


Can you explain what View is in SQL ?
Answer:
View is just a virtual table nothing else which is based or we can say devlop with SQL SELECT query.So we can say that its a real database table (it has columns and rows just like a regular table),but one difference is that real tables store data,but views can’t. View data is generated dynamically when the view is referenced.And view can also references one or more existing database tables or other views. We can say that it is filter of database.

How to get which Process is Blocked in SQL SERVER ?

Answer:- There are two ways to get this  sp_who and sp_who2 . You cannot get any detail about the sp_who2 but its provide more information then the sp_who . And other option from which we can find which process is blocked by other process is by using Enterprise Manager or Management Studio, these two commands work much faster and more efficiently than these GUI-based front-ends.

Can you tell me the difference between DELETE &TRUNCATE commands?
Answer:
Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.

Which is the true with View:
     a Hide data complexity
     b Organise data From Hetrogenious sources
     c Reduce Object Size
     d Usuful for Combine multiple logical table
     e All are True
Ans:a
Which one is true with View:
     a It is a permanet table
     b It is a temporaray table
     c It Is a logical table 
     d It is a physical table
Ans:c
Which Type of Parameter is not found in Stored Procedure?
     a Input
     b Output
     c Ref 
     d All
Ans:c
Temporary stored Procedure Is found in :
     a Master Database
     b Model Database
     c Msdb Database
     d Temp Database 
Ans:d
Which two are the fundamental object of ADO.Net?
     a Dataset ,Dataadapter
     b DataReader ,DataSet
     c DataAdapter ,DataTable

     d DataSet ,DataReader 
Ans:d
select correct option-the .Net namespaces with the data functionality classes?
     a System.Data
     b System.Data.OleDB
     c System.XML
     d All 
Ans:
Which isolation level is used for COM+ object?
     a READ COMMITTED
     b READ UNCOMMITTED
     c SERIALIZABLE 
     d None
Ans:a
What is full form of T-SQL?
     a Transfer-SQL
     b Transaction-SQL
     c Transact-SQL 
     d None
Ans:c
What is the full form of KPI?
     a Key Procedure Indicators
     b Key Process Indicators
     c Key Performance Indicators 
Ans:c
What are the various lock types ?
     a Shared
     b update
     c exclusive
     d all 
Ans:d
What is the use of CHAR function?
     a Convert numeric to char type 
     b Convert char to numeric type
     c convert char to char
     d none
Ans:a
Can we create Web service in SQL Server 2005?
we can create web service in sql server 2005 by using an HTTP EndPoint
     a No

OOPS Interview Questions and Answers

OBJECT ORIENTED PROGRAMMING(Based on C#)

1) What is meant by Object Oriented Programming?
     OOP is a method of programming in which programs are organised as cooperative collections of objects. Each object is an instance of a class and each class belong to a hierarchy.

2) What is a Class?
     Class is a template for a set of objects that share a common structure and a common behaviour.

3) What is an Object?
     Object is an instance of a class. It has state,behaviour and identity. It is also called as an instance of a class.

4) What is an Instance?
     An instance has state, behaviour and identity. The structure and behaviour of similar classes are defined in their common class. An instance is also called as an object.

5) What are the core OOP’s concepts?
     Abstraction, Encapsulation,Inheritance and Polymorphism are the core OOP’s concepts.

6) What is meant by abstraction?
     Abstraction defines the essential characteristics of an object that distinguish it from all other kinds of objects. Abstraction provides crisply-defined conceptual boundaries relative to the perspective of the viewer. Its the process of focussing on the essential characteristics of an object. Abstraction is one of the fundamental elements of the object model.

7) What is meant by Encapsulation?
     Encapsulation is the process of compartmentalising the elements of an abtraction that defines the structure and behaviour. Encapsulation helps to separate the contractual interface of an abstraction and implementation.

8) What is meant by Inheritance?
     Inheritance is a relationship among classes, wherein one class shares the structure or behaviour defined in another class. This is called Single Inheritance. If a class shares the structure or behaviour from multiple classes, then it is called Multiple Inheritance. Inheritance defines “is-a” hierarchy among classes in which one subclass inherits from one or more generalised superclasses.

9) What is meant by Polymorphism?
     Polymorphism literally means taking more than one form. Polymorphism is a characteristic of being able to assign a different behavior or value in a subclass, to something that was declared in a parent class.

10) What is an Abstract Class?
     Abstract class is a class that has no instances. An abstract class is written with the expectation that its concrete subclasses will add to its structure and behaviour, typically by implementing its abstract operations.

11) What is an Interface?
     Interface is an outside view of a class or object which emphaizes its abstraction while hiding its structure and secrets of its behaviour.

12) What is a base class?
     Base class is the most generalised class in a class structure. Most applications have such root classes. In Java, Object is the base class for all classes.

13) What is a subclass?
     Subclass is a class that inherits from one or more classes

14) What is a superclass?
     superclass is a class from which another class inherits.

15) What is a constructor?
     Constructor is an operation that creates an object and/or initialises its state.

16) What is a destructor?
     Destructor is an operation that frees the state of an object and/or destroys the object itself. In Java, there is no concept of destructors. Its taken care by the JVM.

17) What is meant by Binding?
     Binding denotes association of a name with a class.

18) What is meant by static binding?
     Static binding is a binding in which the class association is made during compile time. This is also called as Early binding.

19) What is meant by Dynamic binding?
     Dynamic binding is a binding in which the class association is not made until the object is created at execution time. It is also called as Late binding.

20) Define Modularity?
     Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules.

21) What is meant by Persistence?
     Persistence is the property of an object by which its existence transcends space and time.

22) What is colloboration?
     Colloboration is a process whereby several objects cooperate to provide some higher level behaviour.

23) In Java, How to make an object completely encapsulated?
     All the instance variables should be declared as private and public getter and setter methods should be provided for accessing the instance variables.

24) How is polymorphism acheived in java?
     Inheritance, Overloading and Overriding are used to acheive Polymorphism in java.


 Use the new modifier to explicitly hide a member inherited from a base class. To hide an inherited member, declare it in the derived class using the same name, and modify it with the new modifier.

 Yep. But ..

* Its possible If its a static method.

* Its possible by inheriting from that class also.

* Its possible from derived classes using base keyword.

 Use the override modifier to modify a method, a property, an indexer, or an event. An override method provides a new implementation of a member inherited from a base class. The method overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method.

You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override.

 Method overloading occurs when a class contains two methods with the same name, but different signatures.


Method overriding is a feature that allows to invoke functions (that have the same signatures) and that belong to different classes in the same hierarchy of inheritance using the base class reference. In C# it is done using keywords virtual and overrides .

For more information visit http://www.codeproject.com/KB/cs/cs_methodoverride.aspx


Method overloading allows us to write different version of the same method in a class or derived class. Compiler automatically select the most appropriate method based on the parameter supplied.
public class MultiplyNumbers
{
    public int Multiply(int a, int b)
    {
        return a * b;
    }
  
    public int Multiply(int a, int b, int c)
    {
        return a*b*c;
    }     
}


To call the above method, you can use following code.
MultiplyNumbers mn = new MultiplyNumbers();
int number = mn.Multiply(2, 3) // result = 6
int number1 = mn.Multiply(2, 3, 4) // result = 24
 


You can't have a overload method with same number parameters but different return type. In order to create overload method, the return type must be the same and parameter type must be different or different in numbers.

 An enum has default modifier as public

A class has default modifiers as private . It can declare members (methods etc) with following access modifiers:
public
protected
internal
private
protected internal

An interface has default modifier as public

A struct has default modifier as private and it can declare its members (methods etc) with following access modifiers:
public
internal
private


Protected Internal is a access modifiers for the members (methods or functions) ie. you can't declare a class as protected internal explicitly. The members access is limited to the current assembly or types derived from the containing class.

Protected Internal means the method is accessible by anything that can access the protected method
UNION with anything that can access the internal method.

For more details read http://haacked.com/archive/2007/10/29/what-does-protected-internal-mean.aspx

 The internal keyword is an access modifier for types and type members ie. we can declare a class as internal or its member as internal. Internal members are accessible only within files in the same assembly (.dll). In other words, access is limited exclusively to classes defined within the current project assembly.

For more details see http://msdn.microsoft.com/en-us/library/7c5ka91b(VS.71).aspx

 The private keyword is a member access modifier ie. we can't explicitly declare a class as Private, however if do not specify any access modifier to the class, its scope will be assumed as Private. Private access is the least permissive access level of all access modifiers.

Private members are accessible only within the body of the class or the struct in which they are declared. This is the default access modifier for the class declaration.

For more details, see http://msdn.microsoft.com/en-us/library/st6sy9xe(VS.71).aspx

 The public keyword is an access modifier for types and type members ie. we can declare a class or its member (functions or methods) as Public. There are no restrictions on accessing public members.


The protected keyword is a member access modifier. It can only be used in a declaring a function or method not in the class ie. a class can't be declared as protected class.

A protected member is accessible from within the class in which it is declared, and from within any class derived from the class that declare this member. In other words access is limited to within the class definition and any class that inherits from the class

A protected member of a base class is accessible in a derived class only if the access takes place through the derived class type.

For more details see http://msdn.microsoft.com/en-us/library/bcd5672a(VS.71).aspx


 Private, Protected, Public, Internal, Protected Internal.


The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a sealed class is specified as the base class of another class. (A sealed class cannot also be an abstract class)

 Operator overloading is a concept that enables us to redefine (do a special job) the existing operators so that they can be used on user defined types like classes and structs.

For more information visit: http://aspalliance.com/1227_Understanding_Operator_Overloading_in_C.all

 C# has a large set of operators, which are symbols that specify which operations to perform in an expression.

Arithmetic
+ - * / %

Logical (boolean and bitwise)
& | ^ ! ~ && || true false

String concatenation
+

Increment, decrement
++ --

Shift
<< >>

Relational
== != < > <= >=

Assignment
= += -= *= /= %= &= |= ^= <<= >>=

Member access
.

Indexing
[]

Cast
()

Conditional
?:

Delegate concatenation and removal
+ -

Object creation
new

Type information
as is sizeof typeof

Overflow exception control
checked unchecked

Indirection and Address
* -> [] &

For more details visit http://msdn.microsoft.com/en-us/library/6a71f45d(VS.71).aspx

Partial class

Instead of defining an entire class, you can split the definition into multiple classes by using the partial keyword. When the application is complied, the C# complier will group all the partial classes together and treat them as a single class. There are a couple of good reasons to use partial classes. Programmers can work on different parts of a class without needing to share the same physical file. Also you can separate your application business logic from the designer-generated code.

C#
Public partial class Employee
{
      public void DoWork()
      {}
}
  
Public partial class Employee
{
       public void GoToLunch()
       {}
}

 Abbreviated as GAC, the Global Assembly Cache is a machine-wide store used to hold assemblies that are intended to be shared by several applications on the machine. Each computer where the common language runtime (CLR) is installed has a global assembly cache. The global assembly cache stores the assemblies specifically designated to be shared by several applications on the computer.

For more details visit http://www.webopedia.com/TERM/G/Global_Assembly_Cache.htm


To create a strong name key use following code
C:\>sn -k s.snk


Strong name key is used to specify the strong name used to deploy any application in the GAC (Global Assembly Catch) in the system.

 Object Pooling is something that tries to keep a pool of objects in memory to be re-used later and hence it will reduce the load of object creation to a great extent.

Object Pool is nothing but a container of objects that are ready for use. Whenever there is a request for a new object, the pool manager will take the request and it will be served by allocating an object from the pool.

This concept has been better explained in following article
http://www.c-sharpcorner.com/UploadFile/vmsanthosh.chn/109042007094154AM/1.aspx


The name of C# compiler is CSC.

eg. to create the executable of the .cs file you can use
csc File.cs 

This will create File.exe file.

For more details visit: http://msdn.microsoft.com/en-us/library/78f4aasd.aspx


Using statement is used to work with an object in C# that inherits IDisposable interface.

IDisposable interface has one public method called Dispose that is used to dispose off the object. When we use Using statement, we don't need to explicitly dispose the object in the code, the using statement takes care of it. For eg.
Using (SqlConnection conn = new SqlConnection())
{
  
}

When we use above block, internally the code is generated like this
SqlConnection conn = new SqlConnection()
try
{
  
}
finally
{
          // calls the dispose method of the conn object
}


Using statement make the code more readable and compact.

For more details read http://www.codeproject.com/KB/cs/tinguusingstatement.aspx

 NO,because c# doesnot support static block,but it supports static method


When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

ADO.NET

 SQLClient .NET classes are highly optimized for the .net / sqlserver combination and achieve optimal results. The SqlClient data provider is fast. It's faster than the Oracle provider, and faster than accessing database via the OleDb layer. It's faster because it accesses the native library (which automatically gives you better performance), and it was written with lots of help from the SQL Server team.


• ADO.NET Does Not Depend On Continuously Live Connections
• Database Interactions Are Performed Using Data Commands
• Data Can Be Cached in Datasets
• Datasets Are Independent of Data Sources
• Data Is Persisted as XML
• Schemas Define Data Structures

 DAO is used for database access on windows platform. It creates a work space object in which applications or operations are performed. There are two types of database engines they are Jet database engine and ODBC direct database engine.

 ADO.NET utilizes the power of XML by providing disconnected access to data. This is designed with the help of XML classes in .NET Framework which form the components of single architecture.

 1. Connection object is responsible for creating a connection to the database.
2. Record object represents data which is not from the database.
3. Parameter object represents a sql parameter
4. Stream object is responsible to represent data from a text page or web page.



In order to create a DataView from a DataTable, use instantiate the DataView object by passing DataTable as parameter in the constructor.

eg.
DataView dView = new DataView(dTable);


Yes,

DataAdapter object can accept either DataTable or DataSet as parameter to fill data from database.

eg.
SqlDataAdapter dAd = new SqlDataAdapter();
DataTable dTable = new DataTable();
DataSet dSet = new DataSet();
----
---
dAd.Fill(dTable); // will also work
dAd.Fill(dSet); // will also work
 


We should only use DataSet as parameter when we are expecting more than one result set is being returned from database.

 A linked server configuration enables SQL Server to execute commands against OLE DB data sources on remote servers. Linked Servers is a concept in SQL Server by which we can add other SQL Server to a Group and query both the SQL Server dbs using T‐SQL Statements.
Linked servers offer the following advantages:


1. Remote server access.
2. The ability to issue distributed queries, updates, commands, and transactions on heterogeneous data sources across the enterprise.
3. The ability to address diverse data sources similarly.

With a linked server, you can create very clean, easy to follow, SQL statements that allow remote data to be retrieved, joined and combined with local data. Stored Procedure sp_addlinkedserver, sp_addlinkedsrvlogin will be used add new Linked Server.


increase the execution time out in web.config (or)increase the connection time out in connection string

 Connection pooling enables an application to use a connection from a pool of connections that do not need to be re-established for each use. Once a connection has been created and placed in a connection pool, an application can reuse that connection without performing the complete connection creation process.

 Datagrid is
* one which has advanced features and lets you do lot many things like paging and sorting your data without much effort.
* DataGrid can hold text data, but not linked or embedded objects.


Whereas a DataRepeater is
* which does not have the paging feature but we can do it by coding.
* one which can hold other controls and can embed objects.
* It can embed a Datagrid within it but not viceversa.

Apart from this a Data Repeater
--is used in places where you need more control over the rendering of your data
-- have very flexible templates that give you total control over the formatting of your data


No, it just reads the information from its data source


SqlDataReader object. (Note: Even datasets also use SqlDataReader objects internally for retriving data from database.)


No, it is readonly and forward only control so we can't edit data in repeater control.

C#

 In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.

 A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.

 A delegate object encapsulates a reference to a method.


1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
2. When at least one of the methods in the class is abstract.

 StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.

 NOTE: This is objective type question, Please click question title for correct answer.


Static:
1)A Static memberdata or a memberfunction can be called without the help of an object.
2)Static members can be called with the help of Classname.

Syntax: classname.staticmember
3)'this ' keyword cannot be used inside a static memberfunction
4)Nonstatic members cannot be used inside a static memberfunction

 Both CopyTo() and Clone() make shallow copy (data is copied) and used for Single Dimension arrays.

Clone() method makes a clone of the original array. It returns an exact length array.

CopyTo() copies the elements from the original array to the destination array starting at the specified destination array index. Note that, this adds elements to an already existing array.

In VB.NET, variables has to be declared earlier, before using Clone or CopyTo methods to store the values. The difference arise on mentioning the size of the array.

While declaring the varaiable that is used for CopyTo method, it should have the size equal to or more than that of the original array.

While declaring the variable that is used for Clone method we need not mention the array size. Eventhough the array size is small, it won't show any error, rather the array size gets altered automatically on cloning. The cloned array size get created equal to the size of the source array.

If value type is used for CopyTo/Clone any change in the values made on them will not get reflected on the original whereas on reference type the change gets reflected.

Below is the code which would throw some light on your understanding.

 Constructor:
-----------------

1. The Constructor is the first method that is run when an instance of a type is created. In visual basic a constructor is always Sub new ().

2. Constructor are use to initialize class and structure data before use. Constructor never returns a value and can be overridden to provide custom initialization functionality.

3. The constructor provides a way to set default values for data or perform other necessary functions before the object available for use.

Destructor:
---------------
Destructors are called just before an object is destroyed and can be used to run clean-up code. You can’t control when a destructor is called.


This is a new feature in C# 3.0. This method allows us to add a new static method to the existing classes.

For example, if we want to validate an Email address using the static method of the string class (built-in) class, we can add an extension method like this.
public static bool IsValidEmail(this string input)
        {
            Regex regEx = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
            return regEx.IsMatch(input);
        }


Notice the parameter passed to above method. Here "this" indicates the string class. Now, we can use above extension method like this.
string myEmail = "me@me.com";
bool IsValidEmailAddress = myEmail.IsValidEmail();


In this case as the format of the email id in myEmail variable is correct so IsValidEmailAddress will be true.



If no class is inhertited, by default a class inherit System.Object.
 Extension method is a new feature in C# 3.0.

Extension methods allow existing classes to be extended without relying on inheritance or having to change the class's source code. This means that if you want to add some methods into the existing String class you can do it quite easily.

Here's a couple of rules to consider when deciding on whether or not to use extension methods:

* Extension methods cannot be used to override existing methods
* An extension method with the same name and signature as an instance method will not be called
* The concept of extension methods cannot be applied to fields, properties or events
* Use extension methods sparingly....overuse can be a bad thing!

For more details, see http://weblogs.asp.net/dwahlin/archive/2008/01/25/c-3-0-features-extension-methods.aspx

 Partial class is a new functionality added in since .NET Framework 2.0 version. It allows to split us to split the definition of once class, struct, interface into multiple source files. Each source file contains a section of definition, and all parts are combined when the application is compiled.

For more detail see http://msdn.microsoft.com/en-us/library/wa80x488(VS.80).aspx

 A Nested classes are classes within classes.

OR

A nested class is any class whose declaration occurs within the body of another class or interface.

For more details see http://www.codeproject.com/KB/cs/nested_csclasses.aspx

 A top level class is a class that is not a nested class.

See what is nested class http://www.dotnetfunda.com/interview/exam281-what-is-nested-class.aspx

 NOTE: This is objective type question, Please click question title for correct answer.

 Garbage collection is a mechanism that allows the computer to detect when an object can no longer be accessed. It then automatically releases the memory used by that object (as well as calling a clean-up routine, called a "finalizer," which is written by the user). Some garbage collectors, like the one used by .NET, compact memory and therefore decrease your program's working set.


An application domain (often AppDomain) is a virtual process that serves to isolate an application. All objects created within the same application scope (in other words, anywhere along the sequence of object activations beginning with the application entry point) are created within the same application domain. Multiple application domains can exist in a single operating system process, making them a lightweight means of application isolation.

An OS process provides isolation by having a distinct memory address space. While this is effective, it is also expensive, and does not scale to the numbers required for large web servers. The Common Language Runtime, on the other hand, enforces application isolation by managing the memory use of code running within the application domain. This ensures that it does not access memory outside the boundaries of the domain. It is important to note that only type-safe code can be managed in this way (the runtime cannot guarantee isolation when unsafe code is loaded in an application domain).

 This is a new feature in C# 3.0. This enable use to create a type/class on-the-fly at compile time.
For example
var emp = new { Name = "Sheo", Gender = "Male", Active = true };
In this case a new type will be created on the fly that will have Name, Gender, and Active as public property and its backing field like _Name, _Gender, _Active.

This is especially useful when we want to receive data from other object or iterate through a collection and set values and do not want to create a class just to hold the data. Note that anonymous types are just a placeholder, we can't customize its behavior or add methods inside it.


This is the new feature in C# 3.0. This enable us to declare a variable whose type is implicitly inferred from the expression used to initialize the variable.

eg.

var age = 10;

Because the initialization value (10) of the variable age is integer type of age will be treated as integer type of variable. There are few limitation of the var type of variables.

They are:

#. They can't be initialized as null.
#. They need to be declared and initialized in the same statement.
#. They can't be used as a member of the class.

 Building a shared assembly does involve working with cryptographic keys. Only the public key is strictly needed when the assembly is being built. Compilers targeting the .NET Framework provide command line options (or use custom attributes) for supplying the public key when building the assembly. It is common to keep a copy of a common public key in a source database and point build scripts to this key. Before the assembly is shipped, the assembly must be fully signed with the corresponding private key. This is done using an SDK tool called SN.exe (Strong Name).

Strong name signing does not involve certificates like Authenticode does. There are no third party organizations involved, no fees to pay, and no certificate chains. In addition, the overhead for verifying a strong name is much less than it is for Authenticode. However, strong names do not make any statements about trusting a particular publisher. Strong names allow you to ensure that the contents of a given assembly haven't been tampered with, and that the assembly loaded on your behalf at run time comes from the same publisher as the one you developed against. But it makes no statement about whether you can trust the identity of that publisher.


Data Reader is connected, read only forward only record set.
Dataset is in memory database that can store multiple tables, relations and constraints; moreover dataset is disconnected and is not aware of the data source.


Attributes are a mechanism for adding metadata, such as compiler instructions and other data about your data, methods, and classes, to the program itself. Attributes are inserted into the metadata and are visible through ILDasm and other metadata-reading tools. Attributes can be used to identify or use the data at runtime execution using .NET Reflection.


String is an object (Reference Type).

Easy Way To Pay

Sign up for PayPal and start accepting credit card payments instantly.

Earn While Searching