Any one help me by providing question book collection for ASP net?
and also please describing following questions.
With EXAMPLE....
View stage and view stage life span
Different types of caching
Difference between delete and truncate
Can primary key is a foreign key on the same table
Delegates
Sealed class
Abstract
Shadowing
Serialization
Assembly
Assembly contains
Manifest contains
What is ddl
Session stage options
Web form events
Pure polymorphism
How a base class method is hidden
Method overloading
What is a store procedure? Stage its advantage
Different between unique and primary key
What is a cursor
What is a linked server
Loading
Satyapriya NayakPosted Jan 24, 2012, 10:33 PM
Rest part
What are the contents of assembly?
In general, a static assembly can consist of four elements:
The assembly manifest, which contains assembly metadata.
Type metadata.
Microsoft intermediate language (MSIL) code that implements the types.
A set of resources.
What is Manifest?
Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the following things
Version of assembly
Security identity
Scope of the assembly
Resolve references to resources and classes.
The assembly manifest can be stored in either a PE file (an .exe or .dll) with
Microsoft intermediate language (MSIL) code or in a stand-alone PE file that contains only assembly manifest information.
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.
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As New raj2
MsgBox(a.x)
'Dim b As New raj1
'MsgBox(b.x)
End Sub
Public Class raj1
Public x As Integer = 10
End Class
Public Class raj2
Inherits raj1
Public Shadows ReadOnly Property x() As Integer
Get
Return 16
End Get
End Property
End Class
End Class
What is serialization?
Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process of creating an object from a stream of bytes. Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database). Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created.
Binary serialization preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application. For example, you can share an object between different applications by serializing it to the clipboard. You can serialize an object to a stream, disk, memory, over the network, and so forth. Remoting uses serialization to pass objects "by value" from one computer or application domain to another.
XML serialization serializes only public properties and fields and does not preserve type fidelity. This is useful when you want to provide or consume data without restricting the application that uses the data. Because XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is an open standard, which makes it an attractive choice.
There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code.
What is Delegates?
It is a procedure pointer, which stores the memory address of another procedure. It can be applied with
1.Sub procedure
2.Function procedure
But not property procedure.
Delegate is a class that can hold a reference to a method or a function. Delegate class has
a signature and it can only reference those methods whose signature is compliant with the
class. Delegates are type-safe functions pointers or callbacks.
Program
Ex:-
Public Class Form1
Delegate Sub abhisek(ByVal x As Integer, ByVal y As Integer)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As abhisek
a = AddressOf rajiv
a.Invoke(10, 20)
End Sub
Public Sub rajiv(ByVal x As Integer, ByVal y As Integer)
Dim z As Integer
z = x + y
MsgBox(z)
End Sub
End Class
Ex2
Public Class Form2
Delegate Sub raj(ByVal x As String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As raj
x = AddressOf rajiv
x.Invoke("Adarsh kumar")
End Sub
Private Sub rajiv(ByVal s As String)
MsgBox("Hello:" & s)
End Sub
End Class
What's an abstract class?
A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.
What is Polymorphism?
It is a feature that allows one interface to be used for general class of actions. The specific action is determined by the exact nature of the situation. In general polymorphism means "one interface, multiple methods", this means that it is possible to design a generic interface to a group of related activities. This helps reduce complexity by allowing the same interface to be used to specify a general class of action. It is the compiler's job to select the specific action (that is, method) as it applies to each situation
What is Method overloading?
Method overloading occurs when a class contains two methods with the same name, but different signatures.
Ex:-
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call pintu(60, 30)
Call pintu("rahul")
End Sub
Public Sub pintu(ByVal x As Integer, ByVal y As Integer)
Dim z As Integer
z = x / y
MsgBox(z)
End Sub
Public Sub pintu(ByVal s As String)
MsgBox("hello" & s)
End Sub
End Class
How a base class method is hidden?
Overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.
Public Class Form1
Inherits System.Windows.Forms.Form
Dim a As New sagar1
Dim b As New sagar2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(a.amit(10, 20))
MsgBox(b.amit(5, 10))
End Sub
Public Class sagar1
Public Overridable Function amit(ByVal x As Integer, ByVal y As Integer)
Dim z As Integer
z = x + y
Return z
End Function
End Class
Public Class sagar2
Inherits sagar1
Public Overrides Function amit(ByVal x As Integer, ByVal y As Integer)
Dim z As Integer
z = MyBase.amit(x, y) * 5
Return z
End Function
End Class
End Class
What is assembly?
Assembly is unit of deployment like EXE or a DLL.
An assembly consists of one or more files (dlls, exe's, html files etc.), and
represents a group of resources, type definitions, and implementations of those
types. An assembly may also contain references to other assemblies. These
resources, types and references are described in a block of data called a manifest.
The manifest is part of the assembly, thus making the assembly self-describing.
An assembly is completely self-describing.An assembly contains metadata
information, which is used by the CLR for everything from type checking and
security to actually invoking the components methods.As all information is in
assembly itself it is independent of registry.This is the basic advantage as
compared to COM where the version was stored in registry.
Multiple versions can be deployed side by side in different folders. These
different versions can execute at the same time without interfering with each
other.Assemblies can be private or shared. For private assembly deployment,the
assembly is copied to the same directory as the client program that references
it.No registration is needed, and no fancy installation program is required.
When the component is removed, no registry cleanup is needed,and no uninstall
program is required. Just delete it from the hard drive.
In shared assembly deployment, an assembly is installed in the Global Assembly
Cache (or GAC). The GAC contains shared assemblies that are
globally accessible to all .NET applications on the machine.
What are Sealed classes?
Sealed classes are used to restrict the inheritance feature of object-oriented programming. Once a class is defined as sealedclass, this class cannot be inherited. In C#, the sealed modifier is used to define a class as sealed. In Visual Basic .NET, NotInheritable keyword serves the purpose of sealed. If a class is derived from a sealed class, compiler throws an error.
If you have ever noticed, structs are sealed. You cannot derive a class from a struct.
The following class definition defines a sealed class in C#:
// Sealed class
sealed class SealedClass
{
}
In the following code, I create a sealed class SealedClass and use it from Class1. If you run this code, it will work fine. But if you try to derive a class from sealed class, you will get an error.
using System;
class Class1
{
static void Main(string[] args)
{
SealedClass sealedCls = new SealedClass();
int total = sealedCls.Add(4, 5);
Console.WriteLine("Total = " + total.ToString());
}
}
// Sealed class
sealed class SealedClass
{
public int Add(int x, int y)
{
return x + y;
}
}
Why Sealed Classes?
We just saw how to create and use a sealed class. The main purpose of a sealed class to take away the inheritance feature from the user so they cannot derive a class from a sealed class. One of the best usage of sealed classes is when you have a class with static members. For example, the Pens and Brushes classes of the System.Drawing namespace.
The Pens class represent the pens for standard colors. This class has only static members. For example, Pens.Blue represents a pen with blue color. Similarly, the Brushes class represents standard brushes. The Brushes.Blue represents a brush with blue color.
So when you're designing your application, you may keep in mind that you have sealed classes to seal user's boundaries.
In the next article of this series, I will discuss some usage of abstractclasses.
What is Catching?
Catching:- It is a performance improvement technique.
1.It handles storage of frequently accessed data in the memory of the system so that user can access data very quickly.
2.It is used to store recently visited webpage.suppose we are surfing the site and watching various pages. At the time we want to go back to the previous page it loads the page from the memory instead of the server.
3.It has a disadvantage too. Suppose the website is continuously updated the user is not able to watch the changes.
ASP.Net provides three basic types of caching:
Page level output caching:
Page caching is mainly used for static pages, where the contents does not change. Output caching has the advantage of being incredibly simple to implement, and are sufficient in many cases.
This technique caches the output of a page so that content of pages are not generated every time it is loaded. Output caching simply keeps a copy of the HTML that was sent in response to a request in memory. In this case the subsequent requests are severed with the cached out until cache expires. This gives a great performance increase of web application.
Just add the OutputCache directive to the page you wish to cache.
for eg. <%@ OutputCache Duration="30" VaryByParam="none" %>
Code snippet:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Sample.aspx.cs" Inherits="Sample" %>
<%@ OutputCache Duration="10" VaryByParam="none"%>
Date time:
<% DateTime t = DateTime.Now;
Response.Write(t.ToString()); %>
This page is cached for 10 seconds. When this page was last cached the date/time was 1/1/2009 11:27:27 AM. When you refresh repeatedly this time remains constant until the cache is expired, then it is updated to the current time. So after 10 seconds, you can get the current time. This is because, ASP.Net caches the HTML using Output Caching.
Page Fragment Caching:
This type of technique is used when we need to cache only a part(or rather Fragment) of page instead of the whole page. Suppose, if we need to cache only header of a page, then instead of caching the whole page, its better to cache only header.
When you login to a website, you might find your name on the header. This happens with all the users. So header has to be stored in cache till he logs out. So the header has to be an user control. Fragment caching is applied to this user control.
Just add the OutputCache directive to the user control page you wish to cache.
for eg. <%@ OutputCache Duration="30" VaryByControl="Header1" %>
This will cache Header1 for 30 seconds
Data Caching:
Data caching is also called Application caching. It is much more powerful than the other two caching options. It caches data as objects and its scope is as that of the application. Here, an item is cached under a name , then extract it with the same name when required. Data caching is done using "cache" class.
Data caching is done in this way:
Cache["ID"] = EmployeeID;
Here EmployeeID is cached under "ID" key.
Now while extracting,
EmployeeID = Cache["ID"];
Where does cached data gets stored?
The location for cached data can be specified in OutputCache directive.
What are Web form events?
Refer the below link
http://www.codeproject.com/Articles/73181/ASP-NET-Web-Form-Model-with-Partial-Rendering-and
What are Session stage options?
Refer the below link
http://www.codeproject.com/Articles/7182/Session-management-options-in-ASP-NET
What is view state?
The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control
Thanks
newto netPosted Jan 25, 2012, 1:01 PM
newto netPosted Jan 24, 2012, 12:45 PM
Satyapriya NayakPosted Jan 24, 2012, 1:38 AM
Difference between delete and truncate
Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.
TRUNCATE
TRUNCATE is faster and uses fewer system and transaction log resources than DELETE.
TRUNCATE removes the data by deallocating the data pages used to store the table's data, and only the page deallocations are recorded in the transaction log.
TRUNCATE removes all rows from a table, but the table structure and its columns, constraints, indexes and so on remain. The counter used by an identity for new rows is reset to the seed for the column.
You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY constraint.Because TRUNCATE TABLE is not logged, it cannot activate a trigger.
TRUNCATE can not be Rolled back.
TRUNCATE is DDL Command.
TRUNCATE Resets identity of the table.
DELETE
DELETE removes rows one at a time and records an entry in the transaction log for each deleted row.If you want to retain the identity counter, use DELETE instead. If you want to remove table definition and its data, use the DROP TABLE statement.
DELETE Can be used with or without a WHERE clause
DELETE Activates Triggers.
DELETE Can be Rolled back.
DELETE is DML Command.
DELETE does not reset identity of the table.
What is a Linked Server?
Linked Servers is a concept in SQL Server by which we can add other SQL Server to a Group and query
both the SQL Server dbs using T-SQL Statements. With a linked server, you can create very clean, easy
to follow, SQL statements that allow remote data to be retrieved, joined and combined with local data.
Storped Procedure sp_addlinkedserver, sp_addlinkedsrvlogin will be used add new Linked Server.
What are cursors?
Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis,instead of the typical SQL commands that operate on all the rows in the set at one time.
In order to work with a cursor we need to perform some steps in the following order:
Declare cursor
Open cursor
Fetch row from the cursor
Process fetched row
Close cursor
Deallocate cursor
What's the difference between a primary key and a unique key?
Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique keyallows one NULL only.
What are stored procedures?
Its nothing but a set of T-SQL statements combined to perform a single task of several tasks. Its basically like a Macro so when you invoke the Stored Procedure, you actually run a set of statements. Stored Procedure is the precompiled set of sql command. Stored procedures means containing a precompiled block of code. if we call stored procedures they need not compiled, only execution takes place. With this advantage, work on database is less. With these sps we can perform business logics
What is ddl
In SQL, DDL stands for Data Definition Language. It is the part of SQL programming language that deals with the construction and alteration of database structures like tables, views, and further the entities inside these tables like columns. It may be used to set the properties of columns as well.
The three popular commands used in DDL are:
Create - Used to create tables, views, and also used to create functions, stored procedures, triggers, indexes etc.
-- An example of Create command below
CREATE TABLE t_students (
stud_id NUMBER(10) PRIMARY KEY,
first_name VARCHAR2(20) NULL,
last_name VARCHAR2(20) NOT NULL,
dateofbirth DATE NULL);
Drop - Used to totally eliminate a table, view, index from a database - which means that the records as well as the total structure is eliminated from the database.
-- An example of Drop command below
DROP TABLE t_students;
Alter - Used to alter or in other words, change the structure of a table, view, index. This is particularly used when there is a scenario wherein the properties of fields inside a table, view, index are supposed to be updated.
n An example of Alter command below
ALTER TABLE t_students ADD address VARCHAR2(200); -- adds a column ALTER TABLE t_students DROP COLUMN dateofbirth; -- drops a column ALTER TABLE t_students MODIFY COLUMN address VARCHAR2(100); -- drops a column
-- You can also modify multiple columns using a single modify clause ALTER TABLE t_students MODIFY
{
COLUMN address VARCHAR2(100)
COLUMN first_name VARCHAR2(50)
COLUMN last_name VARCHAR2(50)
};
-- You can also add constraints like NOT NULL using the Modify statement
ALTER TABLE t_students Modify
{ first_name VARCHAR2(50) NOT NULL };
ThanksSatyapriya NayakPosted Jan 24, 2012, 12:51 AM
To get all the answers of your above questions please visit the below link.
http://www.interviewcorner.com/
Thanks