December 11, 2014

OOPs Interview Questions

[1] What is Object Oriented Programming?
[2] What is Class?
[3] What is an Object?
[4] What is meaning of Encapsulation?
[5] What do you mean by Polymorphism?
[6] What is Inheritance?

June 18, 2014

SQL Server Query Interview Questions

1.What will be the output following script?

DECLARE @EMP TABLE
(
    ID INT,
    Name NVARCHAR(100)
)
INSERT INTO @EMP
(ID,Name)
SELECT 1,'Joe' UNION ALL
SELECT 2,'Mac' UNION ALL
SELECT 3,'Sam' UNION ALL
SELECT 4,'Peter'
SELECT 5 FROM @EMP

2. Find nth highest salary form table.

DECLARE @Employee TABLE
(
EmpID INT Identity,
EmpName Varchar(100),
EmpSalary Decimal (10,2)
)
INSERT INTO @Employee VALUES ('Joe',15000);
INSERT INTO @Employee VALUES ('Mac',13000);
INSERT INTO @Employee VALUES ('John',11000);
INSERT INTO @Employee VALUES ('Stev',14000);
INSERT INTO @Employee VALUES ('Sam',19000);

select min(EmpSalary) from @Employee where EmpSalary in
(select distinct top N EmpSalary from @Employee order by EmpSalary desc)


Note: Where N = 1,2,3 ..

3. Delete duplicate records from table.
DECLARE @Employee TABLE
(
EmpName Varchar(100),
EmpSalary Decimal (10,2)
)
INSERT INTO @Employee VALUES ('Joe',15000);
INSERT INTO @Employee VALUES ('Joe',15000);
INSERT INTO @Employee VALUES ('Mac',13000);
INSERT INTO @Employee VALUES ('Mac',13000);
INSERT INTO @Employee VALUES ('John',11000);
INSERT INTO @Employee VALUES ('Stev',14000);
INSERT INTO @Employee VALUES ('Sam',19000);
;WITH CTE AS
(
    SELECT * , ROW_NUMBER() OVER (PARTITION BY EmpName ORDER BY EmpName) AS 'Rnk'
    FROM @Employee
)
DELETE FROM CTE WHERE Rnk > 1

June 13, 2014

Jquery starts with and ends with selector

I have a dynamic table with id “grdComDealerMntce-Ct100_Ct200_DealerCode”.
I want to specify this id in Jquery selector which starts with grdComDealerMntce and ends with DealerCode.

$(‘[id ^=grdComDealerMntce][id $=DealerCode]’) 

^: Starts with
$: Ends with

June 12, 2014

Css starts with and ends with class

I have some ids on my page and I want to specify all those ids in class selector.
How we can do so ?

Css allow us to make regular expression class selector.
Example:

table [id^=grdComDealerMntce][id$=_mainTable] td
{
text-align:left;
}

June 11, 2014

Chechboxlist select all Jquery

I have checkbox list with first element as “"All”. I want to all following operation on this.

1.Click on “All” select all items
2.If I select all items except first item “All”,first item should automatically checked.
3.If I have selected “All” items and I am deselecting any other items “All” should be automatically
   deselected.

Jquery Code block:

$(document).on(‘click’,’[id*=cblYear] input:eq(0)’,function(){
     var toggle = this.checked;
     $”[id*=cblYear] input”.attr(‘checked’,toggle);
}); 

$(document).on(‘click’,’[id*=cblYear] input:gt(0)’,function(){
    if(!this.checked){
      $”[id*=cblYear] input”.eq(0).attr(‘checked’,false);
     }else{
      $”[id*=cblYear] input”.eq(0).attr(‘checked’,$”[id*=cblYear] input”).slice(1).filter
      (‘:not(:checked)’).length ==0
       }

June 26, 2013

Enable/Disable JavaScript in browser

You can enable/disable JavaScript in browser.
In Firefox go to options window and simply check/uncheck highlighted area.

image

In IE.

image

That’s It.
Enjoy Learning.