Advanced interview questions for 6+ years of experience: Part 2


I have already posted important questions asked in various technical interviews. This is part 2 which includes remaining set of questions asked in face to face technical interviews. Be prepared! All the best!

C# / ASP.net/ .net framework / other .net related questions:
1 What is the difference between IEnumerable and IQuerable?
2 What is cross site scripting? (XSS)
3 If I want to see my website similar in all the browsers the what I need to do for that?
4 If say 1Lac users are using any particular website then what you will do to prevent crashing of server? Which care you will take at the time of coding?
5 Why to use design patterns?
6 If I have a class C and two interfaces I1 and I2 and I have add method inside both I1 and I2 then how to specify which one has to be called?
7 Garbage collection uses which type of algorithm? How it will find which object is unused?
8 What is the difference between out and ref?
9 Is it possible to use more than one out parameter?
10 Is it possible to use .js files used under script will be in body and not in header? Why?
11 When the document.get.ready function is called?
12 Which method of HttpHandler is invoked returning the markup for the requested file? Ans: ProcessRequest
13 What is application life cycle?
14 What are anonmous methods in c#?
15 What are extension methods in c#?
16 What are delegates?
17 What are multicast delegates?
18 What is difference between var and dynamic in c#?

WPF questions:
1) What is observable collection?
2) Where to keep css in WPF? It should be in resource file or where it supposed to be?
3) What are the layouts present in WPF?
4) What are advantages of WPF other than look and feel?
WCF questions
1) Why to use WCF service if http protocols are using in that? Webservice can also fulfils my requirement?
2) What are different bindings used in WCF?
3) How to handle errors in WCF?
4) What is fault contract?
5) What is the difference between basic binding tcp binding?
6) What is MSMQ?
7) What is message contract?
8) What is the difference between web service and wcf service?
9) How to create proxy client?

jquery questions:
1) How to avoid conflicts in jQuery amoung different libraries?
2) What is difference between jquery and javascript?


Comments

Author: Pawan Awasthi29 Jun 2013 Member Level: Gold   Points : 2

Hai Prachi,
Excellent questions for 6+ years experience guys. These questions will definitely be helpful for those who are preparing for the interview and belongs to 5+ years category.I will try to provide the answers for these questions in the coming days...
guys...keep looking this thread for all your queries..

Author: Prachi Kulkarni30 Jun 2013 Member Level: Gold   Points : 0

Thanks Pawan..

Author: Pawan Awasthi18 Aug 2013 Member Level: Gold   Points : 10


With lot of encouragement and support, I am posting the Part II of the questions and answers for 3-6 years experienced guys. These questions will be helpful for those who are preparing for the interview or attending the interviews. This will be helpful for the last minute preparation in quickest way.
If anyone has better answer, please reply to this post as that will be useful for all of us.

C# / ASP.net/ .Net framework / other .Net related questions:
1. What is the difference between IEnumerable and IQueryable?
Ans. IEnumerable and IQuerable are used to query data from database and collections. The IEnumerable is basically inherited from IQueryable, so it’s having all the features of the IQueryable in addition to its own features. Both have its own importance to query data and data manipulation
S.No IEnumerable IQueryable
1. Exists in System.Collections Namespace Exists in System.Linq Namespace
2. Can move to forward only in the collection. Can move to forward, backward or in between the items.
3. Best for collection like List, Array or in-memory collection Best for the collections which is out memory like services, remote databases etc
4. Suitable for LINQ to Object and Linq to XML queries. Suitable for Linq to SQL queries
5. It doesn’t supports custom query, Lazy loading so it’s not good for paging scenarios. It supports custom query using CreateQuery and Execute methods. Also support lazy loading so good for the paging scenarios.
6. The extension methods which supports be IEnumrable takes the functional objects as the parameters. The extension methods which supports be IEnumrable takes the expression tree expressions as the parameters.

In the first example (By using the IEnumerable), the generated SQL is as below:

In the second example (By using the IQueryable), the generated SQL is as below:

We can see that by using the IQueryable, the performance will increase as it has the TOP clause in the query.
2. What is cross site scripting? (XSS)
Ans. Cross-site scripting is the way to attacks and insert the vulnerabilities in Web page. This attack is injected by client-side code. The script which is inject by the client can embed itself in response data. The response data which send back to the malicious user. The browser can’t recognize the scripts as it is responded from the trusted source.
The cross-site scripting attacks also work on the HTTP and HTTPS.
There are 2 ways to prevent the cross site scripting attack:
a. Constrain input- Validate the input length, type, formatting, range etc.
b. Encode output- Send the input data with encode e.g. Encode to HTML
To prevent the cross-site attack, we can set the below attributes in web.config file:


3. If I want to see my website similar in all the browsers then what I need to do for that?
Ans. If you want to see the website with the same look and feel then you need to write the common css style which should be same for all browsers. Actually every browser will not support every css elements so it is not possible to use the same css to support all the browsers. You need to write the common css elements in the file and then apply it across the website. Else you need to write the separate css file as per the browser.

4. If say 1 Lac users are using any particular website then what you will do to prevent crashing of server? Which care you will take at the time of coding?
Ans. There are the ways like we can have multiple servers to handle the requests from the users. In this, we can have the Web Gardening concept where we can have the multiple web servers and then one main server to handle the number of requests and switch the requests to other servers.
5. Why to use design patterns?
Ans. Design Pattern is the way to solve the recurring problems which occur during the designing of the applications. As the requirements increases, the projects becomes complex and due to the complexity, it’s difficult to maintain it.
With the help of design patterns, we can reduce the complexity and with the help of OOPs paradigm, we can make our applications more efficient in all the ways.
According to the GoF (Gang of Four) company, the Design Patterns can be classified to 3 ways:-
• Creational Design Pattern
• Behavioral Design Pattern
• Structural Design pattern

6. If I have a class C and two interfaces I1 and I2 and I have add method inside I1 and I2 then how to specify which one has to be called?
Ans. By using the explicit implement interface, we can implement the same method which is defined in both the interfaces.
e.g.

The implementation will be as below:

7. Garbage collection uses which type of algorithm? How it will find which object is unused?
Ans. Mark-And-Release is the algorithm which the garbage collection uses to reclaim the memory of the unreferenced objects which are no longer used.
The algorithm Mark-and-Release work in 2 steps:-
a. In the first steps, it marks all the accessible objects of the heap memory. This is called as mark phase.
b. In the second step, scan the heap and reclaim all the unmarked objects by the Garbage Collection algorithm. This step is called as sweep phase.
Below are the algorithm steps:

For the detailed description, follow the below link:
http://www.brpreiss.com/books/opus5/html/page424.html
8. What is the difference between out and ref?
Ans: Ref and Out are the parameters which are used in the methods. [ ref] and [out] both allow the called method to modify a parameter. The difference between them is what happens before you make the call.
• [ref] means that the parameter has a value on it before going into the function. The called function can read and or change the value any time. The parameter goes in, then comes out
• [out] means that the parameter has no official value before going into the function. The called function must initialize it. The parameter only goes out.
So the main difference between the ref and out parameters is that the out parameter doesn’t need to be initialized while the ref parameter must be initialized before passing to the function.
9. Is it possible to use more than one out parameter?
Ans. As we know that the method always returns a single value but by using the out parameter, we can return multiple values from the method or function.
In C# we can write the small code snippet which will describe to return the multiple values using the out parameters:

We can also use the struct which will contain the multiple values as the return:

There is another way to return multiple values like using Tuple class (newly introduces in .Net 4.0). The tuple class can return the object which can contain multiple values in it.

10. Is it possible to use .js files used under script will be in body and not in header? Why?
Ans. The .js file is used in header because first the .js file should be loaded to the application and then rest of the content should be load.
Cont..

Author: Pawan Awasthi18 Aug 2013 Member Level: Gold   Points : 10

With lot of encouragement and support, I am posting the Part II of the questions and answers for 3-6 years experienced guys. These questions will be helpful for those who are preparing for the interview or attending the interviews. This will be helpful for the last minute preparation in quickest way.
If anyone has better answer, please reply to this post as that will be useful for all of us.

C# / ASP.net/ .Net framework / other .Net related questions:
1. What is the difference between IEnumerable and IQueryable?
Ans. IEnumerable and IQuerable are used to query data from database and collections. The IEnumerable is basically inherited from IQueryable, so it’s having all the features of the IQueryable in addition to its own features. Both have its own importance to query data and data manipulation
S.No IEnumerable IQueryable
1. Exists in System.Collections Namespace Exists in System.Linq Namespace
2. Can move to forward only in the collection. Can move to forward, backward or in between the items.
3. Best for collection like List, Array or in-memory collection Best for the collections which is out memory like services, remote databases etc
4. Suitable for LINQ to Objet and Linq to XML queries. Suitable for Linq to SQL queries
5. It doesn’t supports custom query, Lazy loading so it’s not good for paging scenarios. It supports custom query using CreateQuery and Execute methods. Also support lazy loading so good for the paging scenarios.
6. The extension methods which supports be IEnumrable takes the functional objects as the parameters. The extension methods which supports be IEnumrable takes the expression tree expressions as the parameters.

In the first example (By using the IEnumerable), the generated SQL is as below:

In the second example (By using the IQueryable), the generated SQL is as below:

We can see that by using the IQueryable, the performance will increase as it has the TOP clause in the query.
2. What is cross site scripting? (XSS)
Ans. Cross-site scripting is the way to attacks and insert the vulnerabilities in Web page. This attack is injected by client-side code. The script which is inject by the client can embed itself in response data. The response data which send back to the malicious user. The browser can’t recognize the scripts as it is responded from the trusted source.
The cross-site scripting attacks also work on the HTTP and HTTPS.
There are 2 ways to prevent the cross site scripting attack:
a. Constrain input- Validate the input length, type, formatting, range etc.
b. Encode output- Send the input data with encode e.g. Encode to HTML
To prevent the cross-site attack, we can set the below attributes in web.config file:


3. If I want to see my website similar in all the browsers then what I need to do for that?
Ans. If you want to see the website with the same look and feel then you need to write the common css style which should be same for all browsers. Actually every browser will not support every css elements so it is not possible to use the same css to support all the browsers. You need to write the common css elements in the file and then apply it across the website. Else you need to write the separate css file as per the browser.

4. If say 1 Lac users are using any particular website then what you will do to prevent crashing of server? Which care you will take at the time of coding?
Ans. There are the ways like we can have multiple servers to handle the requests from the users. In this, we can have the Web Gardening concept where we can have the multiple web servers and then one main server to handle the number of requests and switch the requests to other servers.
5. Why to use design patterns?
Ans. Design Pattern is the way to solve the recurring problems which occur during the designing of the applications. As the requirements increases, the projects becomes complex and due to the complexity, it’s difficult to maintain it.
With the help of design patterns, we can reduce the complexity and with the help of OOPs paradigm, we can make our applications more efficient in all the ways.
According to the GoF (Gang of Four) company, the Design Patterns can be classified to 3 ways:-
• Creational Design Pattern
• Behavioral Design Pattern
• Structural Design pattern

6. If I have a class C and two interfaces I1 and I2 and I have add method inside I1 and I2 then how to specify which one has to be called?
Ans. By using the explicit implement interface, we can implement the same method which is defined in both the interfaces.
e.g.

The implementation will be as below:

7. Garbage collection uses which type of algorithm? How it will find which object is unused?
Ans. Mark-And-Release is the algorithm which the garbage collection uses to reclaim the memory of the unreferenced objects which are no longer used.
The algorithm Mark-and-Release work in 2 steps:-
a. In the first steps, it marks all the accessible objects of the heap memory. This is called as mark phase.
b. In the second step, scan the heap and reclaim all the unmarked objects by the Garbage Collection algorithm. This step is called as sweep phase.
Below are the algorithm steps:

For the detailed description, follow the below link:
http://www.brpreiss.com/books/opus5/html/page424.html
8. What is the difference between out and ref?
Ans: Ref and Out are the parameters which are used in the methods. [ ref] and [out] both allow the called method to modify a parameter. The difference between them is what happens before you make the call.
• [ref] means that the parameter has a value on it before going into the function. The called function can read and or change the value any time. The parameter goes in, then comes out
• [out] means that the parameter has no official value before going into the function. The called function must initialize it. The parameter only goes out.
So the main difference between the ref and out parameters is that the out parameter doesn’t need to be initialized while the ref parameter must be initialized before passing to the function.
9. Is it possible to use more than one out parameter?
Ans. As we know that the method always returns a single value but by using the out parameter, we can return multiple values from the method or function.
In C# we can write the small code snippet which will describe to return the multiple values using the out parameters:

We can also use the struct which will contain the multiple values as the return:

There is another way to return multiple values like using Tuple class (newly introduces in .Net 4.0). The tuple class can return the object which can contain multiple values in it.

10. Is it possible to use .js files used under script will be in body and not in header? Why?
Ans. The .js file is used in header because first the .js file should be loaded to the application and then rest of the content should be load.
Cont..

Author: Phagu Mahato21 Aug 2013 Member Level: Gold   Points : 6

Thanks Kulkani for posting Interview question for 6+ years experience. I have been trying to solve some question for last few days . Answer of your questions are given below:
Q No:#16 What are delegates?
Answer :- Another useful innovation of C# language is called delegates which basically serve the same purpose as function pointers in C++ . However , delegates are type-safe , secure managed objects. That means run-time guarantee that a delegate point into a valid method.

Q no#17 What are multicast delegates?
Multicast Delegates one of the special feature of delegates that a single delegates may encapsulate into more than one method. Multicast delegates are the sub set of System.Multicast Delegates.
There are following example of Multicast Delegates
delegate Void Your MultiDelegates (int a,int b)
Youy can add Multicast Delegates by using "+ ="sign assignment operators like YourMethod += new yourMulticastDelegates(Addition);



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: