Interview Questions from C#, JavaScript and SQL

Dear Friends,

Recently i attended interview got some interested questions here i'm sharing pls need correct answers

In C#

1. Consider the following classes:

public class ClassA
{
private int _value;

public ClassA()
{
}

public ClassA(int value)
{
_value = value;
}

public int Value
{
get { return _value; }
protected set { _value = value; }
}
}

public class ClassB : ClassA
{
protected ClassB(int value) : base(value * 10)
{ }
}

public class ClassC : ClassB
{
}

Show how many different ways you can create a new instance of each of the classes? (e.g. "StringBuildersb = new StringBuilder();" is one way to instantiate a StringBuilder class object instance.) Also after each object instantiation, what will be the value returned by the "Value" property of that object instance.
-----------------------------
2. Let's say that you have a doubly-linked list (a list in which each item has reference to the previous as well as the next item in the list) where each node is represented with the following class:

public class ListItemNode
{
object Value;
ListItemNodeNextItem;
ListItemNodePreviousItem;
}

The DoubleLinkedList class has a member variable named "HeadNode" of type ListItemNode. This head node is the first item in the list.

Write a method for the DoubleLinkedList class to reverse the order of the items in the list.
-------------------------------------------------
3. Consider the following two arrays:

string[] arrStrings = new string[] { "Bal", "Yuriy", "Ken", "Apple", "Ken" };
int[] arrNumbers = new int[] { 11, 2, 25, 34, 66, 25, 0, 0, 3, 4, 2, 89 };

Write a single method which can be passed either one of these arrays and it returns the list of unique items in the specified list. You cannot use LINQ to solve this problem.
-----------------------------------------------
4. Let's say you are developing an API which draws a diagram on a screen canvas. The diagram is composed of different types of shapes – circles, rectangles, lines, etc. Each shape knows how to draw itself. Multiple shapes placed at different locations within the canvas area makes up a diagram image. Define an object/class model (set of classes) which can be used to represent the shapes (just target circle, rectangle, and line shape types) and the diagram class. Note that this class model should be extensible so that other types of shapes (like pentagon, star, etc.) can be supported later on without having the change the diagram class. The canvas class (which you don't have to write) will use the diagram object to draw shapes that make up the image. You don't need to write the body of the methods, just the skeleton API design is sufficient. This should demonstrate the common OOP aspects of the skills.

In JavaScript

1. Write a JavaScript/jQuery statement to retrieve the value of a DIV element with ID "FullName" and an INPUT field with the ID "FirstName".
----------------------------

2. Write a JavaScript/jQuery statement to update the value of a DIV element with ID "FullName" and an INPUT field with the ID "FirstName".
-----------------------------------

3. Write a JavaScript/jquery statement to retrieve the 3rd button object on the page.
--------------------------------------

In SQL

1. Consider the following database table:

Promotions(CustomerID, PromotionCode)

This table has a unique index based on CustomerID and PromotionCode columns.

The table contains records for the customers who received any promotions. Let's say two of the promotions are named "PromA" and "PromB".

Write the code for the following SQL queries:
a) Build the query that will show unique Customer IDs of customers who received
'PromA', but didn't receive 'PromB'.

b) Build the query that will show the number of customers who received each
Code stored in the table. Display Promotion Code and number of customers who
received that promotion. However do not display Promotion Codes that were sent to
small number of customers (less than 30).

c) Will the following query utilize the index mentioned above?

SELECT CustomerID FROM Promotions WHERE PromotionCode = 'PromA'

-------------------------------------

2. Write the code that will give a flat hike to your employees using the following criteria:

EmployeeSalary(EID, Name, Salary)

Salary between 30000 and 40000 -- 5000 hike
Salary between 40000 and 55000 -- 7000 hike
Salary between 55000 and 65000 -- 9000 hike
-------------------------------------------

Thanks in advance :)