QuestPond’s Interview Questions & Answers on Design Pattern in .NET

What is a Composite Pattern?

During Programming there are times when we have a collection of objects with us and we want to treat collection of objects and individual objects uniformly.


  • Let’s say you are creating a complex user controls.
    Now the best part is controls like textbox, button and label should be treated in the same manner we treat controls like panel which in turn may consist of many controls.
    Here Composite pattern comes to picture.
  • Let’s say you are working on a logic which consist of working with file system. In this case you will be mainly working with files. Files may indicate simple flat files or folders which contain one or more files internally.
    We implement Composite pattern in this situation

How to implement Composite Pattern?

Let’s talk more about the control creation demo discussed above and let see how to implement composite pattern.

1. When it comes to implementing Composite pattern first thing we will do is identify all
the container (control which can contain more controls) and individual self-contained

Let’s say individual controls are Button and textbox. Composite control is Panel.

public class Panel{}
public class Button{}
public class Textbox{}

2. We want to treat both of them uniformly. Is simple words these two should be
belonging to same family and for that we need an interface containing
Render Method

public interface IControl{void Render();}

3. Implement the interface in all the classes and implement Render Method.

public class Textbox:IControl
Public void Render()
 //Render Textbox
public class Button:IControl
Public void Render()
 //Render Button
public class Panel:IControl
public ListChildControls{get;set;}
Public void Render()
	//Render Panel Start
	foreach(IControli in ChildControls)
	//Render Panel End

That’s it this is the composite pattern. A group of object and individual object will be treated same now.

For technical trainings on various topics like WCF, MVC, Business Intelligence, Design Patterns, WPF, TFS and Basic fundamentals feel free to contact or visit

For more stuff like this, click here. Subscribe to article updates or follow at twitter @SukeshMarla

See following video on Composite Pattern: -

Click and see here for more training on Design Pattern in .NET.

Posted in Uncategorized | Tagged , , , , , , , | Leave a comment

QuestPond’s Interview Questions & Answers on learning authentication in ASP.NET

What are the various ways of authentication techniques in ASP.NET?

There are 3 major ways of doing authentication and authorization:

  • Windows: – In this mode the users are stored in windows local user groups.
  • Forms: – In this mode we create a login screen and use the forms authentication class to do validations. It’s a ticket based authentication.
  • Passport: -In this mode the users are validated from Microsoft sites like hotmail , devhood , MSN etc , ticket is generated and that ticket can be used to do authentication and authorization in your web application.

How do I sign out in forms authentication?


If cookies are disabled how will forms authentication work?

It will pass data through query strings.

How do we implement windows authentication?

  • Create users in your local windows user group.
  • In web.config file set the authentication mode to windows.
  • In web.config file set <deny users=”?”/>.

Once you do the above three steps your pages will authenticated and authorized from the users stored in windows local user group.

How can we do single sign-on in ASP.NET?  

For single sign-on we need to use forms authentication and put the same machine key in the web.config files of all web applications who will participate in single sign on.

See following video on implementing ASP.NET Forms Authentication: -

Click and see here for more learning tutorials on ASP.NET.

Posted in Uncategorized | Tagged , , , , , , , , , , | Leave a comment

QuestPond: Interview Questions and Answers on learning ADO.NET

How can we fine-tune the command object when we are expecting a single row?

Again, CommandBehaviour enumeration provides two values Single Result and Single Row. If you are expecting a single value then pass “CommandBehaviour.SingleResult” and the query is optimized accordingly, if you are expecting single row then pass “CommandBehaviour.SingleRow” and query is optimized according to single row.

Which is the best place to store connection string in .NET projects?

Config files are the best places to store connection strings. If it is a web-based application “Web.config” file will be used and if it is a windows application “App.config” files will be used.

How do you fill the dataset? 

Create object ofdata adapterand call the fill command method of the adapter.

SqlDataAdapter objAdapter = new SqlDataAdapter(objCommand); 
DataSet objDataset = new DataSet(); 

What are the various methods provided by the dataset object to generate XML?

  •  ReadXML
                Read’s a XML document in to Dataset.
  • GetXML
               This is a function, which returns the string containing XML document.
  • Writexml
               This writes a XML data to disk.

How can we save all data from dataset?

Dataset has “AcceptChanges” method, which commits all the changes since last time “Acceptchanges” has been executed.

See following video on dataset is a disconnect while datareader is connected: -

Click and see here for more stuffs step by step learning ADO.NET.

Posted in Uncategorized | Tagged , , , , , , , , , | Leave a comment

QuestPond: Interview Questions/Answers on basics of .NET

What is an IL code?

It’s a CPU independent partially compiled code.

Note: - Half compiled means this code is not yet compiled to
machine/CPU specific instructions.

Why IL code is not fully compiled?

We do not know in what kind of environment.NET code will run. In other words we do not know what can be the end operating system, CPU configuration, machine configuration, security configuration etc. So the IL code is half compiled and on runtime this code is compiled to machine specific using the environmental properties (CPU, OS, machine configuration etc).

Who compiles the IL code and how does it work?

IL code is compiled by JIT (Just in time compiler).

Is it possible to view the IL code?

Yes by using ILDASM simple tool we can view an IL code of a DLL or EXE. In order to view IL code using ILDASM, go to visual studio command prompt and run “ILDASM.EXE”. Once ILDASM is running you view the IL code.

See following video on IL code, CLR, CTS, CAS: -

Click and see here for tutorials on learning basic of .NET.


Posted in Uncategorized | Tagged , , , , , , , , , | Leave a comment

QuestPond: Interview Questions and Answers on ADO.NET

Explain in detail the fundamental of connection pooling?

When a connection is opened first time, a connection pool is created and is based on the exact match of the connection string given to create the connection object. Connection pooling only works if the connection string is the same. If the connection string is different, then a new connection will be opened, and connection pooling will not be used.

Let us try to explain the same pictorially. In the above figure, you can see there are three requests “Request1”, “Request2”, and “Request3”. “Request1” and “Request3” have same connection string so no new connection object is created for “Request3” as the connection string is same. They share the same object “ConObject1”. However, new object “ConObject2” is created for “Request2” as the connection string is different.

Note: - The difference between the connection string is that
one has “User id=sa” and other has “User id=Testing”.

What is Maximum Pool Size in ADO.NET Connection String?

Maximum pool size decides the maximum number of connection objects to be pooled. Ifthe maximum pool size is reached and there is no usable connection available the requestis queued until connections are released back in to pool. So it’s always a good habit tocall the close or dispose method of the connection as soon as you have finishedwork with the connection object.

How to enable and disable connection pooling?

For .NET it is enabled by default but if you want to just make yourself double sure , set Pooling=true inthe connection string. To disable connection pooling set Pooling=false in connectionstring if it is an ADO.NET Connection.

If it is an OLEDBConnection object set OLEDB Services=-4 in the connection string.

See following video on ADO.NET Connection pooling: -

Click and see here for learning ADO.NET tutorials.

Posted in Uncategorized | Tagged , , , , , , , | Leave a comment

QuestPond: Interview Questions and Answers on learning ASP.NET

What are the different events which fire ASP.NET page life cycle?

Following is the sequence in which the events occur: -

  • Init
  • Load
  • Validate
  • Event
  • Render
Note: - Remember word SILVER: - S(Start) I(Init) L(Load)
V(Validate) E(Event) R(Render).

Page_init event only occurs when first time the page is started, but Page Load occurs in subsequent request of the page.

Can you explain how ASP.NET application life cycle works?

When interviewer asks for page life the SILVER answer is appropriate, but when interviewer is asking for application life cycle, two more things come in to picture handlers and modules.

Below is how ASP.NET events fire.

  • First the HttpModule events like BeginRequest, AuthenticateRequest fires.
  • Then the HttpHandlers fires if the file extension matches of the request page name.
  • Finally Page events fire i.e. in it, load , validate , event and render.

See following video on Authentication and Authorization: -

Click and see here for complete tutorials to learn ASP.NET


Posted in Uncategorized | Tagged , , , , , , , , , | Leave a comment

QuestPond: Interview Questions and Answers on OOPS basics of .NET

If we inherit a class do the private variables also get inherited?

Yes, the variables are inherited.

How can we stop the class from further inheriting?

We can stop the class from further inheriting by using the “Sealed” keyword. For instance below is a simple sample code where we have a class called as “Human” which is further inherited to create a “Male” or “Female” class.

Now the below code is great but we do not anyone to further inherit from “Male” or “Female” class. In simple words”Male” and “Female” are the last legs in this inheritance hierarchy. This can be done by using the “Sealed” keyword.

public class Human
public sealed class Male : Human
public sealed  class Female : Human

If anyone tries to inherit the sealed classes he will end with the below error “cannot derive from sealed type”. 

What is the use of “Must inherit” keyword in VB.NET?

If you want to create an abstract class in VB.NET it’s done by using “Must Inherit” keyword. You cannot create an object of a class, which is marked as “Must Inherit”. When you define “Must Inherit” keyword for class, you can only use the class by inheriting.

See following video on OOPS (Inheritance and Use of Virtual Keyword): -

Click and see here on Online .NET Training at QuestPond

Posted in Uncategorized | Tagged , , , , , , , , | Leave a comment

QuestPond for Freshers on IL code, JIT, CLR, CTS, CLS and CAS

IL code, JIT, CLR, CTS, CLS and CAS 

  • IL code is a partially compiled code.
  • JIT (Just in time compiler) compiles IL Code to machine language.
  • CLR (Common language run time) is the heart of.NET framework and it does 4 primary important things Garbage collection, CAS (Code Access security), CV (Code verification) and IL to Native translation.
  • CTS (Common types system) ensure that data types defined in two different languages get compiled to a common data type. 
  • CLS is a specification or set of rules or guidelines. When any programming language adheres to these set of rules it can be consumed by any .NET language.
  • CAS is the part of .NET security model which determines whether or not a particular code is allowed to run and what kind of resources can the code access.

This is basics of .NET which is based on .NET and C# interview questions with answers and also view following video on IL code, CLR, CTS, CAS: -

Posted in Uncategorized | Tagged , , , , , , , , , , , | Leave a comment

How to learn .NET: – In parent-child relationship which constructor will fire first and in which instances you will declare a constructor private?

Parent class constructor will fire first. Following is the code snippet: -

public class class1
public  class1(){}

public class class2 : class1
public  class2(){}

Declaring constructor to be private: -

When we create a private constructor, we cannot create object of the class.  Private constructors are used when we want only a single instance of the class to be created and externally no one can use the ‘new’ keyword to create the object.

See tutorials on .NET video for parent-child relationship: -

Posted in Uncategorized | Tagged , , , , , , , | Leave a comment

.NET OOPS interview questions: – How abstract with only abstract method is it different from interfaces? Also mention best practice to update interface with new methods?

If you define all methods, function, properties as abstract in abstract class it inhibits the same behavior as an interface.

Best practice to update interface with new methods: -

The biggest use of interface is to ensure that strict CONTRACT is followed between clients and components. So that when changes happen on the components clients do not have to change too much. In real world CONTRACTS between two parties do not change which implies that interfaces should also not change.

So if you want to add new methods or change methods in interfaces the best practice is to create new interfaces by inheriting. With this approach your older client who are using the interface stay happy and the new clients who want those new or changed methods get the benefits of the new functionality.

Let’s consider you have a simple interface called as “IView” which helps you to view data , below is the code for the same. Let’s consider that this interface is consumed by many clients.

interface Iview
        public void View();

Over a period of time some users demand “Edit” functionality as well but the rest of the users are happy with the ‘View” functionality and they do not want them to get affected by these changes. Now if you go and change this interface ( “IView”) a.k.a you will be disturbing everyone.

So the best option would be to add a new interface i.e. “IEdit” which inherits from “IView”. So the “IEdit” will have the functionality for “Edit” as well as “View” because it’s also inheriting from “IView”. And the clients who are consuming “IView” do not need to update as “IView’ is not changed at all.

interface IEdit : Iview
        public void Edit();

So putting this whole story in one single sentence for the interviewer.

Interface once fixed should not be changed. If we ever have
to add new functions, new interfaces should be created so that
we do not break compatibility with old clients.

See .NET OOPS interview questions video on implementing interfaces with same method names in C#: -

Posted in Uncategorized | Tagged , , , , , , , , , | Leave a comment