Friday, January 10, 2014

Interview Questions-Answers IG - 8

1) What is Json?
Answer : JSON stands for Java Script Object Notation, it is a text based format, It contains the values in key-value pair.

2) Why we use Json?
Answer : We use the JSON to store the values in key-value pair.

3) Joins - Left Outer, Right Outer, Full Outer, Inner Join?
Answer : In left Outer - All matching rows + all no matching left table rows
Right Outer Join - All matching rows + all non matching right table rows
Full Outer Join- All matching rows + all non matching left table rows + all non matching right table rows

4) Why we use static method?
Answer : To use the common value in whole application.
Static methods are conceptually the same as static variables, thus the reasons to use or not use them are similar. They belong to the class, not specific objects of that class. If a method perform a same task irrespective of object than that method should be declared as static.

In a class Car you might have a method double convertMpgToKpl(double mpg) which would be static, because one might want to know what 35mpg converts to, even if nobody has ever built a Car. But void setMileage(double mpg) (which sets the efficiency of one particular Car) can't be static since it's inconceivable to call the method before any Car has been constructed.

5) Give me real example where you use static method.
Answer : in Singleton Pattern

6) If we have a table in which thousands of record inserting,deleting and updating daily. Which type of index you will use there.
Answer : Non Clustered Index. Since in case of clustered index table reorder for each insert,update or delete.

7)Any critical job/work that you have done so far?

8) Difference between clustered and nonclustered index.
Answer : In clustered Index leaf node contains the row itself while in case of non clustered index leaf node contains the pointer of the row.

9) What is identity?
 Answer : Indentity  is a column whose value auto generated.
Syntax to get Identity : IDENT_CURRENT('table_name')

10) What is scope_identity?
Answer : Scope_Identity used to get the last identity values use by function of procedure.
Syntax : Scope_Identity()

11) Is it make sense that we define clustered index on primary key column.
Answer : No

Beacause a Clustered Index is automatically created on the table when we create a PRIMARY KEY constraint if it is not created already.

12) Can we define clustered index on composite column?
Answer : Yes, you can create.
However, from a performance view you should avoid composite clustered indexes. Generally speaking, the leaner index, the faster SQL Server can scan or seek through it. For small tables (or data sets) composite indexes perform relatively well, but as number of records grows, performance decreases.

No comments: