Shail Mishra's Blog....
Thursday, September 19, 2019
Thursday, May 8, 2014
Interview Questions For .Net
ADO .Net
1. What is the full form of ADO?
The full form of ADO is ActiveX Data Object.
2. Explain ADO.NET in brief.
ADO.NET is a very important feature of .NET Framework, which
is used to work with data that is stored in structured data sources, such as databases
and XML files. The following are some of the important features of ADO.NET:
Contains a number of classes that provide you with various
methods and attributes to manage the communication between your application and
data source.
Enables you to access different data sources, such as
Microsoft SQL Server, and XML, as per your requirements.
Provides a rich set of features, such as connection and
commands that can be used to develop robust and highly efficient data services
in .NET applications.
Provides various data providers that are specific to
databases produced by various vendors. For example, ADO.NET has a separate
provider to access data from Oracle databases; whereas, another provider is
used to access data from SQL databases.
3. What are major difference between classic ADO and
ADO.NET?
Following are some major differences between both
In ADO we have recordset and in ADO.NET we have dataset.
In recordset we can only have one table. If we want to
accommodate more than one tables. We need to do inner join and fill the
recordset. Dataset can have multiple tables.
All data persist in XML as compared to classic ADO where
data persisted in Binary format also.
4. What are the two fundamental objects in ADO.NET?
DataReader and DataSet are the two fundamental objects in
ADO.NET.
5. What are the benefits of using of ADO.NET in .NET 4.0.
The following are the benefits of using ADO.NET in .NET 4.0
are as follows:
Language-Integrated Query (LINQ) - Adds native data-querying
capabilities to .NET languages by using a syntax similar to that of SQL. This
means that LINQ simplifies querying by eliminating the need to use a separate
query language. LINQ is an innovative technology that was introduced in .NET
Framework 3.5.
LINQ to DataSet - Allows you to implement LINQ queries for
disconnected data stored in a dataset. LINQ to DataSet enables you to query
data that is cached in a DataSet object. DataSet objects allow you to use a
copy of the data stored in the tables of a database, without actually getting
connected to the database.
LINQ to SQL - Allows you to create queries for data stored
in SQL server database in your .NET application. You can use the LINQ to SQL
technology to translate a query into a SQL query and then use it to retrieve or
manipulate data contained in tables of an SQL Server database. LINQ to SQL
supports all the key functions that you like to perform while working with SQL,
that is, you can insert, update, and delete information from a table.
SqlClient Support for SQL Server 2008 - Specifies that with
the starting of .NET Framework version 3.5 Service Pack (SP) 1, .NET Framework
Data Provider for SQL Server (System.Data.SqlClient namespace) includes all the
new features that make it fully compatible with SQL Server 2008 Database
Engine.
ADO.NET Data Platform - Specifies that with the release of
.NET Framework 3.5 Service Pack (SP) 1, an Entity Framework 3.5 was introduced
that provides a set of Entity Data Model (EDM) functions. These functions are
supported by all the data providers; thereby, reducing the amount of coding and
maintenance in your application. In .NET Framework 4.0, many new functions,
such as string, aggregate, mathematical, and date/time functions have been
added.
6. Which namespaces are required to enable the use of
databases in ASP.NET pages?
The following namespaces are required to enable the use of
databases in ASP.NET pages:
The System.Data namespace.
The System.Data.OleDb namespace (to use any data provider,
such as Access, Oracle, or SQL)
The System.Data.SQLClient namespace (specifically to use SQL
as the data provider)
7. Explain the DataAdapter.Update() and
DataSet.AcceptChanges() methods.
The DataAdapter.Update() method calls any of the DML
statements, such as the UPDATE, INSERT, or DELETE statements, as the case may
be to update, insert, or delete a row in a DataSet. The DataSet.Acceptchanges()
method reflects all the changes made to the row since the last time the
AcceptChanges() method was called.
8. What is the meaning of object pooling?
Object pooling is a concept of storing a pool (group) of
objects in memory that can be reused later as needed. Whenever, a new object is
required to create, an object from the pool can be allocated for this request;
thereby, minimizing the object creation. A pool can also refer to a group of
connections and threads. Pooling, therefore, helps in minimizing the use of
system resources, improves system scalability, and performance.
9. Which properties are used to bind a DataGridView control?
The DataSource property and the DataMember property are used
to bind a DataGridView control.
10. What property must be set and what method must be called
in your code to bind the data from some data source to the Repeater control?
You must set the DataSource property and call the DataBind()
method.
11. Mention the namespace that is used to include .NET Data
Provider for SQL server in .NET code.
The System.Data.SqlClient namespace.
12. What is the difference between OLEDB Provider and
SqlClient?
With respect to usage, there is no difference between OLEDB
Provider and SqlClient. The difference lies in their performance. SqlClient is
explicitly used to connect your application to SQL server directly, OLEDB
Provider is generic for various databases, such as Oracle and Access including
SQL Server.
Therefore, there will be an overhead which leads to
performance degradation.
13. Name the two properties of the GridView control that
have to be specified to turn on sorting and paging.
The properties of the GridView control that need to be
specified to turn on sorting and paging are as follows:
The AllowSorting property of the Gridview control indicates
whether sorting is enabled or not. You should set the AllowSorting property to
True to enable sorting.
The AllowPaging property of the Gridview control indicates
whether paging is enabled or not. You should set the AllowPaging property to
True to enable paging.
14. Mention different types of data providers available in
.NET Framework.
.NET Framework Data Provider for SQL Server - Provides
access to Microsoft SQL Server 7.0 or later version. It uses the
System.Data.SqlClient namespace.
.NET Framework Data Provider for OLE DB - Provides access to
databases exposed by using OLE DB. It uses the System.Data.OleDb namespace.
.NET Framework Data Provider for ODBC - Provides access to
databases exposed by using ODBC. It uses the System.Data.Odbc namespace.
.NET Framework Data Provider for Oracle - Provides access to
Oracle database 8.1.7 or later versions. It uses the System.Data.OracleClient
namespace.
15. Which architecture does Datasets follow?
Datasets follow the disconnected data architecture.
16. What is the role of the DataSet object in ADO.NET?
One of the major component of ADO.NET is the DataSet object,
which always remains disconnected from the database and reduces the load on the
database.
17. What is a DataReader object?
The DataReader object helps in retrieving the data from a
database in a forward-only, read-only mode. The base class for all the DataReader
objects is the DbDataReader class.
The DataReader object is returned as a result of calling the
ExecuteReader() method of the Command object. The DataReader object enables
faster retrieval of data from databases and enhances the performance of .NET
applications by providing rapid data access speed. However, it is less
preferred as compared to the DataAdapter object because the DataReader object
needs an Open connection till it completes reading all the rows of the
specified table.
An Open connection to read data from large tables consumes
most of the system resources. When multiple client applications simultaneously
access a database by using the DataReader object, the performance of data
retrieval and other related processes is substantially reduced. In such a case,
the database might refuse connections to other .NET applications until other
clients free the resources.
18. How can you identify whether or not any changes are made
to the DataSet object since it was last loaded?
The DataSet object provides the following two methods to
track down the changes:
The GetChanges() method - Returns the DataSet object, which
is changed since it was loaded or since the AcceptChanges() method was
executed.
The HasChanges() method - Indicates if any changes occurred
since the DataSet object was loaded or after a call to the AcceptChanges()
method was made.
If you want to revert all changes since the DataSet object
was loaded, use the RejectChanges() method.
19. Which property is used to check whether a DataReader is
closed or opened?
The IsClosed property is used to check whether a DataReader
is closed or opened. This property returns a true value if a Data Reader is
closed, otherwise a false value is returned.
20. Name the method that needs to be invoked on the
DataAdapter control to fill the generated DataSet with data?
The Fill() method is used to fill the dataset with data.
21. What is the use of the Connection object?
The Connection object is used to connect your application to
a specific data source by providing the required authentication information in
connection string. The connection object is used according to the type of the
data source. For example, the OleDbConnection object is used with an OLE-DB
provider and the SqlConnection object is used with an MS SQL Server.
22. What is the use of the CommandBuilder class?
The CommandBuilder class is used to automatically update a
database according to the changes made in a DataSet.
This class automatically registers itself as an event
listener to the RowUpdating event. Whenever data inside a row changes, the
object of the CommandBuilder class automatically generates an SQL statement and
uses the SelectCommand property to commit the changes made in DataSet.
OLEDB provider in .NET Framework has the OleDbCommandBuiider
class; whereas, the SQL provider has the SqlCommandBuilder class.
23. Explain the architecture of ADO.NET in brief.
AD0.NET consists of two fundamental components:
The DataSet, which is disconnected from the data source and
does not need to know where the data that it holds is retrieved from.
The .net data provider, which allows you to connect your
application to the data source and execute the SQL commands against it.
The data provider contains the Connection, Command,
DataReader, and DataAdapter objects. The Connection object provides
connectivity to the database. The Command object provides access to database
commands to retrieve and manipulate data in a database. The DataReader object
retrieves data from the database in the readonly and forward-only mode. The
DataAdapter object uses Command objects to execute SQL commands. The
DataAdapter object loads the DataSet object with data and also updates changes
that you have made to the data in the DataSet object back to the database.
24. Describe the disconnected architecture of ADO.NET's data
access model.
ADO.NET maintains a disconnected database access model,
which means, the application never remains connected constantly to the data
source. Any changes and operations done on the data are saved in a local copy
(dataset) that acts as a data source. Whenever, the connection to the server is
re-established, these changes are sent back to the server, in which these
changes are saved in the actual database or data source.
25. What are the usages of the Command object in ADO.NET?
The following are the usages of the Command object in
AD0.NET:
The Command object in AD0.NET executes a command against the
database and retrieves a DataReader or DataSet object.
It also executes the INSERT, UPDATE, or DELETE command
against the database.
All the command objects are derived from the DbCommand
class.
The command object is represented by two classes: SqlCommand
and OleDbCommand.
The Command object provides three methods to execute
commands on the database:
The ExecuteNonQuery() method executes the commands and does
not return any value.
The ExecuteScalar() method returns a single value from a
database query.
The ExecuteReader() method returns a result set by using the
DataReader object.
26. What are the pre-requisites for connection pooling?
The prerequisites for connection pooling are as follows:
There must be multiple processes to share the same
connection describing the same parameters and security settings.
The connection string must be identical.
27. What is connection pooling?
Connection pooling refers to the task of grouping database
connections in cache to make them reusable because opening new connections
every time to a database is a time-consuming process. Therefore, connection
pooling enables you to reuse already existing and active database connections,
whenever required, and increasing the performance of your application.
You can enable or disable connection pooling in your
application by setting the pooling property to either true or false in
connection string. By default, it is enabled in an application.
28. What are the various methods provided by the DataSet
object to generate XML?
The various methods provided by the DataSet object to
generate XML are:
ReadXml() - Reads XML document into a DataSet object.
GetXml() - Returns a string containing an XML document.
WriteXml() - Writes an XML data to disk.
29. Out of Windows authentication and SQL Server
authentication, which authentication technique is considered as a trusted
authentication method?
The Windows authentication technique is considered as a
trusted authentication method because the username and password are checked
with the Windows credentials stored in the Active Directory.
The SQL Server Authentication technique is not trusted as
all the values are verified by SQL Server only.
30. How would you connect to a database by using .NET?
The connection class is used to connect a .NET application
with a database.
31. Which adapter should you use, if you want to get the
data from an Access database?
OleDbDataAdapter is used to get the data from an Access
database.
32. Which object is used to add a relationship between two
DataTable objects?
The DataRelation object is used to add relationship between
two DataTable objects.
33. What are different types of authentication techniques
that are used in connection strings to connect .NET applications with Microsoft
SQL Server?
.NET applications can use two different techniques to
authenticate and connect with SQL Server. These techniques are as follows:
The Windows Authentication option
The SQL Server Authentication option
34. Explain the new features in ADO.NET Entity Framework
4.0.
ADO.NET Entity Framework 4.0 is introduced in .NET Framework
4.0 and includes the following new features:
Persistence Ignorance - Facilitates you to define your own
Plain Old CLR Objects (POCO) which are independent of any specific persistence
technology.
Deferred or Lazy Loading - Specifies that related entities
can be loaded automatically whenever required. You can enable lazy loading in
your application by setting the DeferredLoadingEnabled property to true.
Self-Tracking Entities - Refers to the entities that are
able to track their own changes. These changes can be passed across process
boundaries and saved to the database.
Model-First Development - Allows you to create your own EDM
and then generate relational model (database) from that EDM with matching
tables and relations.
Built-in Functions - Enables you to use built-in SQL Server
functions directly in your queries.
Model-Defined Functions - Enables you to use the functions
that are defined in conceptual schema definition language (CSDL).
35. What is the difference between the Clone() and Copy()
methods of the DataSet class?
The Clone() method copies only the structure of a DataSet.
The copied structure includes all the relation, constraint, and DataTable
schemas used by the DataSet. The Clone() method does not copy the data, which
is stored in the DataSet.
The Copy() method copies the structure as well as the data
stored in the DataSet.
36. What is the use of DataView?
User-defined view of a table is contained in a DataView. A
complete table or a small section of table depending on some criteria can be
presented by an object of the DataView class. You can use this class to sort
and find data within DataTable.
The DataView class has the following methods:
Find() - Finds a row in a DataView by using sort key value.
FindRows() - Uses the sort key value to match it with the
columns of DataRowView objects. It returns an array of all the corresponding
objects of DataRowView whose columns match with the sort key value.
AddNew() - Adds a new row to the DataView object.
Delete() - Deletes the specified row from the DataView
object according to the specified index.
37. What are the parameters that control most of connection
pooling behaviors?
The parameters that control most of connection pooling
behaviors are as follows:
Connect Timeout
Max Pool Size
Min Pool Size
Pooling
38. How can you add or remove rows from the DataTable object
of DataSet?
The DataRowCollection class defines the collection of rows
for the DataTable object in a DataSet. The DataTable class provides the
NewRow() method to add a new DataRow to DataTable. The NewRow method creates a
new row, which implements the same schema as applied to the DataTable. The
following are the methods provided by the DataRowCollection object:
Add() - Adds a new row to DataRowCollection.
Remove()- Removes a DataRow object from DataRowCollection.
RemoveAt() - Removes a row whose location is specified by an
index number.
39. Explain in brief DataAdapter class in ADO.NET.
The DataAdapter class retrieves data from the database,
stores data in a dataset, and reflects the changes made in the dataset to the
database. The DataAdapter class acts as an intermediary for all the
communication between the database and the DataSet object. The DataAdapter
Class is used to fill a DataTable or DataSet Object with data from the database
using the Fill() method. The DataAdapter class applies the changes made in
dataset to the database by calling the Update() method.
The DataAdapter class provides four properties that
represent the database command:
SelectCommand, InsertCommand, DeleteCommand, and
UpdateCommand.
ASP.NET
1. What is ASP?
Active Server Pages (ASP), also known as Classic ASP, is a
Microsoft's server-side technology, which helps in creating dynamic and
user-friendly Web pages. It uses different scripting languages to create
dynamic Web pages, which can be run on any type of browser. The Web pages are
built by using either VBScript or JavaScript and these Web pages have access to
the same services as Windows application, including ADO (ActiveX Data Objects)
for database access, SMTP (Simple Mail Transfer Protocol) for e-mail, and the
entire COM (Component Object Model) structure used in the Windows environment.
ASP is implemented through a dynamic-link library (asp.dll) that is called by
the IIS server when a Web page is requested from the server.
2. What is ASP.NET?
ASP.NET is a specification developed by Microsoft to create
dynamic Web applications, Web sites, and Web services. It is a part of .NET
Framework. You can create ASP.NET applications in most of the .NET compatible
languages, such as Visual Basic, C#, and J#. The ASP.NET compiles the Web pages
and provides much better performance than scripting languages, such as
VBScript. The Web Forms support to create powerful forms-based Web pages. You
can use ASP.NET Web server controls to create interactive Web applications.
With the help of Web server controls, you can easily create a Web application.
3. What is the basic difference between ASP and ASP.NET?
The basic difference between ASP and ASP.NET is that ASP is
interpreted; whereas, ASP.NET is compiled. This implies that since ASP uses
VBScript; therefore, when an ASP page is executed, it is interpreted. On the
other hand, ASP.NET uses .NET languages, such as C# and VB.NET, which are
compiled to Microsoft Intermediate Language (MSIL).
4. In which event are the controls fully loaded?
Page load event guarantees that all controls are fully
loaded. Controls are also accessed in Page_Init events but you will see that
view state is not fully loaded during this event
5. How can we identify that the Page is Post Back?
Page object has an "IsPostBack" property, which
can be checked to know that is the page posted back.
6. What is the lifespan for items stored in ViewState?
The items stored in ViewState live until the lifetime of the
current page expires including the postbacks to the same page.
7. How information about the user's locale can be accessed?
The information regarding a user's locale can be accessed by
using the System.Web.UI.Page.Culture property.
8. What is the difference between SQL notification and SQL
invalidation?
The SQL cache notification generates notifications when the
data of a database changes, on which your cache item depends. The SQL cache
invalidation makes a cached item invalid when the data stored in a SQL server
database changes.
9. Which is the parent class of the Web server control?
The System.Web.UI.Control class is the parent class for all
Web server controls.
10. Can you set which type of comparison you want to perform
by the CompareValidator control?
Yes, by setting the Operator property of the
CompareValidator control.
11. What is the behavior of a Web browser when it receives
an invalid element?
The behavior of a Web browser when it receives an invalid
element depends on the browser that you use to browse your application. Most of
the browsers ignore the invalid element; whereas, some of them display the
invalid elements on the page.
12. What are the advantages of the code-behind feature?
The code-behind feature of ASP.NET offers a number of
advantages:
Makes code easy to understand and debug by separating
application logic from HTML tags
Provides the isolation of effort between graphic designers
and software engineers
Removes the problems of browser incompatibility by providing
code files to exist on the Web server and supporting Web pages to be compiled
on demand.
13. How do you sign out from forms authentication?
The FormsAuthentication.Signout() method is used to sign out
from the forms authentication.
14. What is AutoPostBack?
If you want a control to postback automatically when an
event is raised, you need to set the AutoPostBack property of the control to
True.
15. What is the function of the ViewState property?
The ASP.NET 4.0 introduced a new property called
ViewStateMode for the Control class. Now you can enable the view state to an
individual control even if the view state for an ASP.NET page is disabled.
16. Why do you use the App_Code folder in ASP.NET?
The App_Code folder is automatically present in the project.
It stores the files, such as classes, typed data set, text files, and reports.
If this folder is not available in the application, you can add this folder.
One of the important features of the App_Code folder is that only one dll is
created for the complete folder, irrespective of how many files it contains.
17. Define a multilingual Web site.
A multilingual Web site serves content in a number of
languages. It contains multiple copies for its content and other resources,
such as date and time, in different languages.
18. What is an ASP.NET Web Form?
ASP.NET Web forms are designed to use controls and features
that are almost as powerful as the ones used with Windows forms, and so they
are called as Web forms. The Web form uses a server-side object model that
allows you to create functional controls, which are executed on the server and
are rendered as HTML on the client. The attribute, runat="server",
associated with a server control indicates that the Web form must be processed
on the server.
19. What is the difference between a default skin and a
named skin?
The default skin is applied to all the Web server controls
in a Web form, which are of similar type, and it does not provide a Skin ID
attribute. The named skin provides a Skin ID attribute and users have to set
the Skin ID property to apply it.
20. What is IIS? Why is it used?
Internet Information Services (IIS) is created by Microsoft
to provide Internet-based services to ASP.NET Web applications. It makes your
computer to work as a Web server and provides the functionality to develop and
deploy Web applications on the server. IIS handles the request and response
cycle on the Web server. It also offers the services of SMTP and FrontPage
server extensions. The SMTP is used to send emails and use FrontPage server
extensions to get the dynamic features of IIS, such as form handler.
21. What is Query String? What are its advantages and
limitations?
The Query String helps in sending the page information to
the server.
The Query String has the following advantages:.....
1)Every browser works with Query Strings.
2)It does not require server resources and so does not exert
any kind of burden on the server.
The following are the limitations of Query String:
1)Information must be within the limit because URL does not
support many characters.
2)Information is clearly visible to the user, which leads to
security threats.
22. What is actually returned from server to the browser
when a browser requests an .aspx file and the file is displayed?
When a browser requests an .aspx file then the server
returns a response, which is rendered into a HTML string.
23. How can you display all validation messages in one
control?
The ValidationSummary control displays all validation messages
in one control.
24. Which two new properties are added in ASP.NET 4.0 Page
class?
The two new properties added in the Page class are
MetaKeyword and MetaDescription.
25. What is tracing? Where is it used?
Tracing displays the details about how the code was
executed. It refers to collecting information about the application while it is
running. Tracing information can help you to troubleshoot an application. It
enables you to record information in various log files about the errors that
might occur at run time. You can analyze these log files to find the cause of
the errors.
In .NET, we have objects called Trace Listeners. A listener
is an object that gets the trace output and stores it to different places, such
as a window, a file on your locale drive, or a SQL Server.
The System.Diagnostics namespace contains the predefined
interfaces, classes, and structures that are used for tracing. It supplies two
classes, Trace and Debug, which allow you to write errors and logs related to
the application execution. Trace listeners are objects that collect the output
of tracing processes.
26. What is the difference between authentication and
authorization?
Authentication verifies the identity of a user and
authorization is a process where you can check whether or not the identity has
access rights to the system. In other words, you can say that authentication is
a procedure of getting some credentials from the users and verify the user's
identity against those credentials. Authorization is a procedure of granting
access of particular resources to an authenticated user. You should note that
authentication always takes place before authorization.
27. How can you register a custom server control to a Web
page?
You can register a custom server control to a Web page using
the @Register directive.
28. Which ASP.NET objects encapsulate the state of the
client and the browser?
The Session object encapsulates the state of the client and
browser.
29. Differentiate globalization and localization.
The globalization is a technique to identify the specific
part of a Web application that is different for different languages and make
separate that portion from the core of the Web application. The localization is
a procedure of configuring a Web application to be supported for a specific
language or locale.
30. What is ViewState?
The ViewState is a feature used by ASP.NET Web page to store
the value of a page and its controls just before posting the page. Once the
page is posted, the first task by the page processing is to restore the
ViewState to get the values of the controls.
31. Which method is used to force all the validation
controls to run?
The Page.Validate() method is used to force all the
validation controls to run and to perform validation.
32. Which method has been introduced in ASP.NET 4.0 to
redirect a page permanently?
The RedirectPermanent() method added in ASP.NET 4.0 to
redirect a page permanently. The following code snippet is an example of the
RedirectPermanent() method:
RedirectPermanent("/path/Aboutus.aspx");
33. How can you send an email message from an ASP.NET Web
page?
You can use the System.Net.Mail.MailMessage and the
System.Net.Mail.SmtpMail classes to send an email in your Web pages. In order
to send an email through your mail server, you need to create an object of the
SmtpClient class and set the server name, port, and credentials.
34. What is the difference between the Response.Write() and
Response.Output.Write() methods?
The Response.Write() method allows you to write the normal
output; whereas, the Response.Output.Write() method allows you to write the
formatted output.
35. What does the Orientation property do in a Menu control?
Orientation property of the Menu control sets the horizontal
or vertical display of a menu on a Web page. By default, the orientation is
vertical.
36. Differentiate between client-side and server-side
validations in Web pages.
Client-side validations take place at the client end with
the help of JavaScript and VBScript before the Web page is sent to the server.
On the other hand, server-side validations take place at the server end.
37. How does a content page differ from a master page?
A content page does not have complete HTML source code;
whereas a master page has complete HTML source code inside its source file.
38. Suppose you want an ASP.NET function (client side)
executed on the MouseOver event of a button. Where do you add an event handler?
The event handler is added to the Add() method of the
Attributes property.
39. What is the default timeout for a Cookie?
The default time duration for a Cookie is 30 minutes.
40. What are HTTP handlers in ASP.NET?
HTTP handlers, as the name suggests, are used to handle user
requests for Web application resources. They are the backbone of the
request-response model of Web applications. There is a specific event handler
to handle the request for each user request type and send back the
corresponding response object.
Each user requests to the IIS Web server flows through the
HTTP pipeline, which refers to a series of components (HTTP modules and HTTP
handlers) to process the request. HTTP modules act as filters to process the
request as it passes through the HTTP pipeline. The request, after passing
through the HTTP modules, is assigned to an HTTP handler that determines the
response of the server to the user request. The response then passes through
the HTTP modules once again and is then sent back to the user.
You can define HTTP handlers in the <httpHandlers> element
of a configuration file. The <add> element tag is used to add new
handlers and the <remove> element tag is used to remove existing
handlers. To create an HTTP handler, you need to define a class that implements
the IHttpHandler interface.
41. What are the events that happen when a client requests
an ASP.NET page from IIS server?
The following events happen when a client requests an
ASP.NET page from the IIS server:
User requests for an application resource.
The integrated request-processing pipeline receives the
first user request.
Response objects are created for each user request.
An object of the HttpApplication class is created and
allocated to the Request object.
The HttpApplication class processes the user request.
42. Explain file-based dependency and key-based dependency.
In file-based dependency, you have to depend on a file that
is saved in a disk. In key-based dependency, you have to depend on another
cached item.
43. How can you implement the postback property of an
ASP.NET control?
You need to set the AutoPostBack property to True to
implement the PostBack property of controls.
44. Explain how Cookies work. Give an example of Cookie
abuse.
The server tells the browser to put some files in a cookie,
and the client then sends all the cookies for the domain in each request. An
example of cookie abuse is large cookies affecting the network traffic.
45. Explain login controls.
Login controls are built-in controls in ASP.Net for
providing a login solution to ASP.NET application. The login controls use the
membership system to authenticate a user credentials for a Web site.
There are many controls in login controls.
ChangePassword control - Allows users to change their
password.
CreateUserWizard control - Provides an interface to the user
to register for that Web site.
Login control - Provides an interface for user
authentication. It consists of a set of controls, such as TextBox, Label,
Button, CheckBox, HyperLink.
LoginView control - Displays appropriate information to
different users according to the user's status.
LoginStatus control - Shows a login link to users, who are
not authenticated and logout link, who are authenticated
LoginName control - Displays a user name, if the user logs
in.
PasswordRecovery control - Allows users to get back the
password through an e-mail, if they forget.
46. What is the use of PlaceHolder control? Can we see it at
runtime?
The PlaceHolder control acts as a container for those
controls that are dynamically generated at runtime. We cannot see it at runtime
because it does not produce any visible output. It used only as a container.
47. What setting must be added in the configuration file to
deny a particular user from accessing the secured resources?
To deny a particular user form accessing the secured
resources, the web.config file must contain the following code:
<authorization >
<deny users="username" />
</authorization>
48. What are the event handlers that can be included in the
Global.asax file?
The Global.asax file contains some of the following
important event handlers:
Application_Error
Application_Start
Application_End
Session_Start
Session_End
49. What is the difference between page-level caching and
fragment caching?
In the page-level caching, an entire Web page is cached;
whereas, in the fragment caching, a part of the Web page, such as a user
control added to the Web page, is cached.
50. Make a list of all templates of the Repeater control.
The Repeater control contains the following templates:
ItemTemplate
AlternatingltemTemplate
SeparatorTemplate
HeaderTemplate
FooterTemplate
51. Describe the complete lifecycle of a Web page.
When we execute a Web page, it passes from the following
stages, which are collectively known as Web page lifecycle:
Page request - During this stage, ASP.NET makes sure the
page either parsed or compiled and a cached version of the page can be sent in
response
Start - During this stage sets the Request and Response page
properties and the page check the page request is either a postback or a new
request
Page Initialization - During this stage, the page initialize
and the control's Unique Id property are set
Load - During this stage, if the request is postback, the
control properties are loaded without loading the view state and control state
otherwise loads the view state
Validation - During this stage, the controls are validated
Postback event handling - During this stage, if the request
is a postback, handles the event
Rendering - During this stage, the page invokes the Render
method to each control for return the output
Unload - During this stage, when the page is completely
rendered and sent to the client, the page is unloaded.
52. How can you assign page specific attributes in an
ASP.NET application?
The @Page directive is responsible for this.
53. Which method is used to post a Web page to another Web
page?
The Respose.Redirect method is used to post a page to
another page, as shown in the following code snippet:
Response.Redirect("DestinationPageName.aspx");
54. What is a Cookie? Where is it used in ASP.NET?
Cookie is a lightweight executable program, which the server
posts to client machines. Cookies store the identity of a user at the first
visit of the Web site and validate them later on the next visits for their
authenticity. The values of a cookie can be transferred between the user's
request and the server's response.
55. What are Custom User Controls in ASP.NET?
The custom user controls are the controls that are defined
by developers. These controls are a mixture of custom behavior and predefined
behavior. These controls work similar to other Web server controls.
56. What does the .WebPart file do?
The .WebPart file explains the settings of a Web Parts
control that can be included to a specified zone on a Web page.
57. How can you enable impersonation in the web.config file?
To enable impersonation in the web.confing file, you need to
include the <identity> element in the web.config file and set the
impersonate attribute to true as shown in the following code snippet:
<identity impersonate = "true" />
58. How can you identify that the page is PostBack?
The Page object uses the IsPostBack property to check
whether the page is posted back or not. If the page is postback, this property
is set to true.
59. In which database is the information, such as
membership, role management, profile, and Web parts personalization, stored?
The aspnetdb database stores all information.
60. What is State Management? How many ways are there to
maintain a state in .NET?
State management is used to store information requests. The
state management is used to trace the information or data that affect the state
of the applications.
There are two ways to maintain a state in .NET, Client-Based
state management and Server-Based state management.
The following techniques can be used to implement the
Client-Based state management:
View State
Hidden Fields
Cookies
Query Strings
Control State
The following techniques can be used to implement
Server-Based state management:
Application State
Session State
Profile Properties
61. What do you understand by aggregate dependency?
Aggregate dependency allows multiple dependencies to be
aggregated for content that depends on more than one resource. In such type of
dependency, you need to depend on the sum of all the defined dependencies to
remove a data item from the cache.
62. How can you ensure that no one has tampered with
ViewState in a Web page?
To ensure that no one has tampered with ViewState in a Web
page, set the EnableViewStateMac property to True.
63. What is the difference between adding items into cache
through the Add() method and through the Insert() method?
Both methods work in a similar way except that the
Cache.Add() function returns an object that represents the item you added in
the cache. The Cache.Insert() function can replace an existing item in the
cache, which is not possible using the Cache.Add() method.
64. Explain the cookie less session and its working.
ASP.NET manages the session state in the same process that
processes the request and does not create a cookie. It is known as a cookie
less session. If cookies are not available, a session is tracked by adding a
session identifier to the URL. The cookie less session is enabled using the
following code snippet: <sessionState cookieless="true" />
65. What is a round trip?
The trip of a Web page from the client to the server and
then back to the client is known as a round trip.
66. What are the major built-in objects in ASP.NET?
The major built-in objects in ASP.NET are as follows:
Application
Request
Response
Server
Session
Context
Trace
67. Where should the data validations be performed-at the
client side or at the server side and why?
Data validations should be done primarily at the client side
and the server-side validation should be avoided because it makes server task
overloaded. If the client-side validation is not available, you can use
server-side validation. When a user sends a request to the server, the
validation controls are invoked to check the user input one by one.
68. Why do we need nested master pages in a Web site?
When we have several hierarchical levels in a Web site, then
we use nested master pages in the Web site.
69. How can you dynamically add user controls to a page?
User controls can be dynamically loaded by adding a Web User
Control page in the application and adding the control on this page.
70. What is the appSettings Section in the web.config file?
The web.config file sets the configuration for a Web
project. The appSettings block in configuration file sets the user-defined
values for the whole application.
For example, in the following code snippet, the specified
ConnectionString section is used throughout the project for database
connection:
<configuration>
<appSettings>
<add key="ConnectionString"
value="server=indiabixserver; pwd=dbpassword; database=indiabix"
/>
</appSettings>
...
71. What type of code, client-side or server-side, is found
in a code-behind file of a Web page?
A code-behind file contains the server-side code, which
means that the code contained in a code-behind file is executed at the server.
72. To which class a Web form belongs to in the .NET
Framework class hierarchy?
A Web form belongs to the System.Web.UI.Page class.
73. What does the "EnableViewState" property do?
Why do we want it On or Off?
The EnableViewState property enables the ViewState property
on the page. It is set to On to allow the page to save the users input between
postback requests of a Web page; that is, between the Request and corresponding
Response objects. When this property is set to Off, the page does not store the
users input during postback.
74. Which event determines that all the controls are
completely loaded into memory?
The Page_Load event determines that all the controls on the
page are fully loaded. You can also access the controls in the Page_Init event;
however, the ViewState property does not load completely during this event.
75. What is the function of the CustomValidator control?
It provides the customize validation code to perform both
client-side and server-side validation.
76. What is Role-based security?
In the Role-based security, you can assign a role to every
user and grant the privilege according to that role. A role is a group of
principal that restricts a user's privileges. Therefore, all the organization
and applications use role-based security model to determine whether a user has
enough privileges to perform a requested task.
77. Which data type does the RangeValidator control support?
The data types supported by the RangeValidator control are
Integer, Double, String, Currency, and Date.
78. What are the HTML server controls in ASP.NET?
HTML server controls are similar to the standard HTML
elements, which are normally used in HTML pages. They expose properties and
events that can be used programmatically. To make these controls
programmatically accessible, you need to specify that the HTML controls act as
a server control by adding the runat="server" attribute.
79. Why a SiteMapPath control is referred to as breadcrumb
or eyebrow navigation control?
The SiteMapPath control displays a hierarchical path to the
root Web page of the Web site. Therefore, it is known as the breadcrumb or
eyebrow navigation control.
80. Where is the ViewState information stored?
The ViewState information is stored in the HTML hidden
fields.
81. Which namespaces are necessary to create a localized
application?
The System.Globalization and System.Resources namespaces are
essential to develop a localized application.
82. What is the difference between an HtmlInputCheckBox
control and an HtmlInputRadioButton control?
You can select more than one HtmlInputCheckBox control from
a group of HtmlInputCheckBox controls; whereas, you can select only a single
HtmllnputRadioButton control from a group of HtmlInputRadioButton controls.
83. What is the difference between HTML and Web server
controls?
HTML controls are client-side controls; therefore, all the
validations for HTML controls are performed at the client side. On the other
hand, Web server controls are server-side controls; therefore, all the
validations for Web server controls are performed at the server side.
84. Explain the AdRotator Control.
The AdRotator is an ASP.NET control that is used to provide
advertisements to Web pages. The AdRotator control associates with one or many
advertisements, which randomly displays one by one at a time when the Web page
is refreshed. The AdRotator control advertisements are associated with links;
therefore, when you click on an advertisement, it redirects you to other pages.
The AdRotator control is associated with a data source,
which is normally an xml file or a database table. A data source contains all
the information, such as advertisement graphics reference, link, and alternate
text. Therefore, when you use the AdRotator control, you should first create a
data source and then associate it with the AdRotator control.
85. What do you understand by the culture?
The culture denotes a combination of a language and optionally
a region or a country. The contents of a Web page of a multilingual Web site
are changed according to the culture defined in the operating system of the
user accessing the Web page.
86. What is the difference between absolute expiration and
sliding-time expiration?
The absolute expiration expires a cached item after the
provided expiration time. The sliding time does not expire the cached items
because it increments the specified time.
87. What is the code-behind feature in ASP.NET?
The code-behind feature of ASP.NET enables you to divide an
ASP.NET page into two files - one consisting of the presentation data, and the
second, which is also called the code-behind file, consisting of all the
business logic. The presentation data contains the interface elements, such as
HTML controls and Web server controls, and the code-behind contains the
event-handling process to handle the events that are fired by these controls.
The file that contains the presentation data has the .aspx extension. The code
behind file has either the .cs extension (if you are using the programming
language C#) or the .vb (if you are using the programming language Visual Basic
.NET) extension.
88. How can you check if all the validation controls on a
Web page are valid and proper?
You can determine that all the validation controls on a Web
page are properly working by writing code in the source file of the Web page
using a scripting language, such as VBScript or JavaScript. To do this task,
you have to loop across validators collection of pages and check the IsValid
property of each validation control on the Web page to check whether or not the
validation test is successful.
89. Explain the validation controls. How many validation
controls in ASP.NET 4.0?
Validation controls are responsible to validate the data of
an input control. Whenever you provide any input to an application, it performs
the validation and displays an error message to user, in case the validation
fails.
ASP.NET 4.0 contains the following six types of validation
controls:
CompareValidator - Performs a comparison between the values
contained in two controls.
CustomValidator - Writes your own method to perform extra
validation.
RangeValidator- Checks value according to the range of
value.
RegularExpressionValidator - Ensures that input is according
to the specified pattern or not.
RequiredFieldValidator - Checks either a control is empty or
not.
ValidationSummary - Displays a summary of all validation
error in a central location.
90. What is difference between a Label control and a Literal
control?
The Label control's final html code has an HTML tag;
whereas, the Literal control's final html code contains only text, which is not
surrounded by any HTML tag.
91. How many types of Cookies are available in ASP.NET?
There are two types of Cookies available in ASP.NET:
Session Cookie - Resides on the client machine for a single
session until the user does not log out.
Persistent Cookie - Resides on a user's machine for a period
specified for its expiry, such as 10 days, one month, and never.
The user can set this period manually.
92. What is the use of the Global.asax file?
The Global.asax file executes application-level events and
sets application-level variables.
93. What are the Culture and UICulture values?
The Culture value determines the functions, such as Date and
Currency, which are used to format data and numbers in a Web page. The
UICulture value determines the resources, such as strings or images, which are
loaded for a Web page in a Web application.
94. What is the difference between ASP session and ASP.NET
session?
ASP does not support cookie-less sessions; whereas, ASP.NET
does. In addition, the ASP.NET session can span across multiple servers.
95. Which control will you use to ensure that the values in
two different controls match?
You should use the CompareValidator control to ensure that
the values in two different controls match.
96. What is the difference between a page theme and a global
theme?
A page theme is stored inside a subfolder of the App_Themes
folder of a project and applied to individual Web pages of that project. Global
themes are stored inside the Themes folder on a Web server and apply to all the
Web applications on the Web server.
97. What do you mean by a neutral culture?
When you specify a language but do not specify the
associated country through a culture, the culture is called as a neutral
culture.
98. What is the use of the <sessionState> tag in the
web.config file?
The <sessionState> tag is used to configure the
session state features. To change the default timeout, which is 20 minutes, you
have to add the following code snippet to the web.config file of an
application: <sessionState timeout="40"/>
99. Can you post and access view state in another application?
Yes, you can post and access a view state in other
applications. However, while posting a view state in another application, the
PreviousPage property returns null.
100. Which method do you use to kill explicitly a users
session?
The Session.Abandon() method kills the user session
explicitly.
101. Which class is inherited when an ASP.NET server control
is added to a Web form?
The System.Web.UI.WebControls class is inherited when an
ASP.NET server control is added to a Web form.
102. What events are fired when a page loads?
The following events fire when a page loads:
Init() - Fires when the page is initializing.
LoadViewState() - Fires when the view state is loading.
LoadPostData() - Fires when the postback data is processing.
Load() - Fires when the page is loading.
PreRender() - Fires at the brief moment before the page is
displayed to the user as HTML.
Unload() - Fires when the page is destroying the instances
of server controls.
103. Write three common properties of all validation controls.
Three common properties of validation controls are as
follows:
ControlToValidate - Provides a control to validate
ErrorMessage - Displays an error message
IsValid - Specifies if the control's validation has
succeeded or not
Text - Displays a text for validation control before
validation
104. What are navigation controls? How many navigation
controls are there in ASP.NET 4.0?
Navigation controls help you to navigate in a Web
application easily. These controls store all the links in a hierarchical or
drop-down structure; thereby facilitating easy navigation in a Web application.
There are three navigation controls in ASP.Net 4.0.
SiteMapPath
Menu
TreeView
105. What happens if an ASP.NET server control with
event-handling routines is missing from its definition?
The compilation of the application fails.
106. What are server-side comments?
Server-side comments are included in an ASP.NET page for the
purpose of documentations as shown in the following code snippet:
<%--This is an example of server-side comments --%>
The server-side comments begin with <%-- and end with
--%>.
107. How can we provide the WebParts control functionality
to a server control?
We can provide the WebParts controls functionality to a
server control by setting the CreateWebPart property of WebPartManger.
108. How do you prevent a validation control from validating
data at the client end?
You can prohibit a validation control to validate data at
the client side by setting the EnableClientScript property to False.
109. What is cross-page posting in ASP.NET?
The Server.Transfer() method is used to post data from one
page to another. In this case, the URL remains the same. However, in cross page
posting, data is collected from different Web pages and is displayed on a single
page. To do so, you need to set the PostBackUrl property of the control, which
specifies the target page. In the target page, you can access the PreviousPage
property. For this, you need to use the @PreviousPageType directive. You can
access the controls of previous page by using the FindControl() method.
110. Which ASP.NET configuration options are supported in
the ASP.NET implementation on the shared Web hosting platform?
There are many ASP.NET configuration choices, which are not
able to configure at the site, application, or child directory level on the
shared hosting environment. Some options can produce security, performance, and
stability problem to the server and therefore cannot be changed.
The following settings are the only ones that can be changed
in the web.config file(s) of your Web site:
browserCaps
clientTarget
pages
customErrors
globalization
authorization
authentication
webControls
webServices
111. Explain the Application and Session objects in ASP.NET.
Application state is used to store data corresponding to all
the variables of an ASP.NET Web application. The data in an application state
is stored once and read several times. Application state uses the
HttpApplicationState class to store and share the data throughout the application.
You can access the information stored in an application state by using the
HttpApplication class property. Data stored in the application state is
accessible to all the pages of the application and is the same for all the
users accessing the application. The HttpApplicationState class provides a lock
method, which you can use to ensure that only one user is able to access and
modify the data of an application at any instant of time.
Each client accessing a Web application maintains a distinct
session with the Web server, and there is also some specific information
associated with each of these sessions. Session state is defined in the
<sessionState> element of the web.config file. It also stores the data
specific to a user session in session variables. Different session variables
are created for each user session. In addition, session variables can be
accessed from any page of the application. When a user accesses a page, a
session ID for the user is created. The session ID is transferred between the
server and the client over the HTTP protocol using cookies.
112. How will you differentiate a submaster page from a
top-level master page?
Similar to a content page, a submaster page also does not
have complete HTML source code; whereas, a top-level master page has complete
HTML source code inside its source file.
113. What are Web server controls in ASP.NET?
The ASP.NET Web server controls are objects on the ASP.NET
pages that run when the Web page is requested. Many Web server controls, such
as button and text box, are similar to the HTML controls. In addition to the
HTML controls, there are many controls, which include complex behavior, such as
the controls used to connect to data sources and display data.
114. What is the difference between a HyperLink control and
a LinkButton control?
A HyperLink control does not have the Click and Command
events; whereas, the LinkButton control has these events, which can be handled
in the code-behind file of the Web page.
115. What are the various ways of authentication techniques
in ASP.NET?
There are various techniques in ASP.NET to authenticate a
user. You can use one of the following ways of authentication to select a
built-in authentication provider:
Windows Authentication - This mode works as the default authentication
technique. It can work with any form of Microsoft Internet Information Services
(IIS) authentication, such as Basic, Integrated Windows authentication
(NTLM/Kerberos), Digest, and certificates. The syntax of Windows authentication
mode is given as follows: <authentication mode="windows" />
Forms Authentication - You can specify this mode as a
default authentication mode by using the following code snippet:
<authentication mode="Forms"/>
Passport - This mode works with Microsoft Passport authentication,
as shown in the following code snippet: <authentication mode =
"Passport"/>
116. What are the different ways to send data across pages
in ASP.NET?
The following two ways are used to send data across pages in
ASP.NET:
Session
Public properties
117. What does the WebpartListUserControlPath property of a
DeclarativeCatalogPart control do?
The WebpartListUserControlPath property sets the route of
the user defined control to a DeclarativeCatalogPart control.
118. What do you mean by the Web Part controls in ASP.NET?
The Web Part controls are the integrated controls, which are
used to create a Web site. These controls allow the users to change the
content, outlook, and state of Web pages in a Web browser.
119. What type of the CatalogPart control enables users to
restore the Web Parts that have been removed earlier by the user?
The PageCatalogPart control.
120. What is the use of web.config? What is the difference
between machine.config and web.config?
ASP.NET configuration files are XML-based text files for
application-level settings and are saved with the name web.config. These files
are present in multiple directories on an ASP.NET Web application server. The
web.config file sets the configuration settings to the directory it is placed
in and to all the virtual sub folders under it. The settings in sub directories
can optionally override or change the settings specified in the base directory.
The difference between the web.config and machine.config files
is given as follows:
<WinDir>\Microsoft.NET\Framework\<version>\config\machine.config
provides default configuration settings for the entire machine. ASP.NET
configures IIS to prohibit the browser directly from accessing the web.config
files to make sure that their values cannot be public. Attempts to access those
files cause ASP.NET to return the 403: Access Forbidden error.
ASP.NET uses these web.config configuration files at runtime
to compute hierarchically a sole collection of settings for every URL target
request. These settings compute only once and cached across further requests.
ASP.NET automatically checks for changing file settings and do not validate the
cache if any of the configuration changes made.
121. Explain the concept of states in ASP.NET.
State is quite an innovative concept in Web development
because it eliminates the drawback of losing state data due to reloading of a
Web page. By using states in a Web application, you can preserve the state of
the application either at the server or client end. The state of a Web
application helps you to store the runtime changes that have been made to the
Web application. For example, as already described earlier, a change in the
data source of the Web application might be initiated by a user when he/she
selects and saves some products in the shopping cart.
If you are not using states, these changes are discarded and
are not saved. You may think that the whole concept of storing states is
optional. However, under certain circumstances, using states with applications
is imperative. For example, it is necessary to store states for Web
applications, such as an e-commerce shopping site or an Intranet site of a
company, to keep track of the requests of the users for the items they have
selected on the shopping site or the days requested for vacation on the
Intranet site.
122. Can we validate a DropDownList by
RequiredFieldValidator?
Yes, we can validate a DropDownList by
RequiredFieldValidator. To perform this validation, we have to set the InitialValue
property of RequiredFieldValidator control.
123. List the features of the Chart control.
The following are the features of the Chart control:
Bounds a chart with any data source.
Simple manipulation of chart data, such as copying, merging,
grouping, sorting, searching, and filtering.
Support many statistical and financial formulas for data
analysis.
Provide advanced chart outlook, such as 2-D, 3-D, lighting,
and perspective.
Support events and customizations.
Includes interactivity with Microsoft AJAX.
Supports AJAX Content Delivery Network (CDN).
C#
Why would you like to change the company?
1) I am looking for a more challenging career in a firm with
a larger employee base such as yours.
2) Keeping in mind my career goals, the time has come for me
to move onto the next rung of
the ladder and make a mark for myself. This can be achieved
in a company like this.
3) It is just a career move to enhance my knowledge in my
own area of interest.
After completion of this question only interview will go for
further questions
Difference between stored procedure and function
1) Procedure can return zero or n values whereas function
can return one value which is mandatory.
2) Procedures can have input, output parameters for it
whereas functions can have only input parameters.
3) Procedure allows select as well as DML statement in it
whereas function allows only select statement in it.
4) Functions can be called from procedure whereas procedures
cannot be called from function.
5) Exception can be handled by try-catch block in a
procedure whereas try-catch block cannot be used in a function.
6) We can go for transaction management in procedure whereas
we can't go in function.
7) Procedures cannot be utilized in a select statement
whereas function can be embedded in a select statement.
Difference between Abstract and Interface
Abstract Class:
-Abstract class provides a set of rules to implement next
class
-Rules will be provided through abstract methods
-Abstract method does not contain any definition
-While inheriting abstract class all abstract methods must
be override
-If a class contains at least one abstract method then it
must be declared as an “Abstract Class”
-Abstract classes cannot be instantiated (i.e. we cannot
create objects), but a reference can be created
-Reference depends on child class object’s memory
-Abstract classes are also called as “Partial abstract
classes”
-Partial abstract class may contain functions with body and
functions without body
-If a class contains all functions without body then it is
called as “Fully Abstract Class” (Interface)
Interface:
-If a class contains all abstract methods then that class is
known as “Interface”
-Interfaces support like multiple inheritance
-In interface all methods r public abstract by default
-Interfaces r implementable
-Interfaces can be instantiated, but a reference cannot be
created
Index types in SQL Server
Clustered Index
Only 1 allowed per table physically rearranges the data in
the table to confirm to the index constraints for use on columns that are
frequently searched for ranges of data for use on columns with low selectivity.
Non-Clustered Index
Up to 249 allowed per table creates a separate list of key
values with pointers to the location of the data in the data pages For use on
columns that are searched for single values
A clustered index is a special type of index that reorders
the way records in the table are physically stored. Therefore table can have
only one clustered index. The leaf nodes of a clustered index contain the data
pages. A non-clustered index is a special type of index in which the logical
order of the index does not match the physical stored order of the rows on
disk. The leaf node of a non-clustered index does not consist of the data
pages. Instead, the leaf nodes contain index rows.
Included Column Index (New in SQL Server 2005)
In SQL Server 2005, the functionality of non-clustered
indexes is extended by adding non-key columns to the leaf level of the
non-clustered index. Non-key columns can help to create cover indexes. By
including non-key columns, you can create non-clustered indexes that cover more
queries. The Database Engine does not consider non-key columns when calculating
the number of index key columns or index key size. Non-key columns can be
included in non-clustered index to avoid exceeding the current index size
limitations of a maximum of 16 key columns and a maximum index key size of 900
bytes. Another advantage is that using non-key column in index we can have
index data types not allowed as index key columns generally.
In following example column Filename is varchar(400), which
will increase the size of the index key bigger than it is allowed. If we still
want to include in our cover index to gain performance we can do it by using
the Keyword INCLUDE.
USE AdventureWorks
GO
CREATE INDEX IX_Document_Title
ON Production.Document (Title, Revision)
INCLUDE (FileName)
Non-key columns can be included only in non-clustered
indexes. Columns can’t be defined in both the key column and they INCLUDE list.
Column names can’t be repeated in the INCLUDE list. Non-key columns can be
dropped from a table only after the non-key index is dropped first. For
Included Column Index to exist there must be at least one key column defined
with a maximum of 16 key columns and 1023 included columns.
Avoid adding unnecessary columns. Adding too many index
columns, key or non-key as they will affect negatively on performance. Fewer
index rows will fit on a page. This could create I/O increases and reduced
cache efficiency. More disk space will be required to store the index. Index
maintenance may increase the time that it takes to perform modifications,
inserts, updates, or deletes, to the underlying table or indexed view.
Another example to test:
Create following Index on Database AdventureWorks in SQL
SERVER 2005
USE AdventureWorks
GO
CREATE NONCLUSTERED INDEX IX_Address_PostalCode
ON Person.Address (PostalCode)
INCLUDE (AddressLine1, AddressLine2, City, StateProvinceID)
GO
Test the performance of following query before and after
creating Index. The performance improvement is significant.
SELECT AddressLine1, AddressLine2, City, StateProvinceID,
PostalCode
FROM Person.Address
WHERE PostalCode BETWEEN '98000'
AND '99999';
GO
Interview questions
What are differences between Array list and Hash table?
Ans: 1) Hash table store data as name, value pair. While in
array only value is store.
2) To access value from hash table, you need to pass name.
While in array, to access value, you need to pass index number.
3) you can store different type of data in hash table, say
int, string etc. while in array you can store only similar type of data.
What are differences between system.stringbuilder and
system.string?
The main difference is system.string is immutable and
system.stringbuilder is a mutable. Append keyword is used in string builder but
not in system.string.
Immutable means once we created we cannot modified. Suppose
if we want give new value to old value simply it will discarded the old value
and it will create new instance in memory to hold the new value.
What are the differences between Application object and
session object?
Ans: The session object is used to maintain the session of
each user. If one user enter in to the application then they get session id if
he leaves from the application then the session id is deleted. If they again
enter in to the application they get different session id.
But for application object the id is maintained for whole
application.
What are the different types of indexes?
Ans: Two types of indexes are there one is clustered index
and non-clustered index
How many types of memories are there in .net?
Ans: Two types of memories are there in .net stack memory
and heap memory
Is it possible to set the session out time manually?
Ans: Yes we can set the session out time manually in
web.config.
What are differences between function and stored procedure?
Ans:
1) Function returns only one value but procedure returns one
or more than one value.
2) Function can be utilized in select statements but that is
not possible in procedure.
3) Procedure can have an input and output parameters but
function has only input parameters only.
4) Exceptions can be handled by try catch block in
procedures but that is not possible in function.
What are the differences between Abstract and interface?
Ans: 1) Abstract
cannot be instantiated but we can inherit. Interface it cannot be inherit it
can be instantiate
2) Interface contain only declarations no definitions.
Abstract contain declarations and definitions.
3) The class which contains only abstract methods is
interface class. A class which contains abstract method is called abstract
class
4) Public is default access specifier for interface we don’t
have a chance to declare other specifiers. In abstract we have chance to
declare with any access specifier
Can you Explain Page lifecycle in .net?
Can you Explain .NET architecture in .net?
What is the difference between primary key and unique key
with not null?
Ans: There is no difference between primary key and unique
key with not null.
What is boxing and unboxing concepts in .net?
Ans: Boxing is a process of converting value type into
reference type
Unboxing is a process of converting reference type to value
type.
What are the differences between value type and reference
type?
Ans: Value type contain variable and reference type are not
containing value directly in its memory.
Memory is allocated in managed heap in reference type and in
value type memory allocated in stack. Reference type ex-class value
type-struct, enumeration
Is it possible to host the website from desktop?
Ans: Yes
Why we go for page rendering in Asp.Net Page life cycle?
Ans: Browser understands an only html control that’s why in
page rendering we will convert the aspx controls into html controls.
Write a sample query for self join?
Ans: Select e1.ename, e2.empid from emp e1, emp e2 where
e1.empid=e2.mgrid;
Can we change the index of primary key on table?
Ans: No
How to change the name of the table or stored procedure in
sql?
Ans: sp_rename oldtablename newtablename
For changing the column name
Sp_rename
‘tablename.[Oldcolumnname]’,’newcolumnname’,’Column’
Ex:sp_rename ‘tblemp.first’,’namechange’,’Column’
How to find out which index is defined on table?
Ans: sp_helpindex tablename
Can you write the program to find the length of string
without using library function?
Ans: for (int i=0; str[i]!=”\n”; i++)
{
Count++;
}
What is the difference between scope_identity() and
current_identity()?
Ans: Scope_identity and current _identity both are similar
and it will return the last identity value generated in the table.
Scope_Identity will return the identity value in table that
is currently in scope
What are difference between GET and POST Methods?
Ans:
GET Method ():
1) Data is appended to the URL.
2) Data is not secret.
3) It is a single call system
4) Maximum data that can be sent is 256.
5) Data transmission is faster
6) this is the default method for many browsers
POST Method ():
1) Data is not appended to the URL.
2) Data is Secret
3) it is a two call system.
4) There is no Limit on the amount of data. That is
characters any amount of data can be sent.
5) Data transmission is comparatively slow.
6) No default and should be explicitly specified.
What are difference between truncate and delete?
Ans: 1) Delete keep the lock over each row where Truncate
keeps the lock on table not on all the row.
2) Counter of the Identity column is reset in Truncate where
it is not reset in Delete.
3) Trigger is not fired in Truncate where as trigger is
fired in Delete.
4) In TRUNCATE we cannot rollback.
5) In DELETE we can rollback
What is the difference Grid View and between Data Grid
(Windows)?
Ans:
1) GridView Control Enables you to add sorting, paging and
editing capabilities without writing any code.
2)GridView Control Automatically Supports paging by setting
the ‘PagerSetting’ Property.The Page Setting Property supports four Modles
a. Numeric(by default)
b. Next Previous
c. NumericFirstLast
d. Next PreviousLast
3)It is Used in asp.net
4)GridView Supports RowUpdating and RowUpdated Events.
5)GidView is Capable of Pre-Operations and Post-Operations.
6)GridView Has EditTemplates for this control
7)It has AutoFormat
DataGrid(Windows)
1)DataGid Control raises single Event for operations
2)DataGird Supports the SortCommand Events that occur when a
column is Soted.
3)DataGrid Supports UpdataCommand Event that occurs when the
UpdateButton is clicked for an item in the grid.
4)DataGrid is used in Windows GUI Application.
5)It doesnot have EditTemplates for this control
6)It doesnot have AutoFormat
If I write System.exit (0); at the end of the try block,
will the finally block still execute?
Ans: No in this case the finally block will not execute
because when you say system.exit(0),the control immediately goes out of the
program, and thus finally never executes.
What are the different levels of State management in
ASP.NET?
Ans:
State management is the process by which you maintain state
and page information over multiple requests for the same or different pages.
There are 2 types State Management:
1. Client – Side State Management
This stores information on the client's computer by
embedding the information into a Web page, a uniform resource locator (url), or
a cookie. The techniques available to store the state information at the client
end are listed down below:
a. View State – Asp.Net uses View State to track the values
in the Controls. You can add custom values to the view state. It is used by the
Asp.net page framework to automatically save the values of the page and of each
control just prior to rendering to the page. When the page is posted, one of
the first tasks performed by page processing is to restore view state.
b. Control State – If you create a custom control that
requires view state to work properly, you should use control state to ensure
other developers don’t break your control by disabling view state.
c. Hidden fields – Like view state, hidden fields store data
in an HTML form without displaying it in the user's browser. The data is available
only when the form is processed.
d. Cookies – Cookies store a value in the user's browser
that the browser sends with every page request to the same server. Cookies are
the best way to store state data that must be available for multiple Web pages
on a web site.
e. Query Strings - Query strings store values in the URL
that are visible to the user. Use query strings when you want a user to be able
to e-mail or instant message state data with a URL.
2. Server – Side State Management
a. Application State - Application State information is
available to all pages, regardless of which user requests a page.
b. Session State – Session State information is available to
all pages opened by a user during a single visit.
Both application state and session state information is lost
when the application restarts. To persist user data between application
restarts, you can store it using profile properties.
Abstract Class:
Abstract class is a class which can’t be instantiate. Class
should have “Abstract” key word with the name.
In any one of the method of class having abstract method with in it,
then it should be define as abstract class. The class which derived the
abstract class should have definition of the abstract method. These classes
which derived the abstract class and implement the abstract methods call
concrete class.
Abstract class may have the definition of function or may
not. Below is the simple example of an
abstract class
public abstract alass AbstractStudent
{
String Roll
{
get;
set;
}
String
FirstName
{
get;
set;
}
String
LastName
{
get;
set;
}
Public String
GetStudentDetails()
{
//
Implementation of Method
}
public String
SaveStudentDetails ()
{
//
Implementation of Method
}
public
abstract String CalculateWage();
}
So, the class having one abstract method so we need to
mention the class as "abstract" .
Difference between Abstract Class and Interface?
Abstract class is a class which can’t be instantiated and
which can have methods with definition as well as declaration also. This can be
inherited.
As for Example:
public abstract class AbstractStudent
{
String Roll
{
get;
set;
}
String
FirstName
{
get;
set;
}
String
LastName
{
get;
set;
}
Public String
GetStudentDetails()
{
//
Implementation of Method
}
public String
SaveStudentDetails ()
{
//
Implementation of Method
}
public
abstract String CalculateWage();
}
Interface can only contain the methods declaration and can
be implemented in the class.
As for Example:
Public interface IStudnet
{
String Roll
{
get;
set;
}
String
FirstName
{
get;
set;
}
String
LastName
{
get;
set;
}
String
GetStudentDetails();
String
SaveStudentDetails ();
}
Below are the few main difference between Abstract Class and
Interface
a. In abstract
class method can have definition as well as declaration also. But Interface
should have only definition.
b. All the Methods
are Public as default and don’t have any access Modifier Controls in interface,
whereas for abstract class we can have access modifier for methods.
c. Abstract class
can have constructor or destructor, whereas interface not.
d. Abstract class
can’t be part of multiple inheritance and we can implement multiple interface.
What do you mean by String objects are immutable?
String objects are immutable as its state cannot be modified
once created. Every time when we perform any operation like add, copy, replace,
and case conversion or when we pass a string object as a parameter to a method
a new object will be created.
Example:
String str = "ABC";
str.Replace("A","X");
Here Replace() method will not change data that
"str" contains, instead a new string object is created to hold data
"XBC" and the reference to this object is returned by Replace()
method.
So in order to point str to this object we need to write
below line.
str = str.Replace("A","X");
Now the new object is assigned to the variable str. earlier
object that was assigned to str will take care by garbage collector as this one
is no longer in used.
What is dll hell problem in .NET and how it will solve?
Ans: Dll hell, is kind of conflict that occurred previously,
due to the lack of version supportability of dll for (within) an application
.NET Framework provides operating system with a global
assembly cache. This cache is a repository for all the .net components that are
shared globally on a particular machine. When a .net component installed onto
the machine, the global assembly cache looks at its version, its public key and
its language information and creates a strong name for the component. The
component is then registered in the repository and indexed by its strong name,
so there is no confusion between the different versions of same component, or
DLL
What is a Partial class?
Ans: Instead of defining an entire class, you can split the
definition into multiple classes by using partial class keyword. When the
application compiled, c# compiler will group all the partial classes together
and treat them as a single class. There are a couple of good reasons to use
partial classes. Programmers can work on different parts of classes without
needing to share same physical file
Ex:
Public partial class employee
{
Public void somefunction()
{
}
}
Public partial class employee
{
Public void function ()
{
}
}
What is difference between constants, read-only and, static?
Constants: The value can’t be changed
Read-only: The value will be initialized only once from the
constructor of the class.
Static: Value can be initialized once.
What is the cross page post backing?
Asp.Net 2.0 fixed this with built-in features that allowed
us to easily send information from one page to another.
Button control has property PostBackUrl that can be set to
URL of any page in our ASP.Net WebSite where we want to transfer all form
values to.
Along with that Asp.Net 2.0 Page class has a property
PreviousPage that allows us to get reference to the Page object that initiated
the postback (in other words to get the actual reference to the Page object of
the aspx page on which user clicked the Submit button on a HTML form).
So for example lets create two sample pages in our Web
Application:
SourcePage.aspx
DestinationPage.aspx
In SoucePage in Html form we will put two TextBox controls
(one for First Name and one for Last Name) and one Button component and set its PostBackUrl property to
"~/DestinationPage.aspx".
SourcePage.aspx:
<form
id="form1" runat="server">
<div>
First
Name: <asp:TextBox ID="FirstName"
runat="server"></asp:TextBox><br />
Last
Name: <asp:TextBox ID="LastName"
runat="server"></asp:TextBox><br /><br />
<asp:Button ID="Button1" runat="server"
Text="Submit To Destination Page"
PostBackUrl="~/CrossPagePostbacks/DestinationPage.aspx" />
</div>
</form>
When our user clicks the Submit button, all the values from
the HTML Form on SourcePage.aspx will be transfered to the DestinationPage.aspx
and we will also be able to get reference to the SourcePage.aspx in our
DestinationPage with the PreviousPage property like this:
So in our DestinationPage.aspx.cs code-behind we can easily
access two TextBox controls on SourcePage.aspx and show them in two label
controls like this:
protected void
Page_Load(object sender, EventArgs e)
{
// first check
if we had a cross page postback
if (
(PreviousPage != null) && (PreviousPage.IsCrossPagePostBack) )
{
Page
previousPage = PreviousPage;
TextBox
firstName = (TextBox)previousPage.FindControl("FirstName");
TextBox
lastName = (TextBox)previousPage.FindControl("LastName");
// we can
now use the values from TextBoxes and display them in two Label controls..
labelFirstName.Text = firstName.Text;
labelLastName.Text = lastName.Text;
}
}
You probably noticed that we first checked if PreviousPage
property of current page (DestinationPage.aspx) is NOT NULL, this is done to
avoid running our code in case that user opens our DestinationPage.aspx
directly, without running a cross page postback.
Also here we checked the another PreviousPage property
called IsCrossPagePostBack to see if we really had a CrossPagePostback.
(If Server.Transfer is used to redirect to this page,
IsCrossPagePostBack property will be set to FALSE.
TIP: We can be completely sure that we have a real CrossPagePostback ONLY IF:
Page.PreviousPage
is NOT NULL,
PreviousPage.IsCrossPagePostback is true
This important to check to avoid errors in code.
Now this is very useful and i'm sure you are eager to use
this in your next project. But wait, we are not over yet!
Finding the controls on PreviousPage with FindControl method
and type-casting them from object to their real type is a little messy.
It feels like there must be a better solution for this!
And here it is: We can use the <%@ PreviousPageType %>
directive in the header of our DestinationPage.aspx like this
<%@
PreviousPageType VirtualPath="~/SourcePage.aspx" %>
to declare our previous page type, and then we can access Public
properties of the PreviousPage without typecasting.
Now all we need to do is to create some public properties on
our SourcePage.aspx.cs to expose data/Controls we want to the destionation
page:
public partial
class SourcePage : System.Web.UI.Page
{
public string
FormFirstName
{
get {
return FirstName.Text; }
}
public string
FormLastName
{
get {
return LastName.Text; }
}
}
And then we can change the Page_Load code in our
DestinationPage.aspx to much cleaner code like this:
protected void
Page_Load(object sender, EventArgs e)
{
// first check
if we had a cross page postback
if (
(PreviousPage != null) && (PreviousPage.IsCrossPagePostBack) )
{
SourcePage
prevPage = PreviousPage;
// we can
now use the values from textboxes and display them in two Label controls..
labelFirstName.Text = prevPage.FormFirstName;
labelLastName.Text = prevPage.FormLastName;
}
}
SourcePage type used in the code is offcourse name of the
partial class defined is SourcePage.aspx.cs that inherits System.Web.UI.Page
that is automatically created for us when we created new WebForm in
VisualStudio.
This code is much cleaner and easier to follow, there is no
ugly typecasting, just simple property values to use to retrieve the data from
previous page.
When should you use Abstract Class vs Interface while
programming?
Ans: When we want
that sub class must implement all the methods of base class. In such a
situation we will implement the interface. In the other hand when we want only
some method of base class in our sub class then use base class as abstract
class.
What is the difference between application exception and
system exception?
Ans: The difference between application exception and system
exception is that system exceptions are thrown by CLR and application
exceptions are thrown by applications.
What is the difference between authorization and authentication?
Ans: Authorization is a process of allowing or denying
resources to particular user or record
Declaration of authorization is
<authorization>
<allow users=”Suresh, Sanjay”/>
<deny users=”Ramana, Rakesh”>
</authorization>
Sometimes authorization allows the unauthorized persons at
that time we will use
<deny users=”?”/>
Authentication means
Authentication is a process where we identify the
credentials of user i.e. username, password and create an identity to mention
user as an authenticated.
What is the use of n-tier architecture and 3-tier
architecture?
Check this article for 3-tier architecture 3 tier
architecture example in asp.net
How to get the version of the assembly?
Ans: lbltxt.text=Assembly. GetExecutingAssembly().GetName().Version.ToString();
What is the location of Global Assembly Cache on the system?
Ans: c:\Windows\assembly
What is the
serialization?
Ans: Serialization is a process of converting object into a
stream of bites.
What is synchronization?
Ans: The mechanism needed to block one thread access to the
data. If the data is being accessed by another thread.
Synchronization can be accessed by using system.monitor
class
A monitor class methods are enter, exit, pulse for this lock
statement is also used
Suppose if we need to synchronize some data at that time we
need to place that data in this block
Lock
{
}
Whatever the data has been placed into the lock block that
data has been blocked
What are the thread priority levels?
Ans: Thread priority levels are five types
0 - Zero
level
1 - Below
Normal
2 - Normal
3 - Above
Normal
4 - Highest
By Default priority level is 2
What is the difference between .tostring(),
Convert.tostring()?
Ans: The basic difference between them is “Convert” function
handles NULLS while
“.ToString()” does not it will throw a NULL reference
exception error. So as a good coding
practice using “convert” is always safe.
What is Collation?
Ans: Collation refers to a set of rules that determine how
the data is sorted and compared.
What is the difference between Primary key and unique key?
Ans: Primary key does not allow the null values but unique
key allows one null value.
Primary key will create clustered index on column but unique
key will create non-clustered index by default.
How many web.config files are there in 1 project?
Ans: There might be multiple web.config files for a single
project depending on the hierarchy of folders inside the root folder of the project,
so for each folder we can use one web.config file
What is the difference between throw and throw ex?
What is the difference between view state and hidden field?
Ans: viewstate is secured hidden field is insecure
Viewstate will store large amount of data but hidden filed
will store small amount of data.
What is the difference between binary serialization and xml
serialization?
What is the Difference between read only and constant
variables?
Ans: Read only can assign the values at runtime only.
Constant will assign the values at compile time only.
We cannot modify the both variable values.
What is static keyword in .Net?
Ans: Static is same as constant variable but we can change
the value of static variable and we can access the variables without creating
any instances
What is the use of business logic layer in 3-tier
architecture in .net?
Ans: Though a web site could talk to the data access layer
directly, it usually goes through another layer called the business layer. The
business layer is vital in that it validates the input conditions before
calling a method from the data layer. This ensures the data input is correct
before proceeding, and can often ensure that the outputs are correct as well.
This validation of input is called business rules, meaning the rules that the
business layer uses to make “judgments” about the data.
However, business rules don’t only apply to data validation;
these rules apply to any calculations or any other action that takes place in
the business layer. Normally, it’s best to put as much logic as possible in the
business layer, which makes this logic reusable across applications.
One of the best reasons for reusing logic is that
applications that start off small usually grow in functionality. For instance,
a company begins to develop a web site, and as they realize their business
needs, they later decide to add a smart client application and windows service
to supplement the web site. The business layer helps move logic to a central
layer for “maximum reusability.”
Check this post introduction to 3-tier Architecture
What happens when I enter a URL in my browser and click
enter?
You type in the URL and hit go. The browser needs to
translate that URL www.somesite.com into an IP address so it knows what
computer on the internet to connect to (That URL is just there to make it
easier for us humans - kinda like speed-dial for phone numbers I guess). So
your browser will see if it already has the appropriate IP address cached away
from previous visits to the site. If not, it will make a DNS query to your DNS
server (might be your router or your ISP's DNS server) - see
http://en.wikipedia.org/wiki/Domain_name… for more on DNS. Once your browser
knows what IP to use, it will connect to the appropriate webserver and ask for
the page. The webserver then returns the requested page and your browser
renders it to the screen.
The firewall will control connections to & from your
computer. For the most part it will just be controlling who can connect to your
computer and on what ports. For web browsing your firewall generally won't be
doing a whole lot.
Your router (see http://en.wikipedia.org/wiki/Router )
essentially guides your request through the network, helping the packets get
from computer to computer and potentially doing some NAT (see
http://en.wikipedia.org/wiki/Network_add… ) to translate IP addresses along the
way (so your internat LAN request can be transitioned onto the wider internet
and back).
IP Addresses (see http://en.wikipedia.org/wiki/IP_address )
are unique addresses for computers that basically allow computers to find each
other. Think of the IP address as a computer's well address or phone number,
you've got to know someone's phone number before you can call them and you've
got to know a computer's IP address before you can connect to it. Going back to
the start - that's what those URLS and DNS make possible, you don't know John
Doe's phone number so you look in the phone book; likewise your computer doesn't
know yahoo.com's IP address so it looks in DNS.
OOPs Interview Question
1. What is object-oriented programming (OOP)?
OOP is a technique to develop logical modules, such as
classes that contain properties, methods, fields, and events. An object is
created in the program to represent a class. Therefore, an object encapsulates
all the features, such as data and behavior that are associated to a class. OOP
allows developers to develop modular programs and assemble them as software.
Objects are used to access data and behaviors of different software modules,
such as classes, namespaces, and sharable assemblies. .NET Framework supports
only OOP languages, such as Visual Basic .NET, Visual C#, and Visual C++.
2. What is a class?
A class describes all the attributes of objects, as well as
the methods that implement the behavior of member objects. It is a
comprehensive data type, which represents a blue print of objects. It is a
template of object.
A class can be defined as the primary building block of OOP.
It also serves as a template that describes the properties, state, and behaviors
common to a particular group of objects.
A class contains data and behavior of an entity. For
example, the aircraft class can contain data, such as model number, category,
and color and behavior, such as duration of flight, speed, and number of passengers.
A class inherits the data members and behaviors of other classes by extending
from them.
3. What is an object?
They are instance of classes. It is a basic unit of a
system. An object is an entity that has attributes, behavior, and identity.
Attributes and behavior of an object are defined by the class definition.
4. What is the relationship between a class and an object?
A class acts as a blue-print that defines the properties,
states, and behaviors that are common to a number of objects. An object is an
instance of the class. For example, you have a class called Vehicle and Car is
the object of that class. You can create any number of objects for the class
named Vehicle, such as Van, Truck, and Auto.
The new operator is used to create an object of a class.
When an object of a class is instantiated, the system allocates memory for
every data member that is present in the class.
5. Explain the basic features of OOPs.
The following are the four basic features of OOP:
Abstraction - Refers to the process of exposing only the
relevant and essential data to the users without showing unnecessary
information.
Polymorphism - Allows you to use an entity in multiple
forms.
Encapsulation - Prevents the data from unwanted access by
binding of code and data in a single unit called object.
Inheritance - Promotes the reusability of code and
eliminates the use of redundant code. It is the property through which a child
class obtains all the features defined in its parent class. When a class
inherits the common properties of another class, the class inheriting the
properties is called a derived class and the class that allows inheritance of
its common properties is called a base class.
6. What is the difference between arrays and collection?
Array:
You need to specify the size of an array at the time of its
declaration. It cannot be resized dynamically.
The members of an array should be of the same data type.
Collection:
The size of a collection can be adjusted dynamically, as per
the user's requirement. It does not have fixed size.
Collection can have elements of different types.
7. What are collections and generics?
A collection can be defined as a group of related items that
can be referred to as a single unit. The System.Collections namespace provides
you with many classes and interfaces. Some of them are - ArrayList, List,
Stack, ICollection, IEnumerable, and IDictionary. Generics provide the
type-safety to your class at the compile time. While creating a data structure,
you never need to specify the data type at the time of declaration. The
System.Collections.Generic namespace contains all the generic collections.
8. How can you prevent your class to be inherited further?
You can prevent a class from being inherited further by
defining it with the sealed keyword.
9. What is the index value of the first element in an array?
In an array, the index value of the first element is 0
(zero).
10. Can you specify the accessibility modifier for methods
inside the interface?
All the methods inside an interface are always public, by
default. You cannot specify any other access modifier for them.
11. Is it possible for a class to inherit the constructor of
its base class?
No, a class cannot inherit the constructor of its base
class.
12. How is method overriding different from method
overloading?
Overriding involves the creation of two or more methods with
the same name and same signature in different classes (one of them should be
parent class and other should be child).
Overloading is a concept of using a method at different
places with same name and different signatures within the same class.
13. What is the difference between a class and a structure?
Class:
A class is a reference type.
While instantiating a class, CLR allocates memory for its
instance in heap.
Classes support inheritance.
Variables of a class can be assigned as null.
Class can contain constructor/destructor.
Structure:
A structure is a value type.
In structure, memory is allocated on stack.
Structures do not support inheritance.
Structure members cannot have null values.
Structure does not require constructor/destructor and
members can be initialiazed automatically.
14. What are similarities between a class and a structure.
Structures and classes are the two most important data
structures that are used by programmers to build modular programs by using OOP
languages, such as Visual Basic .NET, and Visual C#. The following are some of
the similarities between a class and a structure:
Access specifiers, such as public, private, and protected,
are identically used in structures and classes to restrict the access of their
data and methods outside their body.
The access level for class members and struct members,
including nested classes and structs, is private by default. Private nested
types are not accessible from outside the containing type.
Both can have constructors, methods, properties, fields,
constants, enumerations, events, and event handlers.
Both structures and classes can implement interfaces to use
multiple-inheritance in code.
Both structures and classes can have constructors with
parameter.
Both structures and classes can have delegates and events.
15. What is a multicast delegate?
Each delegate object holds reference to a single method.
However, it is possible for a delegate object to hold references of and invoke
multiple methods. Such delegate objects are called multicast delegates or
combinable delegates.
16. Can you declare an overridden method to be static if the
original method is not static?
No. Two virtual methods must have the same signature.
17. Why is the virtual keyword used in code?
The virtual keyword is used while defining a class to
specify that the methods and the properties of that class can be overridden in
derived classes.
18. Can you allow a class to be inherited, but prevent a
method from being overridden in C#?
Yes. Just declare the class public and make the method
sealed.
19. Define enumeration?
Enumeration is defined as a value type that consists of a
set of named values. These values are constants and are called enumerators. An
enumeration type is declared using the enum keyword. Each enumerator in an
enumeration is associated with an underlying type that is set, by default, on
the enumerator. The following is an example that creates an enumeration to
store different varieties of fruits:
enum Fruits {Mango, Apple, orange, Guava};
In the preceding example, an enumeration Fruits is created,
where number 0 is associated with Mango, number 1 with Apple, number 2 with
Orange, and number 3 with Guava. You can access the enumerators of an
enumeration by these values.
20. In which namespace, all .NET collection classes are
contained?
The System.Collections namespace contains all the collection
classes.
21. Is it a good practice to handle exceptions in code?
Yes, you must handle exceptions in code so that you can deal
with any unexpected situations that occur when a program is running. For
example, dividing a number by zero or passing a string value to a variable that
holds an integer value would result in an exception.
22. Explain the concept of constructor?
Constructor is a special method of a class, which is called
automatically when the instance of a class is created. It is created with the
same name as the class and initializes all class members, whenever you access
the class. The main features of a constructor are as follows:
Constructors do not have any return type
Constructors are always public
It is not mandatory to declare a constructor; it is invoked
automatically by .NET Framework.
23. Can you inherit private members of a class?
No, you cannot inherit private members of a class because
private members are accessible only to that class and not outside that class.
24. Does .NET support multiple inheritance?
.NET does not support multiple inheritance directly because
in .NET, a class cannot inherit from more than one class. .NET supports
multiple inheritance through interfaces.
25. How has exception handling changed in .NET Framework
4.0?
In .NET 4.0, a new namespace, System.Runtime.ExceptionServices,
has been introduced which contains the following classes for handling
exceptions in a better and advanced manner:
HandleProcessCorruptedStateExceptionsAttribute Class -
Enables managed code to handle the corrupted state exceptions that occur in an
operating system. These exceptions cannot be caught by specifying the
try...catch block. To handle such exceptions, you can apply this attribute to
the method that is assigned to handle these exceptions.
FirstChanceExceptionEventArgs Class - Generates an event
whenever a managed exception first occurs in your code, before the common
language runtime begins searching for event handlers.
26. What is a delegate?
A delegate is similar to a class that is used for storing
the reference to a method and invoking that method at runtime, as required. A
delegate can hold the reference of only those methods whose signatures are same
as that of the delegate. Some of the examples of delegates are type-safe
functions, pointers, or callbacks.
27. What is the syntax to inherit from a class in C#?
When a class is derived from another class, then the members
of the base class become the members of the derived class. The access modifier
used while accessing members of the base class specifies the access status of
the base class members inside the derived class.
The syntax to inherit a class from another class in C# is as
follows:
class MyNewClass : MyBaseclass
28. State the features of an interface.
An interface is a template that contains only the signature
of methods. The signature of a method consists of the numbers of parameters,
the type of parameter (value, reference, or output), and the order of
parameters. An interface has no implementation on its own because it contains
only the definition of methods without any method body. An interface is defined
using the interface keyword. Moreover, you cannot instantiate an interface. The
various features of an interface are as follows:
An interface is used to implement multiple inheritance in
code. This feature of an interface is quite different from that of abstract
classes because a class cannot derive the features of more than one class but
can easily implement multiple interfaces.
It defines a specific set of methods and their arguments.
Variables in interface must be declared as public, static,
and final while methods must be public and abstract.
A class implementing an interface must implement all of its
methods.
An interface can derive from more than one interface.
29. Can you use the 'throws' clause to raise an exception?
No, the throws clause cannot be used to raise an exception.
The throw statement signals the occurrence of an exception during the execution
of a program. When the program encounters a throw statement, the method
terminates and returns the error to the calling method.
30. Define an array.
An array is defined as a homogeneous collection of elements,
stored at contiguous memory locations, which can be referred by the same
variable name. All the elements of an array variable can be accessed by index
values. An Index value specifies the position of a particular element in an
array variable.
31. What are methods?
Methods are the building blocks of a class, in which they
are linked together to share and process data to produce the result. In other
words, a method is a block of code that contains a series of statements and
represents the behavior of a class. While declaring a method you need to
specify the access specifier, the return value, the name of the method, and the
method parameters. All these combined together is called the signature of the
method.
32. What is a namespace?
Namespace is considered as a container that contains
functionally related group of classes and other types.
33. Do events have return type?
No, events do not have return type.
34. What is the function of the Try-Catch-Finally block?
The try block encloses those statements that can cause
exception and the catch block handles the exception, if it occurs. Catch block
contains the statements that have to be executed, when an exception occurs. The
finally block always executes, irrespective of the fact whether or not an
exception has occurred. The finally block is generally used to perform the
cleanup process. If any exception occurs in the try block, the program control
directly transfers to its corresponding catch block and later to the finally
block. If no exception occurs inside the try block, then the program control
transfers directly to the finally block.
35. How can you prevent a class from overriding in C# and
Visual Basic?
You can prevent a class from overriding in C# by using the
sealed keyword; whereas, the NotInheritable keyword is used to prevent a class
from overriding in Visual Basic.
36. What are abstract classes? What are the distinct
characteristics of an abstract class?
An abstract class is a class that cannot be instantiated and
is always used as a base class.
The following are the characteristics of an abstract class:
You cannot instantiate an abstract class directly. This
implies that you cannot create an object of the abstract class; it must be
inherited.
You can have abstract as well as non-abstract members in an
abstract class.
You must declare at least one abstract method in the
abstract class.
An abstract class is always public.
An abstract class is declared using the abstract keyword.
The basic purpose of an abstract class is to provide a
common definition of the base class that multiple derived classes can share.
37. Give a brief description of properties in C# and the
advantages that are obtained by using them in programs.
In C#, a property is a way to expose an internal data
element of a class in a simple and intuitive manner. In other words, it is a
simple extension of data fields. You can create a property by defining an
externally available name and then writing the set and get property accessors.
The get property accessor is used to return the property value. The set
property accessor is used to assign a new value to the property.
38. Explain different types of inheritance.
Inheritance in OOP is of four types:
Single inheritance - Contains one base class and one derived
class
Hierarchical inheritance - Contains one base class and
multiple derived classes of the same base class
Multilevel inheritance - Contains a class derived from a
derived class
Multiple inheritance - Contains several base classes and a
derived class
All .NET languages supports single, hierarchical, and
multilevel inheritance. They do not support multiple inheritance because in
these languages, a derived class cannot have more than one base class. However,
you can implement multiple inheritance in.NET through interfaces.
39. You have defined a destructor in a class that you have
developed by using the C# programming language, but the destructor never
executed. Why did the destructor not execute?
The runtime environment automatically invokes the destructor
of a class to release the resources that are occupied by variables and methods
of an object. However, in C#, programmers cannot control the timing for
invoking destructors, as Garbage Collector is only responsible for releasing
the resources used by an object. Garbage Collector automatically gets
information about unreferenced objects from .NET's runtime environment and then
invokes the Finalize() method.
Although, it is not preferable to force Garbage Collector to
perform garbage collection and retrieve all inaccessible memory, programmers
can use the Collect() method of the Garbage Collector class to forcefully
execute Garbage Collector.
40. What is a hashtable?
Hashtable is a data structure that implements the
IDictionary interface. It is used to store multiple items and each of these
items is associated with a unique string key. Each item can be accessed using
the key associated with it. In short, hashtable is an object holding the
key-value pairs.
41. Can users define their own exceptions in code?
Yes, customized exceptions can be defined in code by
deriving from the System.Exception class.
42. Is it possible to execute two catch blocks?
You are allowed to include more than one catch block in your
program; however, it is not possible to execute them in one go. Whenever, an
exception occurs in your program, the correct catch block is executed and the
control goes to the finally block.
43. What do you mean by data encapsulation?
Data encapsulation is a concept of binding data and code in
single unit called object and hiding all the implementation details of a class
from the user. It prevents unauthorized access of data and restricts the user
to use the necessary data only.
44. What is the difference between procedural and
object-oriented programming?
Procedural programming is based upon the modular approach in
which the larger programs are broken into procedures. Each procedure is a set
of instructions that are executed one after another. On the other hand, OOP is
based upon objects. An object consists of various elements, such as methods and
variables.
Access modifiers are not used in procedural programming,
which implies that the entire data can be accessed freely anywhere in the
program. In OOP, you can specify the scope of a particular data by using access
modifiers - public, private, internal, protected, and protected internal.
45. Explain the concept of destructor?
A destructor is a special method for a class and is invoked
automatically when an object is finally destroyed. The name of the destructor
is also same as that of the class but is followed by a prefix tilde (~).
A destructor is used to free the dynamic allocated memory
and release the resources. You can, however, implement a custom method that
allows you to control object destruction by calling the destructor.
The main features of a destructor are as follows:
Destructors do not have any return type
Similar to constructors, destructors are also always public
Destructors cannot be overloaded.
46. Can you declare a private class in a namespace?
The classes in a namespace are internal, by default.
However, you can explicitly declare them as public only and not as private,
protected, or protected internal. The nested classes can be declared as
private, protected, or protected internal.
47. A structure in C# can implement one or more interfaces.
Is it true or false?
Yes, it is true. Like classes, in C#, structures can
implement one or more interfaces.
48. What is a static constructor?
Static constructors are introduced with C# to initialize the
static data of a class. CLR calls the static constructor before the first
instance is created.
The static constructor has the following features:
No access specifier is required to define it.
You cannot pass parameters in static constructor.
A class can have only one static constructor.
It can access only static members of the class.
It is invoked only once, when the program execution begins.
49. What are the different ways a method can be overloaded?
The different ways to overload a method are given as
follows:
By changing the number of parameters used
By changing the order of parameters
By using different data types for the parameters
50. Differentiate between an abstract class and an
interface.
Abstract Class:
A class can extend only one abstract class
The members of abstract class can be private as well as
protected.
Abstract classes should have subclasses
Any class can extend an abstract class.
Methods in abstract class can be abstract as well as
concrete.
There can be a constructor for abstract class.
The class extending the abstract class may or may not
implement any of its method.
An abstract class can implement methods.
Interface
A class can implement several interfaces
An interface can only have public members.
Interfaces must have implementations by classes
Only an interface can extend another interface.
All methods in an interface should be abstract
Interface does not have constructor.
All methods of interface need to be implemented by a class
implementing that interface.
Interfaces cannot contain body of any of its method.
51. What are queues and stacks?
Stacks refer to a list in which all items are accessed and
processed on the Last-In-First-Out (LIFO) basis. In a stack, elements are
inserted (push operation) and deleted (pop operation) from the same end called
top.
Queues refer to a list in which insertion and deletion of an
item is done on the First-In-First-Out (FIFO) basis. The items in a queue are
inserted from the one end, called the rear end, and are deleted from the other
end, called the front end of the queue.
52. Define an event.
Whenever an action takes place in a class, that class
provides a notification to other classes or objects that are assigned to
perform particular tasks. These notifications are called events. For example,
when a button is clicked, the class generates an event called Click. An event
can be declared with the help of the event keyword.
53. What are structures?
Structure is a heterogeneous collection of elements
referenced by the same name. A structure is declared using the struct keyword.
The following is an example that creates a structure to store an employee's
information:
struct emp
{
fixed int empID[15];
fixed char name[30];
fixed char addr[50];
fixed char dept[15];
fixed char desig[15];
}
The preceding example defines a structure emp and the
members of this structure specify the information of an employee.
54. When do you really need to create an abstract class?
We define abstract classes when we define a template that
needs to be followed by all the derived classes.
Window Controls in .Net
1. How can we auto size a button to fit its text?
The Button control has the AutoSize property, which can be
set to true or false. If we set the value of the AutoSize property to true,
then the button control automatically alters its size according to the content
displayed on it.
2. How can we display an icon or a bitmap image on the
Button control?
The Button class contains the Image property, which is used
to set an image on the Button control. We can also set the alignment of the
image by using the ImageAlign property of the Button class.
3. Which method is used to generate the click event of the
Control class for the Button control in C#?
The PerformClick() method of the Button class is used to
generate the Click event of the System.Windows.Forms.Control class.
4. A Windows Form will not show the Minimize, Maximize, and
Close buttons, if the ControlBox property of the form is set to False.
(True/False)
True.
5. How is anchoring different from docking?
Docking refers to attaching a control to either an edge
(top, right, bottom, or left) or the client area of the parent control. On the
other hand, anchoring is a process in which you need to specify the distance
that each edge of your control maintains from the edges of the parent control.
6. How can you display a default value in the text box of an
input box?
You can display a default value in the text box of an input
box by using the DefaultResponse argument of the InputBox() function.
7. How will you pick a color from the ColorDialog box?
To pick a color from the color dialog box, you need to
create an instance of the ColorDialog box and invoke to the ShowDialog()
method. The code to display the color dialog box and set the BackColor property
of the Label control similar to the color selected in the color dialog box
control is:
private void button1_Click(object sender, EventArgs e)
{
if
(colorDialog1.ShowDialog() != DialogResult.Cancel)
{
label1.Text =
"Here's my new color!";
label1.BackColor =
colorDialog1.Color;
}
}
8. How can you get or set the time between Timer ticks?
There is an Interval property, which is responsible to get
and set the time in milliseconds.
9. How can you programmatically position the cursor on a
given line or on a character in the RichTextBox control in C#?
The RichTextBox control contains the Lines array property,
which displays one item of an array in a separate line. Each line entry has a
Length property, which can be used to accurately position the cursor at a
character, as shown in the following code snippet:
private void GoToLineAndColumn(RichTextBox RTB, int Line,
int Column)
{
int offset = 0;
for(int i = 0; i <
Line -1 && i < RTB.Lines.Length; i++)
{
offset +=
RTB.Lines[i].Length + 1;
}
RTB.Focus();
RTB.Select(offset +
Column, 0);
}
10. What is the difference between the
WindowsDefaultLocation and WindowsDefaultBounds properties?
The WindowsDefaultLocation property makes the form to start
up at a location selected by the operating system, but with internally
specified size. The WindowsDefaultBounds property delegates both size and
starting position choices to the operating system.
11. Where does an ImageList control appear when you add it
at the design time?
The ImageList control is a component; therefore, it appears
in the component tray at the design time.
12. How can you programmattically prevent a Combobox from
dropping, in .NET 4.0?
To avoid dropping of a Combobox, you need to override the
WndProc() method and ignore WM_LBUTTONDOWN and WM_LBUTTONDBLCLK events.
13. What is the function of the CheckState property of the
CheckBox control?
The CheckState property gets or sets the state of CheckBox.
If the ThreeState property is set to false, the CheckState
property value can only be set to CheckState.Indeterminate in code and not by
user interaction.
Checked - The CheckBox displays a check mark. The control
appears sunken.
Unchecked - The CheckBox is empty. The control appears
raised.
Indeterminate - The CheckBox displays a check mark and is
shaded.
14. Write a code to select an item in the ListView control
programmatically in C#?
To select an item from the ListView control, you can use the
following code snippet:
//Make sure the listview has focus
listview1.Focus();
listview1.Items[i].Selected = true;
15. Differentiate between a TextBox control and RichTextBox
control.
The TextBox control is an input control, which allows a user
to enter text to an application at runtime. By default, it allows only single
line text; however, you can change its property to accept the multiline text as
well as scroll bar also.
The RichTextBox control is similar to the TextBox control
with the difference that it allows the user to format its text also. You can
format the text in various ways, such as bold, italic, and underlined as well
as change its color and font. You can save your RichTextBox value to a RTF
(Rich Text Format) file and load value of RTF file to the RichTextBox control.
16. Describe the ToolTip control. How can you associate it
with other controls?
The ToolTip control generates a small pop-up window with
explanatory text for an element It is displayed when the user pauses the mouse
for a certain period over an element/control. Tool tips provide a quick help to
user to understand about that element. To associate a tool tip with other
control, you need to implement the SetToolTip() method.
17. What does the DialogResult property of a Button control
do?
The DialogResult property retrieves or sets a value that is
returned to the parent form when the button is clicked.
18. How do you create a separator in the Menu Designer?
You can use hyphen (-) to create a separator.
19. Define the TrackBar control.
The TrackBar control, also known as the slider control,
works as a navigator to display a large amount of information or for visual
adjustment of numeric setting. There are two parts in a TrackBar control -
thumb (also known as slider) and tick marks. The thumb part acts as a slider.
You can adjust the thumb part using the Value property. The tick marks are
visual indicators that are spaced at regular intervals.
20. How does an MDI form differ from a standard form?
An MDI form closely resembles a standard form with one major
difference-the client area of an MDI form acts as a container for other forms.
It means that an MDI form, also known as an MDI parent form, can display MDI
child forms inside it.
21. Which method provides the functionality to display a
dialog box at runtime?
The ShowDialog() method is used to display the dialog box at
run time.
22. What does the PerformStep() method do?
The PerformStep() method increases the value of Progress bar
according to the amount set by the Step property.
23. Write a method to get only the name of a file from the
complete path string in C#.
Use a FileInfo class and instantiate its object with the
full path as the constructor argument and then simply call the FileInfo.Name file
and you will get just the name of the file.
24. What does the OpenFile() method of the OpenFileDialog
control do?
The OpenFile() method opens the file selected by the user
with read-only permission. The file is specified by the FileName property.
25. How do you retrieve the customized properties of a .NET
application from the XML .config file?
Initialize an instance of the AppSettingsReader class. Call
the GetValue() method of the AppSettingsReader class, passing in the name of
the property and the type expected. Finally, assign the result to the
appropriate variable.
26. What is the difference between a toolstrip drop-down
button and a toolstrip split button?
The difference between a toolstrip drop-down button and a
toolstrip split button is that a toolstrip split button is a combination of two
controls - a push button and a drop-down button; whereas, a toolstrip drop-down
button is a single control.
27. Which event of a TextBox control helps in restricting a
text box from accepting numeric digits in .NET 4.0?
The KeyPress event of a text box is used to restrict it from
accepting numeric digits or any other character.
28. How would you create an ellipse, which is a non-
rectangular window?
Open a new Windows form, which is by default rectangular in
design and then set the TransparencyKey property to the same value as
BackColor, which will effectively make the background of the form transparent.
Then, set the FormBorderStyle property to FormBorderStyle.None, which removes
the contour and contents of the form.
29. What does the Checked property of the DateTimePicker
control do?
The Checked property holds either true or false value. It
holds true, when the Value property hold a valid date-time value and is
updatable; otherwise, false.
30. Name the classes used to handle standard menu in a
MenuStrip control.
The two main classes used to handle standard menu in a
MenuStrip control are:
MenuStrip - Acts as a container for the menu structure of a
form.
ToolStripMenuItem - Supports the items in a menu system
(including the menus, such as File and Edit).
31. How can you attach a horizontal scroll bar with the
ListBox control?
You need to set the the MultiColumn property of the ListBox
control to True to attach a horizontal scroll bar with it.
32. What is the difference between the Add() and Insert()
methods of a ListBox control?
The Add() method simply adds an item into the list box;
whereas, the Insert() method inserts an item at the specified index.
33. Consider a situation where you have added panels in a
StatusBar control; however, they are not displayed at run time. What could be
the reason for this?
To display panels in the StatusBar control, the ShowPanels
property needs to be set to true.
34. What is the function of the SizeMode property of the
PictureBox control?
The SizeMode property determines how the picture will be
displayed in the PictureBox control. The following five enumerations are used
to set the value of the SizeMode property:
Normal - Represents Standard picture box behavior (the
upper-left corner of the image is placed at upper-left in the picture box)
StretchImage - Displays image according the PictureBox size
AutoSize - Increases or decreases the picture size
automatically as per the actual size of the PictureBox control.
CenterImage - Displays the image in the center if it is
smaller than the PictureBox control; otherwise, the center part of the image is
placed in the PictureBox control and its outside edges are clipped
Zoom - Helps in stretching or shrinking the image so that it
fits the PictureBox control, by maintaining the aspect ratio of the image
35. How can you prevent users of an application from editing
the text in the ComboBox controls in .NET 4.0?
The ComboBox class contains the DropDownStyle property,
which is used to define the display style of the items in the ComboBox control.
The DropDownStyle property accepts a value from the ComboBoxStyle enumeration,
which contains three members to define the styles for the items: Simple, DropDownList,
and DropDown. The DropDownList value of the ComboBoxStyle enumeration is
selected to set a ComboBox control as non-editable by users, as shown in the
following code snippets:
Code for VB:
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
Code for C#:
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
36. Which class manages the event and layout of all
ToolStrip elements?
The ToolStripItem class manages the event and layout of all
elements that the ToolStrip control contains.
37. How can you place a border around a picture box?
The PictureBox control offers the BorderStyle property,
which can be set to define the style of its border. This property can accept
any of the three values from Fixed3D, FixedSingle, or None. These properties
can be easily set through code or through the Properties window of the Visual
Studio IDE.
38. How do we format numbers, dates, and currencies in a
text box?
Each type has a ToString() method that can used to format
date, currencies, and numbers. You can also use the String.Format() method to
format these things as well. To format dates, use the ToString() member of the
DateTime type.
39. What is the use of the Panel control? Does it display at
runtime?
Panels acts as a container to group other controls. It is an
important control, when you want to show/hide a group of controls and relocate
a number of controls simultaneously.
When you generate a new control at runtime, it works as a
container control. As we know, it is a container control; therefore, it is not
displayed at runtime.
40. Is it possible to add an image on the RadioButton
control?
Yes, you can add an image on the RadioButton control by
setting the Image property.
41. What is the use of a toolstrip container?
A toolstrip container is used to contain controls, such as
ToolStrip, MenuStrip, and StatusStrip, so that these controls can be docked and
moved at the run time.
42. Name the methods, available in .NET 4.0, that are used
to add and delete items from a ListBox control?
The following methods can be used to add and delete items
from a ListBox control. The Items.Add() and Items.Insert() methods are used to
add items; whereas, the Items.Remove(), Items.RemoveAt(), and Items.Clear()
methods are used to delete items from a ListBox control.
43. What is the importance of a Button control?
A Button control is an important Windows control, which
provides the most common way of creating and handling an event in the code with
the help of its Click event.
44. How can you unselect the selected items in a ListView
control programmatically in .NET 4.0?
The syntax to unselect the selected items in the ListView
control is shown in the following code snippets:
Code for VB:
Me.listView1.SelectedItems.Clear()
Code for C#:
this.listView1.SelectedItems.Clear();
45. How can you get the text of the RichTextBox control,
including all rich text format strings in .NET 4.0?
The Rtf property of the RichTextBox control is used to set
or get texts, including the RTF format code.
46. What is the use of a Timer control? Can a Timer control
pause?
The Timer control is a mechanism to perform an iterative
task at a specified time interval. You cannot pause it because it can only
start and stop.
47. What is die difference between a CheckBox control and a
RadioButton control?
A CheckBox control is square shaped; whereas, a RadioButton
control is round in shape. Moreover, you can select more than one CheckBox
control from a group of CheckBox controls; whereas, you can select only a
single RadioButton control from a group of RadioButton controls.
48. Can you write a class without specifying a namespace?
Which namespace does it belong to by default?
Yes, we can write a dass without specifying namespace and
that class belongs to a global namespace that has no name.
49. What are the three states set in the CheckState property
of CheckBox?
Checked
Unchecked
Indeterminate
50. How can you display an icon at runtime on the
StatusStrip control?
The following code snippet shows the code to display an icon
at runtime on the StatusStrip control:
toolStripStatusLabel2.Image =
Bitmap.FromFile("D:\\Indiabix\\Images\\1.bmp");
51. Can you add more than one item simultaneously in the
ListBox control?
Yes, You can add more than one item simultaneously in the
ListBox control by using the AddRange() method.
52. What is the difference between a MenuStrip control and a
ContextMenuStrip control?
The difference between a MenuStrip control and a
ContextMenuStrip control is that a MenuStrip control is associated with the
Windows Form; whereas, a ContextMenuStrip control is associated with a control,
which is added to the Windows Form.
53. What are the values that can be assigned to the
DialogResult property of a Button control?
The DialogResult property of a Button control can be
assigned a value from the DialogResult enumerations, which are as follows:
Abort-Returns Abort
Cancel-Returns Cancel
Ignore-Returns Ignore
No-Returns No
None-Nothing is returned from the dialog box
OK-Returns OK
Retry-Returns Retry
Yes-Returns Yes
54. Why do you require user-defined controls?
User-defined controls are particularly useful in situations
where you need to enhance the functionality of an existing control.
55. Is it possible to enter more than one line in a TextBox
control?
Yes, it is possible to enter more than one line in a TextBox
control. To do this, you need to set the Multiline property of the TextBox
control to True. You can set this property at design time as well as runtime.
The syntax to set this property at runtime is as follows:
Textbox1.Multiline = true;
56. How can you enable a text box to change its characters
format, so that users can enter password?
You can set the PasswordChar property of the TextBox class
to True to enable it to accept passwords. The code to change the PasswordChar
property of the TextBox class is given as follows:
textBox1.PasswordChar = '*';
57. What does the TickFrequency property of the TrackBar
control do?
The TickFrequency property gets or sets a value that
specifies the distance between ticks. By default, the distance between ticks is
1.
58. Is it possible to associate a control with more than one
ContextMenu control?
No, we cannot associate a control with more than one ContextMenu
control.
59. What is the difference between the Panel and GroupBox
control?
The Panel and GroupBox controls both can be used as a
container for other controls, such as radio buttons and check box. The main
differences between a Panel and a GroupBox control are as follows:
Panel does not display captions, while GroupBox do
Panel has scrollbar, while GroupBox does not
60. Does a Timer control appear at run time?
Timer is a component; therefore, it does not appear at run
time.
61. What is the difference between a ListBox control and a
ComboBox control?
With a ListBox control, the user can only make a selection
from a list of items; whereas, with a ComboBox control, the user can make a
selection from the list of items as well as can add custom entry and select the
same.
62. What is the function of MinDate and MaxDate properties
of the MonthCalender control?
The MinDate and MaxDate properties allow users to get and
set the minimum and maximum allowable date.
63. Name the parent class for all Windows controls.
The Control class or System.Windows.Forms.Control class is
the parent class for all Window controls.
64. What is the MaskedTextBox control? What does the Mask
property do?
The MaskedTextBox control is an improvement of the TextBox
control. It forces the user to provide the proper input, which is specified by
the Mask property. In other words, it prevents the user to provide any invalid
input to an application. The Mask property gets or sets the input type to the
MaskedTextBox control. There are many built-in formats for the Mask property,
such as phone no., short date, time, zip code, and custom.
65. How can you adjust the height of a combo box drop-down
list?
You can control the height of a combo box drop-down list by
setting the MaxDropDownItems property of the combo box. The MaxDropDownItems
property sets the maximum number of entries that will be displayed by the
drop-down list.
66. How can you enforce a text box to display characters in
uppercase?
The TextBox class contains the CharacterCasing property,
which is used to specify the case of the content for a text box. This property
accepts a value from the CharacterCasing enumeration of .NET Framework. The
members specified in the CharacterCasing enumeration are Lower, Upper, and
Normal. You can select any one of these enumerations as a value for the
CharacterCasing property of a specified text box, as shown in the following
code snippet:
textBox1.CharacterCasing = CharacterCasing.Upper;
67. Is it possible to associate a control with more than one
ContextMenu?
No, we cannot associate a control with more than one
ContextMenu.
68. How can you check/uncheck all items in the
CheckedListBox control in .NET 4.0?
To check all items in .NET, you can use the following code
snippet:
Code for VB:
Dim i as Integer
For i = 0 To myCheckedListBox.Items.Count - 1
myCheckedListBox.SetItemChecked(i, True)
Next
Code for C#:
for( int i = 0; i < myCheckedListBox.Items.Count; i++ )
{
myCheckedListBox.SetItemChecked(i, true);
}
69. How can we disable the context menu for a TextBox
control?
The TextBox class contains the ContextMenuStrip property.
When we set this property to a dummy instance of the ContextMenu class, the
TextBox control is unable to provide any context menu on the right-click of the
mouse.
70. How can you move and resize a control on a Windows form?
You can make use of the SetBounds() method to move as well
as resize the control on a Windows form.
71. What is use of the DropDownStyle property of the
ComboBox control?
The DropDownStyle property changes the style of the ComboBox
control. It consists of Simple, DropDown, and DropDownList as its values. When
you select Simple, the list of items are displayed as a ListBox control. When
you select DropDown, the list is displayed in a drop down style. When you
select DropDownList, the list displayed in a drop down style and you cannot
edit its text.
72. What is the difference between pixels, points, and em's
when fonts are displayed?
A pixel is the lowest-resolution dot that the computer
monitor supports. Its size depends on user's settings and the size of the
monitor. A point is always 1/72 of an inch. An em is the number of pixels it
takes to display the letter M.
Daynamic Programming Interview Question
1. What is Dynamic Language Runtime (DLR)?
DLR is a runtime environment that allows you to integrate
dynamic languages with the Common Language Runtime (CLR) by adding a set of
services, such as expression trees, call site caching, and dynamic object
interoperability to the CLR.
The System.Dynamic and System.Runtime.CompilerServices
namespaces are used to hold the classes for DLR. It also provides dynamic
features to statically-typed languages, such as C# and Visual Basic to enable
their interoperation with dynamic languages.
2. What are the advantages of DLR?
The various advantages provided by DLR are:
Allows you to easily implement the dynamic languages to the
.NET Framework.
Provides dynamic features to statically-typed languages. The
statically-typed .NET Framework languages, such as C# and Visual Basic can
create dynamic objects and use them together with statically-typed objects.
Implements sharing of libraries and objects, which means
that the objects and libraries implemented in one language can be used by other
languages using DLR. The DLR also enables interoperation between
statically-typed and dynamic languages.
Enables fast execution of dynamic operations by supporting
advance caching.
3. Give a brief introduction to Binders.
Binders are used by DLR to communicate with not the .NET Framework
but also with various other services, such as Silverlight and COM. These
services represent language-specific semantics and specify how a particular
operation can be performed at the call site.
Call sites refer to the area in the code where logical and
mathematical operations, such as a + b or a.b() are performed on dynamic
objects.
4. Explain the different services provided by DLR to CLR.
The services provided by DLR to CLR are used for supporting
dynamic languages. These services include the following:
Expression Trees - Refers to the representation of code in a
data structure similar to a tree. However, expression trees in DLR are the
advanced version of the expression trees that were introduced with LINQ in .NET
3.5. Therefore, DLR has extended the functionalities of Language Integrated
Query (LINQ) expression trees, such as control flow, assignment, and other
language-modeling nodes to a dynamic language. These expression trees define
the semantics of a language in form of an abstract syntax tree (AST). AST
enables the DLR to dynamically generate code, which the CLR executes at
runtime.
Call Site Caching - Enables the DLR to store the information
of the operations and characteristics of the variables, such as their data
type. The call site caching services also enables to check whether such
operations have been performed previously to retrieve all the information about
the variable. The place where DLR stores these values is called a call site.
Dynamic Object Interoperability - Enables the DLR to provide
a set of classes and interfaces that represent dynamic objects and operations.
These classes and interfaces can be used to create classes for dynamic
libraries, which can be used in static and dynamic type languages.
5. Name the binders provided by .NET Framework 4.0.
.NET Framework 4.0 provides the following binders:
Object Binder - Enables to communicate with .NET objects.
JavaScript Binder - Enables to communicate with JavaScript
in Silverlight.
Python Binder - Enables to communicate with IronPython.
Ruby Binder - Enables to communicate with IronRuby.
COM Binder - Enables to communicate with COM.
6. Explain ExpandoObject and DynamicObject classes.
The ExpandoObject class refers to a class whose members can
be explicitly added and removed at runtime. In other words, the ExpandoObject
class allows dynamic binding of the objects, which enables you to use standard
syntax, similar to the dynobj.Method method instead of using more complex
syntax, such as dynobj.getAttribute("Method").
The DynamicObject class enables you to define the dynamic
behavior for an object at run time. This class cannot be instantiated directly;
therefore, to implement the dynamic behavior, you must inherit from the
DynamicObject class and override the necessary methods. It allows you to define
the specific operations that can be performed on dynamic objects as well the
methods to perform those operations.
7. What is the difference between dynamic and var data
types?
The difference between the var and dynamic data types is
that the var data type is strongly type checked at the compile time; whereas,
the dynamic data type is type checked by the compiler only at run time. After
declaring a var data type, you cannot explicitly change its type throughout the
execution of the program; however, a variable of the dynamic data type can be
changed during runtime. Another major difference between the two is that
dynamic type can also be used as the return type for methods, for which var
cannot be used.
8. Which class is used for converting the data types?
The System.Convert class provides a complete set of methods
for converting the data types.
Application Deployment Question
1. What is deployment?
Deployment refers to the distribution of an application
among various end-users. It is a process that makes software available for use
by just installing it on the client computer.
2. List different ways of deployment that are supported by
.NET Framework 4.0.
Windows Installer
ClickOnce
XCOPY
Copy Web Site
Publish Web Site tool
3. What is XCOPY?
XCOPY enables you to deploy an application by copying the
application directory and all subdirectories to the target computer and then
executing the application on the client. The application starts executing on
the target computer by using its assembly file, which is a self-description
file that contains all the information about the application. The XCOPY
deployment does not make any impact on the target system while configuring the
components and registering entries, and is therefore known as zero-impact
installation.
4. Does XCOPY copy the hidden and system files?
No. By default, XCOPY excludes the hidden and system files.
However, you can include the hidden and system files using the /h switch.
5. Why do you use Windows Installer?
The Windows Installer deployment technique allows you to
deploy Windows-based and Web applications by creating a Windows Installer
Package. The installer package has an extension of .msi and it contains the
application, any dependent files, registry entries, and the rest. The installer
package can then be distributed to various end-users by simply copying it on
the target computers.
The end-users can then run the installer package to install
the application anywhere in their computers. The installation takes place using
the installation wizard; therefore, the users can easily install the
application on their system. Once your application is installed on the target
computer, end-users can open the application from the installed location.
6. Can you deploy an ASP.NET Web application project using
the Copy Web Site option?
No. The Copy Web Site option can only be used to deploy the
Web sites.
7. How can you determine whether you should deploy the
application or publish the application?
If you want to host the application on a shared hosting
environment, you should use publishing; whereas, if you want to create a Web
application that is downloaded from a Web site, you should deploy the
application to create a setup.exe file.
8. How can you deploy an ASP.NET Web application?
You can deploy an ASP.NET Web application using either the
Windows Installer deployment or ClickOnce deployment technique.
9. What is Application Cache?
When a ClickOnce application is installed locally or hosted
online, it is stored in the ClickOnce application cache of the client computer.
The ClickOnce application cache is a set of hidden directories placed under the
Local Settings directory of the current user's Documents and Settings folder.
The application cache contains all the application files, assemblies,
configuration files, application and user settings, and data directory. In case
the ClickOnce applications are hosted online, the size of the ClickOnce
application cache gets limited to a specified amount; whereas, the installed
applications do not restrict to the cache size limitation. The cache storage
quota is responsible to determine the size of the application cache.
10. What are the enhancements in ClickOnce deployment in
.NET 4.0?
In .NET 4.0, the ClickOnce deployment technology is enhanced
with the following features:
Support for .NET Framework 4.0 version - Creates
applications by using Visual Studio 2010 that can target .NET Framework 4.0 and
its new features.
Support for multiple versions of the .NET Framework -
Creates applications that are compatible with multiple versions of the .NET
Framework. You can specify the target framework for an application as .NET Framework
3.5 or .NET Framework 4 while creating the application.
Enhanced logging feature - Stores logging information that
includes various parameters passed to the ClickOnce runtime, the browser
settings, and ClickOnce security options.
Custom Installer and User Interface - Allows you to create a
custom graphical user interface for installing and updating the .exe
applications. In addition, the custom installer can have custom dialog boxes
for security and maintenance operations.
11. What is the difference between deploying and publishing
an application?
In deployment, you can create a new setup and deployment
project. In this project, you can add the project output and create a setup.exe
file. After creating an executable file, you need to login into the server and
execute the setup.exe file to install the application. On the other hand, in
publishing, you need to right-click the application in the Solution Explorer
and select Publish to publish the application. Then, you specify a location
where the application is to be published. The users can then install the
application from the location where you have published it and run locally even
when the computer is offline.
12. What do you mean by Merge Module projects?
Merge Module projects are used to package the files and
components that are shared between multiple applications. The Merge Module
project file contains the .msm extension. The .msm file includes files,
resources, registry entries, and setup logic. This file is merged with a
Windows installer (.msi) file to correctly install the shared files. If a
single merge module is used by more than one application, then you need to add
that merge module in the package only once.
13. What is the need of Copy Web Site?
Copy Web Site is a tool used to deploy the Web site by
copying its content files. The Copy Web Site tool also checks whether or not
the latest version of a file is present at the destination. If files of the
most recent version are found at the destination, then the Copy Web Site tool does
not superimpose the older version of files. The Copy Web Site deployment tool
consists of the following main entities:
Project source - Specifies the source directory, which
contains the contents and references of a Web site at development time. In simple
words, you can say that the project source specifies the site that you
currently have opened in Visual Studio 2010. The Copy Web Site tool picks all
the files for deployment from this location.
Project destination - Specifies the destination folder where
you have to deploy the application. This destination directory can be placed on
remote computers or servers, which allow you to copy the Web site contents
using the Front Page Server Extensions, FTP, or HTTP protocol implementations
for content transfer.
Synchronizing two Web sites - Synchronizes two Web sites by
copying each other's files. Synchronization checks the files on the local and
remote sites and ensures that all files on both sites are up to date.
14. What is the use of the Copy Project command?
The Copy Project command copies only the files required to
run the project and pastes it on the target server. It does not deploy the
complete project; therefore, IIS directory settings are not automatically
configured.
15. Can Windows applications and the Web applications be
deployed using the same template of Setup and Deployment project?
No. the Windows applications use the Setup Project template;
whereas, the Web applications use the Web Setup Project template. After the
deployment, their installation takes place in the similar way.
16. Explain the .NET Framework deployment features.
In a general context, .NET Framework includes the following
deployment features:
No-impact applications - Provides application isolation and
removes DLL conflicts.
Private components by default - Enables the components to
deploy to the application directory and to be visible only to the containing
application.
Side-by-side versioning - Enables you to select one of the
multiple versions.
XCOPY deployment and replication - Refers to the
self-descriptive application that is deployed without the need to store
registry entries.
On-the-fly updates - Allows for the updating of the DLLs of
the remote computers.
Integration with the Microsoft Windows Installer - Makes the
features, such as advertising, publishing, repairing, and install-on-demand
available during deployment of an application.
Enterprise deployment - Eases the task of software
distribution.
Downloading and caching - Specifies that the downloads are
kept smaller and the components are isolated for application use.
Partially trusted code - Enables code-based identification.
Ajax Tools Interview Question
1. What is ASP.NET AJAX?
ASP.NET AJAX, mostly called AJAX, is a set of extensions of
ASP.NET. It is developed by Microsoft to implement AJAX functionalities in Web
applications. ASP.NET AJAX provides a set of components that enable the
developers to develop applications that can update only a specified portion of
data without refreshing the entire page. The ASP.NET AJAX works with the AJAX
Library that uses object-oriented programming (OOP) to develop rich Web
applications that communicate with the server using asynchronous postback.
2. What is the difference between synchronous postback and
asynchronous postback?
The difference between synchronous and asynchronous postback
is as follows:
Asynchronous postback renders only the required part of the
page; whereas, synchronous postback renders the entire page for any postback.
Asynchronous postback executes only one postback at a time,
that is, if you have two buttons doing asynchronous postback, the actions will
be performed one by one; whereas, synchronous postback executes all the actions
at once.
Asynchronous postback only modifies the update panel that
raises the postback; whereas, synchronous postback modifies the entire page.
3. What technologies are being used in AJAX?
AJAX uses four technologies, which are as follows:
JavaScript
XMLHttpRequest
Document Object Model (DOM)
Extensible HTML (XHTML) and Cascading Style Sheets (CSS)
4. Why do we use the XMLHttpRequest object in AJAX?
The XMLHttpRequest object is used by JavaScript to transfer
XML and other text data between client and server. The XMLHttpRequest object
allows a client-side script to perform an HTTP request. AJAX applications use
the XMLHttpRequest object so that the browser can communicate to the server
without requiring a postback of the entire page. In earlier versions of
Internet Explorer, MSXML ActiveX component is liable to provide this
functionality; whereas, Internet Explorer 7 and other browsers, such as Mozilla
Firefox, XMLHttpRequest is not liable to.
5. How can we get the state of the requested process?
XMLHttpRequest get the current state of the request
operation by using the readyState property. This property checks the state of
the object to determine if any action should be taken. The readyState property
uses numeric values to represent the state.
6. What are the different controls of ASP.NET AJAX?
ASP.NET AJAX includes the following controls:
ScriptManager
ScriptManagerProxy
UpdatePanel
UpdateProgress
Timer
7. What are the new features included in the Microsoft AJAX library?
The Microsoft AJAX library is a client-based JavaScript
library that is compatible with all modern browsers and offers a lot of
functionality as compared to JavaScript. This library is released with new
features and fully supports ASP.NET 4.0'. The new features included in the
Microsoft AJAX library are as follows:
Imperative syntax - Supports simple imperative syntax that
is used to create and manage controls.
Script loader - Retrieves all scripts that are needed by one
or more client component or control automatically and executes the scripts in
the order in which they are received.
Client data access - Supports to access client data and
display by client data control and client template.
Client datacontext - Supports read and write permission to
data from a database.
The AdoNetDataContext class - Enables you to easily interact
with an ADO.NET Data Services service.
jQuery integration - Helps to access the elements in your
Web pages, work with client-side events, enable visual effects, and make it
easier to use AJAX in your applications.
8. Explain the Step property of the NumericUpDownExtender
control.
The Step property sets the steps for numeric increment and
decrement. The default value is 1.
9. What are the new features of ASP.NET AJAX 4.0?
ASP.NET 4.0 AJAX includes several new features that provide
more functionality to a user. These features are as follows:
Support for live data binding.
Support for client-side template rendering.
Support for declarative instantiation of client components.
Support for using the observer pattern on JavaScript objects
and arrays.
Support for invoking ADO.NET data services and data
contexts.
Support for the DataView control.
10. Why do we use the UpdateProgress control in AJAX?
The UpdateProgress control is somewhat related to the
UpdatePanel control. The UpdateProgress control enables you to design a
user-friendly interface when a Web page consists of a number of UpdatePanel
controls for partial-page rendering.
The UpdateProgress control makes you aware of the status
information about the partial-page updates in the UpdatePanel control.
11. What is JSON?
JSON is an abbreviation of JavaScript Object Notation. It is
a safe and reliable data interchange format in JavaScript, which is easy to
understand not only for the users but also for the machines.
12. How many validation controls are available in ASP.NET
AJAX 4.0?
The following validation controls are available in ASP.NET
AJAX 4.0:
FilteredTextBoxExtender - Enables you to apply filtering to
a text box.
MaskedEditExtender and MaskedEditValidator - Restricts a
user to enter only a certain pattern of characters in the TextBox by applying a
mask to the input.
ValidatorCalloutExtender - Attaches to the ASP.NET
validators so that the error messages are not displayed as a simple text but as
a balloon-style ToolTip.
NoBot - Prevents the spam/bot from filling the input forms
automatically and uses the Completely Automated Public Turing test to tell
Computers and Humans Apart (CAPTCHA), which is a type of challenge-response
test to ensure that the response is not generated by the computer.
PasswordStrengthExtender - Measures the strength of the
password text entered within the text box by validating with the different
strength specified parameters
13. Explain the limitations of AJAX.
The following are the limitations of AJAX:
It is difficult to bookmark a particular state of the
application.
Function provided in the code-behind file do not work
because the dynamic pages cannot register themselves on browsers history engine
automatically.
If JavaScript is disabled, then AJAX is not able to perform
any work.
Response time may be slow because different controls of a
page are loaded at different time.
14. What are the differences between AJAX and JavaScript?
The differences between AJAX and JavaScript are given as
follows:
AJAX sends request to the server and does not wait for the
response. It performs other operations on the page during that time. JavaScript
make a request to the server and waits for response.
AJAX does not require the page to refresh for downloading
the whole page while JavaScript manages and controls a Web page after being
downloaded.
AJAX minimizes the overload on the server since the script
needs to request once while JavaScript posts a request that updates the script
every time.
15. Explain the UpdatePanel control.
The UpdatePanel control specifies the portions of a Web page
that can be updated together. As the UpdatePanel control refreshes only a
selected part of the Web page instead of refreshing the entire page with a
postback, you get more flexibility to create rich and client-centric Web
applications.
Refreshing a selected part of the Web page is referred as
partial-page update. You can add one or more UpdatePanel control in the Web
page, which automatically participates in partial-page update without custom
client script. The UpdatePanel control uses the UpdatePanel class to support
the partial-page rendering.
16. What does the DynamicPopulateExtender control do?
The DynamicPopulateExtender control populates the contents
of a control dynamically. It enables you to send an asynchronous call to the
server that dynamically populates the contents of a control. The
DynamicPopulateExtender control replaces the contents of a control with the
result of a Web service or page method call.
17. What does the MinimumPrefixLength property of the
AutoCompleteExtender control do?
The MinimumPrefixLength property sets the minimum number of
characters that must be entered before getting suggestions from the Web
service.
18. What is the importance of client-side libraries?
Client-side libraries contain built-in code to make
asynchronous calls over XMLHTTP. These libraries automatically handle browser
compatibility issues. These libraries are based on a programming model similar
to ASP.NET.
19. Can we call server-side code from JavaScript?
Yes, page methods and Web services are the two techniques to
call the server-side code from JavaScript.
20. What are the components of the ASP.NET AJAX
architecture?
You can divide the ASP.NET AJAX architecture into two
components - AJAX client architecture and AJAX server architecture.
21. Describe AJAX Control Extender Toolkit.
AJAX Control Toolkit is a set of extenders that are used to
extend the functionalities of the ASP.NET controls. The extenders use a block
of JavaScript code to add new and enhanced capabilities to the ASP.NET
controls. AJAX Control Toolkit is a free download available on the Microsoft
site. You need to install this toolkit on your system before using extenders.
22. Explain the need of the Timer control in AJAX.
The Timer control is used with an UpdatePanel control to
allow partial-page updates at a specified interval. It is mostly used when a
periodically partial-page update for one or more UpdatePanel controls is
required without refreshing the entire page.
The Timer control is a server control that sets a JavaScript
component in the Web page. The interval property of the Timer control specifies
time in milliseconds. Similar to the UpdatePanel control, the Timer control
also requires an instance of the ScriptManager control in the Web page.
When the Timer control initiates a postback, the Tick event
is raised on the server for which you can provide an event handler to perform
the actions when the page is submitted to the server. The Tick event occurs
when the time specified in the interval property has elapsed and the page is
posted on the server. You can add one or more Timer controls on a Web page.
Usually the entire page requires only a single Timer control; however, you can
use multiple Timer controls, if the UpdatePanel controls are being updated at
different intervals.
23. List the different states of XMLHttpRequest with their
description.
The different states of the XMLHttpRequest object are as
follows:
Uninitialized - Refers to the state when the object has not
been initialized.
Open - Refers to the state when the object has been created;
however, the send function has not been invoked.
Sent -Refers to the state when the send function is invoked;
however, the status and headers are not available.
Receiving - Refers to the state when the process is
receiving data.
Loaded - Refers to the state when the procedure is completed
and the entire data is available.
24. Can we nest the UpdatePanel controls?
Yes, we can nest the UpdatePanel control.
25. What is the role of the ScriptManagerProxy control?
A Web page cannot contain more than one ScriptManager
control. You can use the ScriptManagerProxy control to add scripts to other
pages; however to perform such an operation, you need to work with a master
page that contains the ScriptManager control. If you have only few pages that
need to register to a script or a Web service, then you should remove these
pages from the ScriptManager control and add them as individual pages by using
the ScriptManagerProxy control. If you include the scripts on the master page
by the ScriptManager control, then the items get downloaded on each page that
extends the master page, even if they are not necessary.
26. What is the work of the ConformOnFormSubmit property in
the ConfirmButtonExtender control?
The ConformOnFormSubmit property determines whether or not
the confirm dialog box should wait when the form is submitted for display.
27. What is the syntax to create AJAX objects?
AJAX uses the following syntax to create an object:
var myobject = new AjaxObject("page path");
The page path is the URL of the Web page containing the
object that you want to call. The URL must be of the same domain as the Web page.
28. Is there any difference between HTML and XHTML?
Extensible HTML (XHTML) is a markup language that provides
the mixture expressions of HTML and XML. XHTML is a flexible markup language
that enables automated processing by standard XML tools, which was difficult in
HTML.
29. What are the requirements to run ASP.NET AJAX
applications on a server?
AJAX is a built-in functionality of .NET Framework 4.0.
Therefore, you can run an AJAX application by just installing Microsoft Visual
Studio 2010. However, to use extenders in your applications, you are required
to install AJAX Control Toolkit and copy the AjaxControlToolkit.dll file to the
Bin directory of your application.
30. Describe the situations in which AJAX should not be
used.
You should not use AJAX if:
You want the page to show in a search engine, such as
Google, because WebCrawler does not execute JavaScript code.
The browser does not support JavaScript.
You want to create a secure application.
31. What is the use of the ScriptManager control in AJAX?
The ScriptManager control is a core control that performs a
key role in implementing the ASP.NET AJAX functionality. It helps to use
JavaScript for the Microsoft AJAX Library. It should be noted that AJAX Library
on a Web page can only be used if the Web page contains the ScriptManager
control. This control makes use of the ScriptManager class to maintain the AJAX
script libraries and script files. It allows for partial page rendering, Web
service calls, and use of ASP.NET AJAX Client Library by rendering the AJAX
Library scripts to the browser.
32. How can you find out that an AJAX request has been
completed?
You can find out that an AJAX request has been completed by
using the readyState property. If the value of this property equals to four, it
means that the request has been completed and the data is available.
33. Is it possible to use multiple ScriptManager controls on
a Web page?
No, it is not possible.
34. What are the new controls introduced in ASP.NET AJAX
Control Toolkit?
The following controls are introduced with the new version
of AJAX Control Toolkit:
SeaDragonExtender control - Refers to the control that is
used to deeply zoom the images. You can zoom in or out the image or the
particular portion of the image by using the mouse. You can also create a menu
over the Seadragon control. This control is helpful when you want to analyze
the image closely.
AsyncFileUploadExtender control - Refers to the control that
provides the facility to upload and save the files on the server asynchronously.
You can check the outcome either at the server or client side.
35. Briefly describe ASP.NET AJAX Framework.
ASP.NET AJAX Framework provides a platform where developers
can develop such type of applications that use the AJAX concept. The AJAX provides
the collection of technologies to create dynamic pages at the client side. The
JavaScript requests are responsible to retrieve data from the server or send
data to the server. Even some processing at server also requires handling
requests, such as searching and storing of data. These tasks are achieved more
easily using the AJAX Framework.
AJAX Framework is completely devoted to process requests.
The objective of the AJAX engine is to reduce the delays that the user notices
while performing a postback to the server. AJAX Framework allows JavaScript
functions to send requests to server at the client side. On the other side, it
allows the server to process the client's request, searches data, and responds
the result to the browser.
36. Is the AjaxControlToolkit.dll file installed in the
Global Assembly Cache?
No, you have to copy this file to the Bin folder of your
application.
37. What are the different ways to pass parameters to the
server?
We can pass parameters to the server using either the GET or
POST method. The following code snippets show the example of both the methods:
Get: XmlHttpObject.Open("GET",
"file1.txt", true);
Post: XmlHttpObject.Open("POST",
"file2.txt", true);
38. What are the extender controls?
The extender controls uses a block of JavaScript code to add
new and enhanced capabilities to ASP.NET. The developers can use a set of
sample extender controls through a separate download - AJAX Control Toolkit
(ACT).
39. Describe the AccordionExtender control.
The AccordionExtender control is similar to the
CollapsiblePanelExtender control. It allows you to group multiple collapsible
panels in a single control. At the same time, it also manages the collapsed and
expanded state of each panel; therefore, expanding one panel at a time. In
other words, the AccordionExtender control does not support expanding two or
more panels simultaneously. Instead, the header templates of all the panels are
always visible so that you can click on any of them to display the hidden
contents. By default, the AccordionExtender control opens with one panel as
expanded.
.Net Framework Interview Question
1. What is .NET Framework?
.NET Framework is a complete environment that allows
developers to develop, run, and deploy the following applications:
Console applications
Windows Forms applications
Windows Presentation Foundation (WPF) applications
Web applications (ASP.NET applications)
Web services
Windows services
Service-oriented applications using Windows Communication
Foundation (WCF)
Workflow-enabled applications using Windows Workflow
Foundation (WF)
.NET Framework also enables a developer to create sharable
components to be used in distributed computing architecture. NET Framework
supports the object-oriented programming model for multiple languages, such as
Visual Basic, Visual C#, and Visual C++. .NET Framework supports multiple
programming languages in a manner that allows language interoperability. This
implies that each language can use the code written in some other language.
2. What are the main components of .NET Framework?
.NET Framework provides enormous advantages to software
developers in comparison to the advantages provided by other platforms.
Microsoft has united various modern as well as existing technologies of
software development in .NET Framework. These technologies are used by
developers to develop highly efficient applications for modern as well as
future business needs. The following are the key components of .NET Framework:
.NET Framework Class Library
Common Language Runtime
Dynamic Language Runtimes (DLR)
Application Domains
Runtime Host
Common Type System
Metadata and Self-Describing Components
Cross-Language Interoperability
.NET Framework Security
Profiling
Side-by-Side Execution
3. List the new features added in .NET Framework 4.0.
The following are the new features of .NET Framework 4.0:
Improved Application Compatibility and Deployment Support
Dynamic Language Runtime
Managed Extensibility Framework
Parallel Programming framework
Improved Security Model
Networking Improvements
Improved Core ASP.NET Services
Improvements in WPF 4
Improved Entity Framework (EF)
Integration between WCF and WF
4. What is an IL?
Intermediate Language is also known as MSIL (Microsoft
Intermediate Language) or CIL (Common Intermediate Language). All .NET source
code is compiled to IL. IL is then converted to machine code at the point where
the software is installed, or at run-time by a Just-In-Time (JIT) compiler.
5. 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 a PE file either (an
.exe or) .dll with Microsoft
intermediate language (MSIL code with Microsoft intermediate
language (MSIL) code or in a
stand-alone PE file, that contains only assembly manifest
information.
6. What are code contracts?
Code contracts help you to express the code assumptions and
statements stating the behavior of your code in a language-neutral way. The
contracts are included in the form of pre-conditions, post-conditions and
object-invariants. The contracts help you to improve-testing by enabling
run-time checking, static contract verification, and documentation generation.
The System.Diagnostics.Contracts namespace contains static
classes that are used to express contracts in your code.
7. Name the classes that are introduced in the
System.Numerics namespace.
The following two new classes are introduced in the
System.Numerics namespace:
BigInteger - Refers to a non-primitive integral type, which
is used to hold a value of any size. It has no lower and upper limit, making it
possible for you to perform arithmetic calculations with very large numbers,
even with the numbers which cannot hold by double or long.
Complex - Represents complex numbers and enables different
arithmetic operations with complex numbers. A number represented in the form a
+ bi, where a is the real part, and b is the imaginary part, is a complex
number.
8. What is managed extensibility framework?
Managed extensibility framework (MEF) is a new library that
is introduced as a part of .NET 4.0 and Silverlight 4. It helps in extending
your application by providing greater reuse of applications and components. MEF
provides a way for host application to consume external extensions without any
configuration requirement.
9. Explain memory-mapped files.
Memory-mapped files (MMFs) allow you map the content of a
file to the logical address of an application. These files enable the multiple
processes running on the same machine to share data with each Other. The
MemoryMappedFile.CreateFromFile() method is used to obtain a MemoryMappedFile
object that represents a persisted memory-mapped file from a file on disk.
These files are included in the System.IO.MemoryMappedFiles
namespace. This namespace contains four classes and three enumerations to help
you access and secure your file mappings.
10. What is Common Type System (CTS)?
CTS is the component of CLR through which .NET Framework
provides support for multiple languages because it contains a type system that
is common across all the languages. Two CTS-compliant languages do not require
type conversion when calling the code written in one language from within the
code written in another language. CTS provide a base set of data types for all
the languages supported by.NET Framework. This means that the size of integer
and long variables is same across all .NET-compliant programming languages.
However, each language uses aliases for the base data types provided by CTS. For
example, CTS uses the data type system. int32 to represent a 4 byte integer
value; however, Visual Basic uses the alias integer for the same; whereas, C#
uses the alias int. This is done for the sake of clarity and simplicity.
11. Give a brief introduction on side-by-side execution. Can
two applications, one using private assembly and the other using the shared
assembly be stated as side-by-side executables?
Side-by-side execution enables you to run multiple versions
of an application or component and CLR on the same computer at the same time.
As versioning is applicable only to shared assemblies and not to private
assemblies, two applications, one using a private assembly and other using a
shared assembly, cannot be stated as side-by-side executables.
12. Which method do you use to enforce garbage collection in
.NET?
The System.GC.Collect() method.
13. State the differences between the Dispose() and
Finalize().
CLR uses the Dispose and Finalize methods to perform garbage
collection of run-time objects of .NET applications.
The Finalize method is called automatically by the runtime.
CLR has a garbage collector (GC), which periodically checks for objects in heap
that are no longer referenced by any object or program. It calls the Finalize
method to free the memory used by such objects. The Dispose method is called by
the programmer. Dispose is another method to release the memory used by an
object. The Dispose method needs to be explicitly called in code to dereference
an object from the heap. The Dispose method can be invoked only by the classes
that implement the IDisposable interface.
14. What is code access security (CAS)?
Code access security (CAS) is part of the .NET security
model that prevents unauthorized access of resources and operations, and
restricts the code to perform particular tasks.
15. Differentiate between managed and unmanaged code?
Managed code is the code that is executed directly by the
CLR instead of the operating system. The code compiler first compiles the
managed code to intermediate language (IL) code, also called as MSIL code. This
code doesn't depend on machine configurations and can be executed on different
machines.
Unmanaged code is the code that is executed directly by the
operating system outside the CLR environment. It is directly compiled to native
machine code which depends on the machine configuration.
In the managed code, since the execution of the code is
governed by CLR, the runtime provides different services, such as garbage
collection, type checking, exception handling, and security support. These
services help provide uniformity in platform and language-independent behavior
of managed code applications. In the unmanaged code, the allocation of memory,
type safety, and security is required to be taken care of by the developer. If
the unmanaged code is not properly handled, it may result in memory leak.
Examples of unmanaged code are ActiveX components and Win32 APIs that execute
beyond the scope of native CLR.
16. What are tuples?
Tuple is a fixed-size collection that can have elements of
either same or different data types. Similar to arrays, a user must have to
specify the size of a tuple at the time of declaration. Tuples are allowed to
hold up from 1 to 8 elements and if there are more than 8 elements, then the
8th element can be defined as another tuple. Tuples can be specified as
parameter or return type of a method.
17. How can you turn-on and turn-off CAS?
YOU can use the Code Access Security Tool (Caspol.exe) to
turn security on and off.
To turn off security, type the following command at the
command prompt:
caspol -security off
To turn on security, type the following command at the
command prompt:
caspol -security on
In the .NET Framework 4.0, for using Caspol.exe, you first
need to set the <LegacyCasPolicy> element to true.
18. What is garbage collection? Explain the difference
between garbage collections in .NET 4.0 and earlier versions.
Garbage collection prevents memory leaks during execution of
programs. Garbage collector is a low-priority process that manages the
allocation and deallocation of memory for your application. It checks for the
unreferenced variables and objects. If GC finds any object that is no longer
used by the application, it frees up the memory from that object.
GC has changed a bit with the introduction of .NET 4.0. In
.NET 4.0, the GC.Collect() method contains the following overloaded methods:
GC.Collect(int)
GC.Collect(int, GCCollectionMode)
Another new feature introduced in .NET is to notify you when
the GC.Collect() method is invoked and completed successfully by using
different methods. The .NET 4.0 supports a new background garbage collection
that replaces the concurrent garbage collection used in earlier versions. This
concurrent GC allocates memory while running and uses current segment (which is
16 MB on a workstation) for that. After that, all threads are suspended. In
case of background GC, a separate ephemeral GC - gen0 and gen1 can be started,
while the full GC - gen0, 1, and 2 - is already running.
19. How does CAS works?
There are two key concepts of CAS security policy- code
groups and permissions. A code group contains assemblies in it in a manner that
each .NET assembly is related to a particular code group and some permissions
are granted to each code group. For example, using the default security policy,
a control downloaded from a Web site belongs to the Zone, Internet code group,
which adheres to the permissions defined by the named permission set.
(Normally, the named permission set represents a very restrictive range of
permissions.)
Assembly execution involves the following steps:
Evidences are gathered about assembly.
Depending on the gathered evidences, the assembly is
assigned to a code group.
Security rights are allocated to the assembly, depending on
the code group.
Assembly runs as per the rights assigned to it.
20. What is Difference between NameSpace and Assembly?
Following are the differences between namespace and
assembly:
Assembly is physical grouping of logical units, Namespace,
logically groups classes.
Namespace can span multiple assembly.
21. Mention the execution process for managed code.
A piece of managed code is executed as follows:
Choosing a language compiler
Compiling the code to MSIL
Compiling MSIL to native code
Executing the code.
22. Is there a way to suppress the finalize process inside
the garbage collector forcibly in .NET?
Use the GC.SuppressFinalize() method to suppress the
finalize process inside the garbage collector forcibly in .NET.
23. How can you instantiate a tuple?
The following are two ways to instantiate a tuple:
Using the new operator. For example,
Tuple<String, int> t = new Tuple<String, int>
("Hellow", 2);
Using the Create factory method available in the Tuple
class. For example,
Tuple<int, int, int> t = Tuple.Create<int, int,
int> (2, 4, 5);
24. Which is the root namespace for fundamental types in
.NET Framework?
System.Object is the root namespace for fundamental types in
.NET Framework.
25. What are the improvements made in CAS in .NET 4.0?
The CAS mechanism in .NET is used to control and configure
the ability of managed code. Earlier, as this policy was applicable for only
native applications, the security guarantee was limited. Therefore, developers
used to look for alternating solutions, such as operating system-level
solutions. This problem was solved in .NET Framework 4 by turning off the
machine-wide security. The shared and hosted Web applications can now run more
securely. The security policy in .NET Framework 4 has been simplified using the
transparency model. This model allows you to run the Web applications without
concerning about the CAS policies.
As a result of security policy changes in .NET Framework
4.0, you may encounter compilation warnings and runtime exceptions, if your try
to use the obsolete CAS policy types and members either implicitly or
explicitly. However, you can avoid the warnings and errors by using the
<NetFx40_LegacySecurityPolicy> configuration element in the runtime
settings schema to opt into the obsolete CAS policy behavior.
26. What is Microsoft Intermediate Language (MSIL)?
The .NET Framework is shipped with compilers of all .NET
programming languages to develop programs. There are separate compilers for the
Visual Basic, C#, and Visual C++ programming languages in .NET Framework. Each
.NET compiler produces an intermediate code after compiling the source code.
The intermediate code is common for all languages and is understandable only to
.NET environment. This intermediate code is known as MSIL.
27. What is lazy initialization?
Lazy initialization is a process by which an object is not
initialized until it is first called in your code. The .NET 4.0 introduces a
new wrapper class, System.Lazy<T>, for executing the lazy initialization
in your application. Lazy initialization helps you to reduce the wastage of
resources and memory requirements to improve performance. It also supports
thread-safety.
28. How many types of generations are there in a garbage
collector?
Memory management in the CLR is divided into three
generations that are build up by grouping memory segments. Generations enhance
the garbage collection performance. The following are the three types of
generations found in a garbage collector:
Generation 0 - When an object is initialized, it is said to
be in generation 0.
Generation 1 - The objects that are under garbage collection
process are considered to be in generation 1.
Generation 2 - Whenever new objects are created and added to
the memory, they are added to generation 0 and the old objects in generation 1
are considered to be in generation 2.
29. Explain covariance and contra-variance in .NET Framework
4.0. Give an example for each.
In .NET 4.0, the CLR supports covariance and contravariance
of types in generic interfaces and delegates. Covariance enables you to cast a
generic type to its base types, that is, you can assign a instance of type
IEnumerable<Tl> to a variable of type IEnumerable<T2> where, T1
derives from T2. For example,
IEnumerable<string> str1= new List<string> ();
IEnumerable<object> str2= str1;
Contravariance allows you to assign a variable of
Action<base> to a variable of type Action<derived>. For example,
IComparer<object> obj1 = GetComparer()
IComparer<string> obj2 = obj1;
.NET framework 4.0 uses some language keywords (out and in)
to annotate covariance and contra-variance. Out is used for covariance, while
in is used for contra-variance.
Variance can be applied only to reference types, generic
interfaces, and generic delegates. These cannot be applied to value types and
generic types.
30. How do you instantiate a complex number?
The following are the different ways to assign a value to a
complex number:
By passing two Double values to its constructor. The first
value represents the real, and the second value represents imaginary part of a
complex number.
For example,
Complex c1 = new Complex(5, 8); /* It represents (5, 8) */
By assigning a Byte, SByte, Intl6, UIntl6, Int32, UInt32,
Int64, UInt64, Single, or Double value to a Complex object. The assigned value
represents the real part of the complex number, and its imaginary part becomes
0. For example,
Complex c2 = 15.3; /* It represents (15.3, 0) */
By casting a Decimal or BigInteger value to a Complex
object.
For example,
Complex c3 = (Complex) 14.7; /* It represents (14.7, 0) */
Assigning the value returned by an operator to a Complex
variable.
For example,
Complex c4 = c1 + c2; /* It represents (20.3, 8) */
31. What is Common Language Specification (CLS)?
CLS is a set of basic rules, which must be followed by each
.NET language to be a .NET- compliant language. It enables interoperability
between two .NET-compliant languages. CLS is a subset of CTS; therefore, the
languages supported by CLS can use each other's class libraries similar to
their own. Application programming interfaces (APIs), which are designed by
following the rules defined in CLS can be used by all .NET-compliant languages.
32. What is the role of the JIT compiler in .NET Framework?
The JIT compiler is an important element of CLR, which loads
MSIL on target machines for execution. The MSIL is stored in .NET assemblies
after the developer has compiled the code written in any .NET-compliant
programming language, such as Visual Basic and C#.
JIT compiler translates the MSIL code of an assembly and
uses the CPU architecture of the target machine to execute a .NET application.
It also stores the resulting native code so that it is accessible for
subsequent calls. If a code executing on a target machine calls a non-native
method, the JIT compiler converts the MSIL of that method into native code. JIT
compiler also enforces type-safety in runtime environment of .NET Framework. It
checks for the values that are passed to parameters of any method.
For example, the JIT compiler detects any event, if a user
tries to assign a 32-bit value to a parameter that can only accept 8-bit value.
33. What is difference between System.String and
System.StringBuilder classes?
String and StringBuilder classes are used to store string
values but the difference in them is that String is immutable (read only) by
nature, because a value once assigned to a String object cannot be changed
after its creation. When the value in the String object is modified, a new
object is created, in memory, with a new value assigned to the String object.
On the other hand, the StringBuilder class is mutable, as it occupies the same
space even if you change the value. The StringBuilder class is more efficient
where you have to perform a large amount of string manipulation.
34. Describe the roles of CLR in .NET Framework.
CLR provides an environment to execute .NET applications on
target machines. CLR is also a common runtime environment for all .NET code
irrespective of their programming language, as the compilers of respective
language in .NET Framework convert every source code into a common language
known as MSIL or IL (Intermediate Language).
CLR also provides various services to execute processes,
such as memory management service and security services. CLR performs various
tasks to manage the execution process of .NET applications.
The responsibilities of CLR are listed as follows:
Automatic memory management
Garbage Collection
Code Access Security
Code verification
JIT compilation of .NET code
35. What is the difference between int and int32.
There is no difference between int and int32. System.Int32
is a .NET Class and int is an alias name for System.Int32.
.Net Assembly Question
1. What is an assembly?
Assemblies are the basic building blocks required for any
application to function in the .NET realm. They are partially compiled code
libraries that form the fundamental unit of deployment, versioning, activation
scoping, reuse, and security. Typically, assemblies provide a collection of
types and resources that work together to form a logical unit of functionality.
They are the smallest deployable units of code in .NET. Compared to the
executable files assemblies are far more reliable, more secure, and easy to
manage. An assembly contains a lot more than the Microsoft Intermediate
Language (MSIL) code that is compiled and run by the Common Language Runtime
(CLR). In other words, you can say that an assembly is a set of one or more
modules and classes compiled in MSIL, and metadata that describes the assembly
itself, as well as the functionalities of the assembly classes.
2. Name the different components of an assembly.
An assembly is a logical unit that is made up of the
following four different types of components:
Assembly manifest
MSIL source code
Type metadata
Resources
3. What are the different types of assemblies? Explain them
in detail.
The following are the two types of assemblies:
Private Assembly - Refers to the assembly that is used by a
single application. Private assemblies are kept in a local folder in which the
client application has been installed.
Public or Shared Assembly - Refers to the assembly that is
allowed to be shared by multiple applications. A shared assembly must reside in
Global Assembly Cache (GAC) with a strong name assigned to it.
For example, imagine that you have created a DLL containing
information about your business logic. This DLL can be used by your client
application. In order to run the client application, the DLL must be included
in the same folder in which the client application has been installed. This
makes the assembly private to your application. Now suppose that the DLL needs
to be reused in different applications. Therefore, instead of copying the DLL
in every client application folder, it can be placed in the global assembly
cache using the GAC tool. These assemblies are called shared assemblies.
4. Can one DLL file contain the compiled code of more than
one .NET language?
No, a DLL file can contain the compiled code of only one
programming language.
5. What is the maximum number of classes that can be
contained in a DLL file?
There is no limit to the maximum number of classes that can
be contained in a DLL file.
6. What is a satellite assembly?
Satellite assemblies are assemblies that are used to deploy
language and culture specific resources for an application. In an application,
a separate product ID is assigned to each language and a satellite assembly is
installed in a language specific sub-directory.
7. Is versioning applicable to private assemblies?
No, versioning is not applicable to private assemblies as
these assemblies reside in their individual folders. Versioning can be applied
to GAC only.
8. What is metadata?
An assembly metadata describes every data type and member
defined in the code. It stores the description of an assembly, such as name,
version, culture, public key of an assembly along with the types exported,
other assemblies dependent on this assembly, and security permissions needed to
run the application. In addition, it stores the description of types, such as
the name, visibility, base class, interfaces implemented, and members, such as
methods, fields, properties, events, and nested types.
It also stores attributes. Metadata is stored in binary
format. Therefore, metadata of an assembly is sharable among applications that
execute on various platforms. It can also be exported to other applications to
give information about the services and various features of an application.
9. What is Assembly Manifest?
Assemblies maintain all their information in a special unit
called the manifest. Every assembly has a manifest.
The followings are the contents of an Assembly Manifest:
Assembly name - Represents a text string that specifies the
assembly's name.
Version number - Represents a major and minor version
number, as well as a revision and build number. The CL.R makes use of these
numbers to enforce version policy.
Culture - Represents information of the culture or language,
which the assembly supports. An assembly is a container of only resources
containing culture- or language-specific information.
Strong name information - Represents the public key from the
publisher, if a strong name is assigned to an assembly.
List of all files in the assembly - Represents a hash of
each file contained in the assembly and a file name.
Type reference information - Represents the information used
at the runtime to map a type reference to the file that contains its
declaration and implementation.
Information on referenced assemblies - Represents a list of
other assemblies that are statically referenced by the assembly. Each reference
includes the names of dependent assemblies, assembly metadata (version,
culture, operating system, and so on), and public key, if the assembly is
strong named.
10. What is the value of the Copy Local property when you
add an assembly in the GAC?
False.
11. What is Native Image Generator?
The Native Image Generator (Ngen.exe) is a tool that creates
a native image from an assembly and stores that image to native image cache on
the computer. Whenever, an assembly is run, this native image is automatically
used to compile the original assembly. In this way, this tool improves the
performance of the managed application by loading and executing an assembly
faster.
Note that native images are files that consist of compiled
processor-specific machine code. The Ngen.exe tool installs these files on to
the local computer.
12. Name the MSIL Disassembler utility that parses any .NET
Framework assembly and shows the information in human readable format
The Ildasm.exe utility.
13. What is the significance of the Strong Name tool?
The Strong Name utility (sn.exe) helps in creating unique
public-private key pair files that are called strong name files and signing
assemblies with them. It also allows key management, signature generation, and
signature verification.
14. How can different versions of private assemblies be used
in the same application without a re-build?
You can use different versions of private assemblies in the
same application without a re-build by specifying the assembly version in the
AssemblyInfo.cs or AssemblyInfo.vb file.
15. What is Global Assembly Cache (GAC) ?
GAC is a central repository (cache) in a system in which
assemblies are registered to share among various applications that execute on
local or remote machines. .NET Framework provides the GAC tool (gacutil.exe
utility), which is used to view and change the content of GAC of a system.
Adding new assemblies to GAC and removing assemblies from GAC are some of the
tasks that can be performed by using the gacutil.exe utility. GAC can contain
multiple versions of the same .NET assembly. CLR checks GAC for a requested
assembly before using information of configuration files.
The gacutil.exe /i <assembly name> - is the command
that is used to install an assembly in GAC. Users use the Command Prompt of
Visual Studio to install an assembly in GAC by using this command.
You can see all the assemblies installed in the GAC using
the GAC viewer, which is located at the
<WinDrive>:<WinDir>\assembly directory, where <WinDir> is
windows in Windows XP or windows in Windows Vista or WinNT in Windows 2000.
Apart from the list of assemblies, the assembly viewer also shows relevant
information, such as the global assembly name, version, culture, and the public
key token.
16. Where is the information regarding the version of the
assembly stored?
Information for the version of assembly is stored inside the
assembly manifest.
17. Discuss the concept of strong names.
Whenever, an assembly is deployed in GAC to make it shared,
a strong name needs to be assigned to it for its unique identification. A
strong name contains an assembly's complete identity - the assembly name,
version number, and culture information of an assembly. A public key and a
digital signature, generated over the assembly, are also contained in a strong
name. A strong name makes an assembly identical in GAC.
18. What is the difference between .EXE and .DLL files?
EXE
It is an executable file, which can be run independently.
EXE is an out-process component, which means that it runs in
a separate process.
It cannot be reused in an application.
It has a main function.
DLL
It is Dynamic Link Library that is used as a part of EXE or
other DLLs. It cannot be run independently.
It runs in the application process memory, so it is called
as in-process component.
It can be reused in an application.
It does not have a main function.
19. Which utility allows you to reference an assembly in an
application?
An assembly can be referenced by using the gacutil.exe
utility with the /r option. The /r option requires a reference type, a
reference ID, and a description.
20. The AssemblyInfo.cs file stores the assembly
configuration information and other information, such as the assembly name,
version, company name, and trademark information. (True/False).
True.
Subscribe to:
Posts (Atom)