Thursday, October 25, 2012

Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming

Aspect-Oriented

Aspect-oriented programming looks at how many components or pieces of a system might need to interact. The intersections of these pieces are what are important in AOP. "Crosscutting" is a slice across several units, all of which interact during some operation.
Interface-Oriented
Interface-oriented programming is a contract-based approach. Nether side of the interface cares how the other does its work, only that the two sides can communicate via an agreed-upon contract. WSDL-based web services are the prime example of this.

Object-Oriented
Object-Oriented programming is based on abstraction, encapsulation (data hiding), polymorphism and inheritance. Classes implement these concepts to build objects controlling or implementing a system.

Abstraction allows loose coupling between components by providing a layer between objects so that one object isn't concerned with how the other implements its business rules. (Interfaces, layers) Great stuff when you want to isolate parts of the system so they can be swapped out without killing the rest of the sytsem.

Encapsulation allows abstraction to work by hiding details of a class's implementation from calling classes. (Public vs. private fields)

Inheritance enables base (parent) classes to have common functionality defined in it and passed down to child classes. A Shape class might have a field for color which is inherited by child classes of Square or Circle type.

Polymorphism enables implementation of same-named public fields, allowing different classes to perform different actions on the same call - rendering a Square or Circle object differently in a graphic program, even though they might both be subclassed from a base Shape class. (Overriding)

What are trace switches?

Trace switches helps us to control and govern the tracing behavior of a project. There are two types of trace switches ‘BooleanSwitch’ and ‘TraceSwitch’. BooleanSwitch, as the name says, is a kind of on/off switch which can be either enabled (true) or disabled (false).

‘TraceSwitch’ on the other hand offers more options rather than simple true/false like ‘BooleanSwitch’. Tracing is enabled for a TraceSwitch object using the Level property. When we set the Level property of a switch to a particular level, it includes all levels from the indicated level down. For example, if you set a TraceSwitch’s Level property to TraceLevel.Info, then all the lower levels, from TraceLevel.Error to TraceLevel.Warning, will be taken in to account.

Below are the various levels in ‘TraceSwitch’ object.
 
Off a Outputs no messages to Trace Listeners

Error a Outputs only error messages to Trace Listeners

Warning a Outputs error and warning messages to Trace Listeners

Info a Outputs informational, warning and error messages to Trace Listeners

Verbose a Outputs all messages to Trace Listeners

 
 
 
 
 
 
 
 

What is the main difference between Gridlayout and FlowLayout ?

GridLayout provides absolute positioning for controls placed on the page. Developers that have their roots in rich-client development environments like Visual Basic will find it easier to develop their pages using absolute positioning, because they can place items exactly where they want them. On the other hand, FlowLayout positions items down the page like traditional HTML. Experienced Web developers favor this approach because it results in pages that are compatible with a wider range of browsers.

If you look in to the HTML code created by absolute positioning you can notice lot of DIV tags. While in Flow layout you can see more of using HTML table to position elements which is compatible with wide range of browsers.



What is the difference between “Web farms” and “Web garden”?

Web farm
Used to have some redundancy to minimize failures. It consists of two or more web server of the same configuration and they stream the same kind of contents. When any request comes there is switching / routing logic which decides which web server from the farm handles the request. For instance we have two servers “Server1″ and “Server2″ which have the same configuration and content. So there is a special switch which stands in between these two servers and the users and routes the request accordingly.

A router in between which takes a request and sees which one of the server is least loaded and forwards the request to that server. So for request1 it route’s server1, for request2 it routes server2, for request3 it routes to server3 and final request4 is routed to server4. So you can see because we have web farm at place server1 and server2 are loaded with two request each rather than one server loading to full. One more advantage of using this kind of architecture is if one of the servers goes down we can still run with the other server thus having 24×7 uptime.

The routing logic can be a number of different options:

Round-robin: Each node gets a request sent to it “in turn”. So, server1 gets a request, then server2 again, then server1, then server2 again.

Least Active Whichever node show to have the lowest number of current connects gets new connects sent to it. This is good to help keep the load balanced between the server nodes

Fastest Reply Whichever node replies faster is the one that gets new requests. This is also a good option – especially if there are nodes that might not be “equal” in performance. If one performs better than the other, then send more requests there rather than which is moving slowly?

Web Garden

All requests to IIS are routed to “aspnet_wp.exe” for IIS 5.0 and “w3wp.exe” for IIS 6.0. In normal case i.e. without web garden we have one worker process instance (“aspnet_wp.exe” / “w3wp.exe”) across all requests. This one instance of worker process uses the CPU processor as directed by the operating system.

But when we enable web garden for a web server it creates different instances of the worker process and each of these worker process runs on different CPU.
In short we can define a model in which multiple processes run on multiple CPUs in a single server machine are known as a Web garden.



If cookies are not enabled at browser end does form Authentication work?

No,it does not work

ASP used STA threading model, what is the threading model used for ASP.NET ?

ASP.NET uses MTA threading model

Tuesday, October 23, 2012

What are the benefits of service orientation?

[1] Isolation : Changing the internals of one service does not force changes, rebuilding or restarting of other services.

[2] Behavior is separated from constraints : Relocating, outsourcing or restricting a service requires changes only in the policy but not to the service itself.

[3] Location independent : Whether a service is on the same machine or different, it can be accessed in the similar manner.

[4] Scale invariant : Services scale in all the directions. Let's take an example a service can be scaled out by fronting it with a router service that distributes traffic among a farm of services.

[5] Transport/protocol/format neutral : The communication details between parties are flexible but not fixed.

[6] Time independent : Services can make use of queue-based communication, when they do not have to be online at the same time to interact.

[7] Platform and implementation independent : A service need not know anything about another service's execution environment to interact with it.

[8] Address agnostic : Services can employ a discovery mechanism to locate each other without any prior notion about where they reside.

Set Operators in Linq

There are mainly five types of Set Operators in Linq.


1. Distinct

2. Concat

3. Union

4. Intersect

5. Except

1.Distinct
public void DistinctFunction()
{
int[] seq1 = { 1, 2, 3, 3, 4, 2, 5, 4, 5, 2, 1 };
var distinctValues = seq1.Distinct();
Console.WriteLine("Distinct Values in the array : ");
foreach (var n in distinctValues)
{
Console.WriteLine(n);
}
}
OutputDistinct Values in the array :
1
2
3
4
5



2.Concat
public void ConcatFunction()
{
int[] seq1 = { 1, 2, 3 }, seq2 = { 3, 4, 5 };
var concatValues = seq1.Concat(seq2);
Console.WriteLine("Concatenation of two array : ");
foreach (var n in concatValues)
{
Console.WriteLine(n); }
 }
OutputConcatenation of two array :
1
2
3
3
4
5

3.Union

public void UnionFunction()
{
    int[] seq1 = { 1, 2, 3 }, seq2 = { 3, 4, 5 };
 
    var unionValues = seq1.Union(seq2);
 
    Console.WriteLine("Union of two array : ");
    foreach (var n in unionValues)
    {
        Console.WriteLine(n);
    }
}

Output

Union of two array :
1
2
3
4
5


4.Intersect
public void IntersectFunction() {    int[] seq1 = { 1, 2, 3 }, seq2 = { 3, 4, 5 };    var unionValues = seq1.Intersect(seq2);    Console.WriteLine("Intersection of two array : ");    f oreach (var n in unionValues)    {      Console.WriteLine(n);    } } OutputIntersection of two array :  3   5.Except public void ExceptFunction() {  int[] seq1 = { 1, 2, 3 }, seq2 = { 3, 4, 5 };  var unionValues = seq1.Except(seq2); Console.WriteLine("Applying Except Function on two arrays : "); foreach (var n in unionValues) {  Console.WriteLine(n);  } } OutputApplying Except Function on two arrays :  1  2






Ordering Operators in Linq

There are mainly five types of Ordering Operators in Linq.


1. OrderBy

2. OrderByDescending

3. ThenBy

4. ThenByDescending

5. Reverse



1.OrderBy
public void OrderBy()
{
    string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };
 
    var sortedNames = names.OrderBy (s => s);
    var sortedNamesLengthWise = names.OrderBy (s => s.Length);
 
    Console.WriteLine("Sorted List: ");
    foreach (var n in sortedNames)
    {
        Console.WriteLine(n);
    }
    Console.WriteLine("Sorted List LengthWise: ");
    foreach (var nlw in sortedNamesLengthWise)
    {
        Console.WriteLine(nlw);
    }
}

OutPut

Sorted List:
Dick
Harry
Jay
Mary
Tom


2.OrderByDescending
public void OrderByDescending()
{
    string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };
 
    var sortedNames = names.OrderByDescending(s => s);
    var sortedNamesLengthWise = names.OrderByDescending(s => s.Length);
 
    Console.WriteLine("Sorted Descending : ");
    foreach (var n in sortedNames)
    {
        Console.WriteLine(n);
    }
    Console.WriteLine("Sorted Descending LengthWise: ");
    foreach (var nlw in sortedNamesLengthWise)
    {
        Console.WriteLine(nlw);
    }
}

OutPut

Sorted List:
Tom
Mary
Jay
Harry
Dick
Sorted List LengthWise:
Harry
Dick
Mary
Tom
Jay

3.ThenBy
public void ThenBy()
{
    string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };
 
    var sortedNames = names.OrderBy(s => s.Length).ThenBy (s => s);
    var sortedNamesLengthWise = names.OrderBy (s => s.Length).ThenBy (s => s[1]).ThenBy (s => s[0]);
 
    Console.WriteLine("Sorting By Length then alphabetically : ");
    foreach (var n in sortedNames)
    {
        Console.WriteLine(n);
    }
    Console.WriteLine("By length, then second character, then first character : ");
    foreach (var nlw in sortedNamesLengthWise)
    {
        Console.WriteLine(nlw);
    }
}

OutPut

Sorting By Length then alphabetically :
Jay
Tom
Dick
Mary
Harry

By length, then second character, then first character :

Jay
Tom
Mary
Dick
Harry

4.ThenByDescending

public void ThenByDescending()
{
 string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };
var sortedNames = names.OrderBy(s => s.Length).ThenByDescending(s => s);
Console.WriteLine("Sorting By Length then alphabetically in descending order : ");
foreach (var n in sortedNames)
 {
 Console.WriteLine(n);
 }
}
OutPutSorting By Length then alphabetically in descending order :
Tom
Jay
Mary
Dick
Harry

5.Reverse

public void Reverse()
{
 string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };
var reverse = names.Reverse();
Console.WriteLine("Reversing the collection : ");
foreach (var r in reverse)
 {
   Console.WriteLine(r);
  }
}
OutPutReversing the collection :
Jay
Mary
Harry
Dick
Tom







Which is the process of tying a control of the application to any column or row of the DataTable so that the data stored in the database table can be displayed in that control?


Data Binding

Which is considered as an object on which data retrieved from the database is stored?

Dataset

How do you catch all exceptions?

Using a catch statement that specifies no parameters

What does DOM stands for?


Document Object Model

what is ACID?

A-Atomocity

C-Consistency

I-Isolation

D-Durability

Observer pattern defines.......?

One to Many Relation

Network Cable lines on----------layer


Physical Layer

DBCC stands for............

Database Console Commands

Is it possible to access one aspx page's view state data into another aspx page? If so, How?


possible through cross page post back

What is the purpose of machine key in asp.net?

To encrypt forms authentication tickets and to encrypt ViewState

Write the sql query for entering a comma-separated string into a table

select data from dbo.split('string1.string2,string3', ',')

How many types of SQL Replication are there

3 Types

What is SQL Replication?

Replication is a set of technologies for copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency

What is Code Name of Sql Server 2011..?

Denali

What is the Code Name of Sql Server 2005..?

Yukon

Whats the purpose of Linked Server in microsoft sql server?

 Remote server access

Thursday, October 4, 2012

What is Service Broker?

Service Broker is a message-queuing technology in SQL Server that allows developers to integrate SQL Server fully into distributed applications. Service Broker is feature which provides facility to SQL Server to send an asynchronous, transactional message. it allows a database to send a message to another database without waiting for the response, so the application will continue to function if the remote database is temporarily unavailable.




What are the basic functions for master, msdb, model, tempdb and resource databases?

The master database holds information for all databases located on the SQL Server instance and is theglue that holds the engine together. Because SQL Server cannot start without a functioning masterdatabase, you must administer this database with care.


The msdb database stores information regarding database backups, SQL Agent information, DTS packages, SQL Server jobs, and some replication information such as for log shipping.

The tempdb holds temporary objects such as global and local temporary tables and stored procedures.

The model is essentially a template database used in the creation of any new user database created in the instance.

The resoure Database is a read-only database that contains all the system objects that are included with SQL Server. SQL Server system objects, such as sys.objects, are physically persisted in the Resource database, but they logically appear in the sys schema of every database. The Resource database does not contain user data or user metadata.

Wednesday, October 3, 2012

Value Type Vs Reference Type

VALUE TYPE
-
Value type derives from System.ValueType which derives from System.Object
-Value types directly contains their values
-
When you copy from one value type variable to another it copies all the data. So if you change one variable it does not affect another variable.
-Value Type are stored in Stack.
-
Value type has default value. For eg: int i; So i has default value of 0.
-
Runtime can create, delete, remove the value type quickly. So no garbage collection needed.
-
It does not contain null values unless you can make it as nullable type.
-There are three categories in value type
1Built-in Type
- Integral type (sbyte, byte, char, short, ushort, int, uint, long, ulong)
- Floating point type (float, double)
- Decimal type (decimal)
2Bool
3Struct,Enum
REFERENCE TYPE
-
Reference Type is derive from System.Object
-
Reference Type variable stores address of their data.
-
It has the pointer to points to the data.
-
When you copy from one reference type variable to another it copies only the reference. So if you change one variable it will affect another.
-
Reference types are stored in the Heap.
-
Reference types always has null values.
-
The memory used by the reference type will handled by Garbage Collection.
-
Class, Interface, Object, String, Arrays, Stream, Exception, Delegate, StringBuilder are the reference type.

TYPES IN C#

C# is a strongly typed language. Each variable and constants has type. A type has following information:


- It specifies the storage space that the type occupies.

- The location of the memory of that type occupies.

- The base type that it inherits from.



There are two built in types in C#.


1. Value Type

2. Reference Type.



 

VALUE TYPE



- Value type derives from System.ValueType which derives from System.Object.

- Value types directly contains their values.

- When you copy from one value type variable to another it copies all the data. So if you change one variable it does not affect another variable.

- Value Type are stored in Stack.

- Value type has default value. For eg: int i; So i has default value of 0.

- Runtime can create, delete, remove the value type quickly. So no garbage collection needed.

- It does not contain null values unless you can make it as nullable type.



There are three categories in value type.


1. Built in Type

- Integral type (sbyte, byte, char, short, ushort, int, uint, long, ulong)

- Floating point type (float, double)

- Decimal type (decimal)

2. Bool

2. Struct , Enum





REFERENCE TYPE


- Reference Type is derive from System.Object

- Reference Type variable stores address of their data.

- It has the pointer to points to the data.

- When you copy from one reference type variable to another it copies only the reference. So if you change one variable it will affect another

- Reference types are stored in the Heap.

- Reference types always has null values.

- The memory used by the reference type will handled by Garbage Collection

- Class, Interface, Object, String, Arrays, Stream, Exception, Delegate, StringBuilder are the reference type.