Thursday, February 23, 2012

Design Pattern Interview Questions

  1. Factory Design Pattern
  2. Abstract Factory Design Pattern
  3. Builder Design Pattern
  4. Prototype Design Pattern
  5. Singleton Design Pattern
  6. Adapter Design Pattern
  7. Bridge Design Pattern
  8. Composite Design Pattern
  9. Decorator Design Pattern
  10. Facade Design Pattern
  11. Flyweight Design Pattern
  12. Proxy Design Pattern
  13. Mediator Design Pattern
  14. Memento Design Pattern
  15. Interpreter Design Pattern
  16. Iterator Design Pattern
  17. COR Design Pattern
  18. Command Design Pattren
  19. State Design Pattern
  20. Strategy Design Pattern
  21. Observer Design Pattern
  22. Template Design Pattern
  23. Visitor Design Pattern
  24. Dependency IOC Design pattern

WCF, WPF, Silverlight, LINQ, Azure and EF 4.0 interview questions

  1. What is SOA, Services and Messages ?
  2. What is the difference between Service and Component?
  3. What are basic steps to create a WCF service ?
  4. What are endpoints, address, contracts and bindings?
  5. What are various ways of hosting WCF service?
  6. What is the difference of hosting a WCF service on IIS and Self hosting?
  7. What is the difference between BasicHttpBinding and WsHttpBinding?
  8. How can we do debugging and tracing in WCF?
  9. Can you explain transactions in WCF (theory)?
  10. How can we self host WCF service ?
  11. What are the different ways of implementing WCF Security?
  12. How can we implement SSL security on WCF(Transport Security)?
  13. How can we implement transport security plus message security in WCF ?
  14. How can we do WCF instancing ?
  15. How Can we do WCF Concurency and throttling?
  16. Can you explain the architecture of Silverlight ?
  17. What are the basic things needed to make a silverlight application ?
  18. How can we do transformations in SilverLight ?
  19. Can you explain animation fundamentals in SilverLight?
  20. What are the different layout methodologies in SilverLight?
  21. Can you explain one way , two way and one time bindings?
  22. How can we consume WCF service in SilverLight?
  23. How can we connect databases using SilverLight?
  24. What is LINQ and can you explain same with example?
  25. Can you explain a simple example of LINQ to SQL?
  26. How can we define relationships using LINQ to SQL?
  27. How can we optimize LINQ relationships queries using ‘DataLoadOptions’?
  28. Can we see a simple example of how we can do CRUD using LINQ to SQL?
  29. How can we call a stored procedure using LINQ?
  30. What is the need of WPF when we had GDI, GDI+ and DirectX?
  31. Can you explain how we can make a simple WPF application?
  32. Can you explain the three rendering modes i.e. Tier 0 , Tier 1 and Tier 2?
  33. Can you explain the Architecture of WPF?
  34. What is Azure?
  35. Can you explain Azure Costing?
  36. Can we see a simple Azure sample program?
  37. What are the different steps to create a simple Worker application?
  38. Can we understand Blobs in steps, Tables & Queues ?
  39. Can we see a simple example for Azure tables?
  40. What is Package and One click deploy(Deployment Part - 1) ?
  41. What is Web.config transformation (Deployment Part-2)?
  42. What is MEF and how can we implement the same?
  43. How is MEF different from DIIOC?
  44. Can you show us a simple implementation of MEF in Silverlight ?

Basic .NET, ASP.NET, OOPS and SQL Server Interview questions

  1. What is IL code, CLR, CTS, GAC & GC?
  2. How can we do Assembly versioning?
  3. can you explain how ASP.NET application life cycle and page life cycle events fire?
  4. What is the problem with Functional Programming?
  5. Can you define OOP and the 4 principles of OOP?
  6. What are Classes and Objects?
  7. What is Inheritance?
  8. What is Polymorphism, overloading, overriding and virtual?
  9. Can you explain encapsulation and abstraction?
  10. What is an abstract class?
  11. Define Interface & What is the diff. between abstract & interface?
  12. What problem does Delegate Solve ?
  13. What is a Multicast delegate ?
  14. What are events and what's the difference between delegates and events?
  15. How can we make Asynchronous method calls using delegates ?
  16. What is a stack, Heap, Value types and Reference types ?
  17. What is boxing and unboxing ?
  18. Can you explain ASP.NET application and Page life cycle ?
  19. What is Authentication, Authorization, Principal & Identity objects?
  20. How can we do Inproc and outProc session management ?
  21. How can we windows , forms and passport authentication and authorization in ASP.NET ?
  22. In a parent child relationship which constructor fires first ?

C#'s const vs. readonly

C#'s const vs. readonly

A quick synopsis on the differences between 'const' and 'readonly' in C#:
'const':
Can't be static.
Value is evaluated at compile time.
Initiailized at declaration only.

'readonly':
Can be either instance-level or static.
Value is evaluated at run time.
Can be initialized in declaration or by code in the constructor.

http Handlers vs. Modules

Modules are units of code that have registered for one or more pipeline events. They perform authentication, authorization, logging, etc. There is one task that is reserved for a special module, known as a handler. The handler’s unique job is to retrieve the resource that is requested in the URL. All resources served by IIS are mapped to a handler in configuration. If the configuration mapping does not exist, requests for the resource will receive a 404 HTTP status. In addition to the configuration mapping, which takes place before the pipeline begins, the handler mapping can be changed during request execution in the MAP_REQUEST_HANDLER event. This allows scenarios such as URL rewriting to work. Handlers are notified, or executed, in the EXECUTE_REQUEST_HANDLER step. (Note that only the mapped handler is notified, as you would expect.)

Friday, February 17, 2012

An Interface is a Value type or reference type?

Select from following answers:
  1. Value Type
  2. Reference Type
  3. Vaule type or reference type
  4. both

Because , Interface is a Contract, When we design Interface and implement it in other object , that object will implement this. So, when a struct implement an interface ,that time it is value type and in case of class it is reference type.

What are the different ways to deploy a assembly ?

Basically there are three different ways to deploy an assembly the are

1. Using a MSI Installer

2. Using a CAB archive

3. Using a XCOPY Command

exact difference between IQueryable and IEnumerable interface ?

IEnumerable is applicable for in-memory data querying, and in contrast IQueryable allows remote execution, like web service or database querying.

What is the difference between N-layer and N-tier architecture?

N-layers of application may reside on the same physical computer(same tier) and the components in each layer communicates with the components of other layer by well defined interfaces.Layered architecture focuses on the grouping of related functionality within an application into distinct layers that are stacked vertically on top of each other.Communication between layers is explicit and loosely coupled.With strict layering, components in one layer can interact only with componentsin the same layer or with components from the layer directly below it.


The main benefits of the layered architectural style are:
Abstraction,Isolation, Manageability, Performance, Reusability, Testability.


N-tiers architecture usually have atleast three separate logical parts,each located on separate physical server.Each tier is responsible with specific functionality.Each tier is completely independent from all other tier, except for those immediately above and below it.Communication between tiers is typically asynchronous in order to support better scalability.


The main benefit of tier architecture styles are
1.Maintainability. Because each tier is independent of the other tiers, updates or changes can be carried out without affecting the application as a whole.
2.Scalability. Because tiers are based on the deployment of layers, scaling out an application is reasonably straightforward.
3.Flexibility. Because each tier can be managed or scaled independently, flexibility is increased.
4.Availability. Applications can exploit the modular architecture of enabling systems using easily scalable components, which increases availability.

Difference between XElement and XDocument

Both are the classes defined by System.Xml.Linq namespace

XElement class
represents an XML fragment
XDocument class represents an entire XML document with all associated meta-data.

example:

XDocument d = new XDocument(
      new XComment("hello"),
      new XElement("book",
              new XElement("bookname", "ASP.NET"),
             new XElement("authorname", "techmedia"),
       )
);

Advantages and disadvantages of LINQ over Stored procedures

Below is the three advantages of LINQ over stored procedures.

Debugging - As debug point concern, as LINQ is part of .NET, we can use the visual studio's debugger to debug the queries but it is tough to debug the Stored procedure as it will not support the visual studio debugger.

Deployment - In case of deployment, we need to provide an additional script for stored procedures to execute but in case of LINQ, it will complie into single DLL hence deployment becomes easier.

Type Safety - As LINQ is type safe, the queries errors are type checked at compile time. Better suggest to use LINQ because it helps to encounter an error at the compile time rather than at runtime exception.
 
 
The disadvantage with LINQ is, it is not a precompiled statement where as stored procedures are precompiled. In case of LINQ the queries need to be compile before the execution. So according to this, I can say stored procedures are faster in performance as compared to LINQ.
 

Thursday, February 16, 2012

Removing some querystring values from collection

Below code is used for removing the query string parameters from the collection of parameters-

Dim isreadonly As PropertyInfo = GetType(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance Or BindingFlags.NonPublic)

' make collection editable
isreadonly.SetValue(HttpContext.Current.Request.QueryString, False, Nothing)

' remove
HttpContext.Current.Request.QueryString.Remove("uid")
HttpContext.Current.Request.QueryString.Remove("pwd")

HttpContext.Current.Response.Redirect(HttpContext.Current.Request.Url.AbsolutePath + "?" & Convert.ToString(HttpContext.Current.Request.QueryString))Rem

Monday, February 13, 2012

What is the difference between Authentication and authorization?

This can be a tricky question. These two concepts seem altogether similar but there is
wide range of difference. Authentication is verifying the identity of a user and authorization
is process where we check does this identity have access rights to the system. In short we
can say the following authentication is the process of obtaining some sort of credentials
from the users and using those credentials to verify the user’s identity. Authorization is
the process of allowing an authenticated user access to resources. Authentication always
proceed to Authorization; even if your application lets anonymous users connect and use
the application, it still authenticates them as being anonymous.

What is the difference between Server.Transfer and response.Redirect ?

Following are the major differences between them:-
√ Response.Redirect sends message to the browser saying it to move to some
different page, while server.transfer does not send any message to the browser
but rather redirects the user directly from the server itself. So in server.transfer
there is no round trip while response.redirect has a round trip and hence puts
a load on server.
√ Using Server.Transfer you can not redirect to a different from the server itself.
Example if your server is www.yahoo.com you can use server.transfer to move
to www.microsoft.com but yes you can move to www.yahoo.com/travels, i.e.
within websites. This cross server redirect is possible only using
Response.redirect.
√ With server.transfer you can preserve your information. It has a parameter
called as “preserveForm”. So the existing query string etc. will be able in the
calling page.

What is event bubbling ?

Server controls like Datagrid, DataList, Repeater can have other child controls inside
them. Example DataGrid can have combo box inside datagrid. These child control do not
raise there events by themselves, rather they pass the event to the container parent (which
can be a datagrid, datalist, repeater), which passed to the page as “ItemCommand” event.
As the child control send there events to parent this is termed as event bubbling.

Why is it preferred to not use finalize for clean up?

Problem with finalize is that garbage collection has to make two rounds in order to remove
objects which have finalize methods.
Below figure will make things clear regarding the two rounds of garbage collection rounds
performed for the objects having finalized methods.
In this scenario there are three objects Object1, Object2 and Object3. Object2 has the
finalize method overridden and remaining objects do not have the finalize method
overridden.
Now when garbage collector runs for the first time it searches for objects whose memory
has to free. He can see three objects but only cleans the memory for Object1 and Object3.
Object2 it pushes to the finalization queue.
Now garbage collector runs for the second time. He see’s there are no objects to be
released and then checks for the finalization queue and at this moment it clears object2
from the memory.
So if you notice that object2 was released from memory in the second round and not first.
That’s why the best practice is not to write clean up Non.NET resources in Finalize
method rather use the DISPOSE.

What is the difference between Class and structure’s ?

Following are the key differences between them :-
√ Structure are value types and classes are reference types. So structures use
stack and classes use heap.
√ Structures members can not be declared as protected, but class members can
be. You can not do inheritance in structures.
√ Structures do not require constructors while classes require.
√ Objects created from classes are terminated using Garbage collector. Structures
are not destroyed using GC.

What are similarities between Class and structure ?

Following are the similarities between classes and structures :-
√ Both can have constructors, methods, properties, fields, constants,
enumerations, events, and event handlers.
√ Structures and classes can implement interface.
√ Both of them can have constructors with and without parameter.
√ Both can have delegates and events.

What are the different accessibility levels defined in .NET ?


Following are the five levels of access modifiers :-
Private : Only members of class have access.
Protected :-All members in current class and in derived classes can access the
variables.
Friend (internal in C#) :- Only members in current project have access to the
elements.
Protected friend (protected internal in C#) :- All members in current project
and all members in derived class can access the variables.
Public :- All members have access in all classes and projects.

Difference between Shadowing and Overriding

Following are the differences between shadowing and overriding :-
√ Overriding redefines only the implementation while shadowing redefines the
whole element.
√ In overriding derived classes can refer the parent class element by using “ME”
keyword, but in shadowing you can access it by “MYBASE”.

What is shadowing ?

When two elements in a program have same name, one of them can hide and shadow the
other one. So in such cases the element which shadowed the main element is referenced.
Below is a sample code, there are two classes “ClsParent” and “ClsShadowedParent”. In
“ClsParent” there is a variable “x” which is a integer. “ClsShadowedParent” overrides
“ClsParent” and shadows the “x” variable to a string.
Note:- In Sample CD “WindowsShadowing” is folder which has the sample code. If you
run the program you can have two output’s one which shows a integer and other which shows
a string.
Public Class ClsParent
         Public x As Integer
End Class
Public Class ClsShadowedParent
       Inherits ClsParent 
       Public Shadows x As String
End Class

Different properties provided by Objectoriented systems

Following are characteristic’s of Object Oriented System’s :-

Abstraction
It allows complex real world to be represented in simplified manner. Example color is
abstracted to RGB. By just making the combination of these three colors we can achieve
any color in world.It’s a model of real world or concept.

Encapsulation
It is a process of hiding all the internal details of an object from the outside world.

Communication using messages
When application wants to achieve certain task it can only be done using combination of
objects. A single object can not do all the task. Example if we want to make order processing
form.We will use Customer object, Order object, Product object and Payment object to
achieve this functionality. In short these objects should communicate with each other.
This is achieved when objects send messages to each other.

Object lifetime
All objects have life time.Objects are created ,and initialized, necessary functionalities
are done and later the object is destroyed. Every object have there own state and identity
which differ from instance to instance.

Class hierarchies (Inheritance and aggregation)
This is the simplest relationship between objects. Example every customer has sales. So
Customer object and sales object have an association relation between them.

In object oriented world objects have relation and hierarchies in between them. There are
basically three kind of relationship in Object Oriented world :-
1.Association
This is the simplest relationship between objects. Example every customer has sales. So
Customer object and sales object have an association relation between them

2.Aggregation
This is also called as composition model. Example in order to make a “Accounts” class it
has use other objects example “Voucher”, “Journal” and “Cash” objects. So accounts
class is aggregation of these three objects.

3.Inheritance
Hierarchy is used to define more specialized classes based on a preexisting generalized
class. Example we have VEHICLE class and we can inherit this class make more
specialized class like CAR, which will add new attributes and use some existing qualities
of the parent class. Its shows more of a parent-child relationship. This kind of hierarchy
is called inheritance.


Polymorphism
When inheritance is used to extend a generalized class to a more specialized class, it
includes behavior of the top class(Generalized class). The inheriting class often implement
a behavior that can be somewhat different than the generalized class, but the name of the
behavior can be same. It is important that a given instance of an object use the correct
behavior, and the property of polymorphism allows this to happen automatically.

What is the relation between Classes and Objects ?

They look very much same but are not same. Class is a definition, while object is a instance of the class created. Class is a blue print while objects are actual objects existing in real world. Example we have class CAR which has attributes and methods like Speed, Brakes, Type of Car etc. Class CAR is just a prototype, now we can create real time objects which can be used to provide functionality. Example we can create a Maruti car object with 100 km speed and urgent brakes.

What is OOPS, Class and Objects?

 What is Object Oriented Programming ?
It is a problem solving technique to develop software systems. It is a technique to think real world in terms of objects. Object maps the software model to real world concept. These objects have responsibilities and provide services to application or other objects.


What’s a Class ?
A class describes all the attributes of objects, as well as the methods that implement the behavior of member objects. It’s a comprehensive data type which represents a blue print of objects. It’s a template of object.


What’s an Object ?
It is a basic unit of a system. An object is an entity that has attributes, behavior, and identity. Objects are members of a class. Attributes and behavior of an object are defined by the class definition.