ASP.NET Interview Questions and Answers (1544) - Page 78

What are the following data types that support RangeValidator?

NOTE: This is objective type question, Please click question title for correct answer.
What is the difference between Web Form and Web Page?

All two are ASP.NET technologies for creating dynamic web applications

Web Pages focuses on adding server-side code and database access to the static page (HTML). Mainly good choice for developers who have experience with non-ASP.NET web technologies.

Web Forms is based on a page object model and traditional window-type controls (buttons, lists, etc.). It uses an event-based model. Good choice for those who have worked with Windows forms development.
We generally have this question in most of the interviews on Garbage collector 1) What is the need of Garbage Collector? 2) How does the Object Generations come into the picture? 3) How the objects get Disposed based on Generations? 4) Will an Object will be moved from One Generation to another? 5) Why there are multiple generations when we are anyways clearing the memory?

Garbage Collection is the most important topic which we hardly notice the use of it, Courtesy .Net CLR made it to run automatically without invoking it. Which made us lazy to understand what that is exactly used for.

Question 1: What is the need of Garbage Collector?
Answer 1: So when we ever we create any object using New operator the memory of that respective object gets stored in the Heap memory. So our application size increases when we tend to create more and more objects and sooner or later the Heap memory gets filled completely without even having space to save any object. Now in this case the Garbage Collector gets called automatically and checks for unused objects in that heap memory. So it cleans up those unused objects and allocates space for newly created Objects into Heap memory

Question 2: How does the Object Generations come into the picture?
Answer 2: The role of object generations comes into picture when CLR checks for objects which are no longer used in the application since a very long time and then Garbage collector will reclaim its memory.

Question 3: How the objects get Disposed based on Generations?
Answer 3: In general we have 3 generations for an object to travel which was written under the .Net framework library. By default the object goes into Generation 0.

Question 4: Will an Object will be moved from One Generation to another?
Answer 4: So when the Generation 0 objects gets completely occupied with memory now the Garbage collector will check for the objects which are unused for long time and will mark them for deletion and will move the remaining objects to Generation 1. Same is the behavior with Generation 2.

Question 5: Why there are multiple generations when we are anyways clearing the memory?
Answer 5: Because of having multiple generations the Garbage Collector need not check the entire Heap memory pool rather than it first checks for Generation 0 and will reclaim the memory. If it still needs it will check in Gen 1 and Gen 2. Which will decrease the time in finding the object and consequently enhancing the application performance.
Can we make all Ajax calls Cache free?

In our application development we generally use Ajax calls for Asynchronous calls which will have an issue with Cache.

That means it loads the Old content rather than the recently fetched dynamic content. So for that we can make the call to be Cache free.

Below is the code to make the Ajax call Cache Free

$.ajaxSetup ({

// Disable the caching of AJAX responses for all Ajax
cache: false
});

Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories