This blog contains questions generally asked in ASP.Net interviews along with their relevant answers
Saturday, February 4, 2012
What's new in C# 3.5 ?
° Anonymous Types for LINQ
° Implicitly Typed Local Variables - The var Keyword
° Extension Methods
° Object and Collection Initializers
° Lambda Expressions
Saturday, January 28, 2012
What are the types of polymorphism ?
- Static (Compile time): Function Overloading, Operator Overloading
- Dynamic (Run time): Virtual Functions
What is object slicing ?
Example:
Class Base
{
public int i;
};
class Derived : public Base
{
public int j;
};
int main()
{
Base objB;
Derived objD;
objB = objD;
//Here objD contains both i and j.
//But only i is copied to objB.
}
Friday, January 20, 2012
What is the difference between DELETE and TRUNCATE ?
- TRUNCATE is a DDL command whereas DELETE is a DML command.
- TRUNCATE is much faster than DELETE. Reason:When you type DELETE.all the data get copied into the Rollback Tablespace first.then delete operation get performed.Thatswhy when you type ROLLBACK after deleting a table ,you can get back the data(The system get it for you from the Rollback Tablespace).All this process take time.But when you type TRUNCATE,it removes data directly without copying it into the Rollback Tablespace.Thatswhy TRUNCATE is faster.Once you Truncate you cann't get back the data.
- You cann't rollback in TRUNCATE but in DELETE you can rollback.TRUNCATE removes the record permanently.
- In case of TRUNCATE ,Trigger doesn't get fired.But in DML commands like DELETE .Trigger get fired.
- You cann't use conditions(WHERE clause) in TRUNCATE.But in DELETE you can write conditions using WHERE clause
- TRUNCATE command resets the High Water Mark for the table but DELETE does not. So after TRUNCATE the operations on table are much faster.
How to maintain the scroll position of the page on postback ?
Note:- You can define this attribute for all pages by setting the maintainScrollPostitionOnPostback attribute (note that it is case-sensitive in configuration files) on the
What is the difference between website and webapplication ?
Web Application project model
- Provides the same Web project semantics as Visual Studio .NET 2003 Web projects.
- Has a project file (structure based on project files).
- Build model - all code in the project is compiled into a single assembly.
- Supports both IIS and the built-in ASP.NET Development Server.
- Supports all the features of Visual Studio 2005 (refactoring, generics, etc.) and of ASP.NET 2.0 (master pages, membership and login, site navigation, themes, etc).
- Using FrontPage Server Extensions (FPSE) are no longer a requirement.
Web Site project model
- No project file (Based on file system).
- New compilation model. (Read here or here for more details) and ...
- Dynamic compilation and working on pages without building entire site on each page view.
- Supports both IIS and the built-in ASP.NET Development Server.
- Each page has it's own assembly.
- Defferent code model. (Read here for more details)
Ok, all is great, but you want to create your web site now. Which model should you use?
- You need to migrate large Visual Studio .NET 2003 applications to VS 2005? use the Web Application project.
- You want to open and edit any directory as a Web project without creating a project file? use Web Site project.
- You need to add pre-build and post-build steps during compilation? use Web Application project.
- You need to build a Web application using multiple Web projects? use Web Application project.
- You want to generate one assembly for each page? use Web Site project.
- You prefer dynamic compilation and working on pages without building entire site on each page view? use Web Site project.
- You prefer single-page code model to code-behind model? use Web Site project.
For more information please visit
What are partial classes, what is the use of it in .net ?
.Net 2.0 provided us with new feature called partial classes. Using partial classes we can use multiple files to keep the code of same class. Yes - we can put some methods to one file and the others to another file. Although partial classes may be extremely useful they can be also used to ruin system's technical design if developers don't know what happens behind the compiler.
Visual Studio uses partial classes to keep Windows and Web forms automatically generated code separately of user written code behind the forms.