Dot.Net Interview Quations in TCS Part-2

42)How to register strong name with my class library?
Ans:that just means tha the referenced assembly ApplicationDataAccess is not
signed so it doesn't have a strong name.
Since you signed your application/assembly all referenced assemblies must
also be signed.
..................................................................................................................................
43)Can i register my assembly in gac with out strong name?
Ans:
Refer:"http://www.dotnetspider.com/forum/262111-Interviiew-questions-related-assembly-plz-any-one-answer.aspx"
.........................................................................................................................................
44)What is dataset?
Ans:
A Dataset is a in memory representation of a collection of
Database objects including tables of a relational database
scheme. The dataset contains a collection of Tables,
Relations, constraints etc.,

It can be used for manipulating the data remotely and
finally updating the database with the modified data. This
way it enables disconnected means of working with data. This
improves performance
in terms of reducing the number of times a database is
accessed for data manipulations.

The dataset contains all the objects as a Collection of
objects. For example it contains the Database Tables as
DataTable objects. The data from the database is filled into
the dataset by using the DataAdapter.
...................................................................
45)Diff between dataset and datareder?
Ans: Data Reader

A DataReader is a 
read-only stream of data returned from the database as the query 
executes. It only contains one row of data in memory at a time and is 
restricted to navigating forward only in the results one record at a 
time. The DataReader does support access to multiple result sets, but 
only one at a time and in the order retrieved. Just as in the original 
version of ADO, the data is no longer available through the DataReader 
once the connection to the data source is closed, which means a 
DataReader requires a connection to the database throughout its usage. 
Output parameters or return values are only available through the 
DataReader once the connection is closed.

DataReaders all 
implement the same IDataReader interface, which means that all of the 
DataReaders should provide the same set of functionality. Each 
DataReader implementation is optimized for a specific data provider such
 as SQL Server or Oracle. Version 1.0 of the Microsoft .NET Framework 
includes a System.Data.SqlClient.SqlDataReader that is specific to SQL 
Server and a System.Data.OleDb.OleDbDataReader that is more generic for 
OLEDB providers. Version 1.1 of the .NET Framework introduced the 
SqlCeDataReader for connecting to the SQL Server edition for Windows CE,
 OdbcDataReader for ODBC data sources, and OracleDataReader for 
connecting to Oracle databases. It isn''t required that you use the 
DataReaders from Microsoft, and each database vendor often has its own 
.NET provider. In addition, you can implement a DataReader of your own 
through the IDataReader interface.

What is a DataSet?
DataSet 
is the core of the ADO.NET disconnected architecture and is used to 
store data in a disconnected state. It was designed to fully support the
 use of XML so an XML document can be read into a DataSet or a DataSet 
can be exported to XML. This allows a DataSet to be easily transported 
across a network so it can be used as a return from a Web service or 
other type of remote call. Changes to a DataSet can be propagated back 
to the data source from where the data originated. A DataSet is fully 
navigable forward or backward and the contents can be filtered, sorted, 
or searched as desired, making all records accessible at any given 
point.

The DataSet, part of the System.Data namespace, is not 
specific to any one data provider, but rather is independent of them. A 
DataSet relies on a DataAdapter specific to each provider to be the 
intermediary between the DataSet and the data store. The DataAdapter 
uses a DataReader for the specific provider to fill the contents of the 
DataSet.

You can use the following information to help you decide which data retrieval is right for your purposes.

When to consider using a DataReader:
•The
 DataReader is a better choice for applications that require optimized 
read-only and forward-only access to data such as binding to a DataGrid 
control. The sooner the data is off-loaded from the DataReader and the 
connection is closed the better the application performance. 
•The 
DataReader is a better choice when you are planning to make repeated 
calls to retrieve small amounts of information or the data you are 
retrieving must be as up to date as possible each time it is used.

When to consider using a DataSet:
•The
 DataSet is a better choice for applications that will not off-load the 
query result immediately, or when there is extensive processing such as 
complex business logic involved between data accesses. The DataSet will 
retrieve the data, off-load the data into memory and return the database
 connection to the connection pool, where as a DataReader would keep the
 connection locked open until processing is complete. This could easily 
cause a high traffic application to run out of available database 
connections. 
•The DataSet is a better choice when you need to 
navigate through the data more than once. For example, if you have 
multiple controls you need to build off the same data, then a DataSet is
 the better answer because a DataReader can only be read once so it can 
only be bound to a single control and would require the data to be 
retrieved for use with each control. 
•The DataSet is a better choice
 when the data does not change frequently enough to warrant always 
retrieving it from the database or is specific to the user requesting 
the data. A DataSet can be stored in Session or Application variables or
 cached through the System.Web.Caching.Cache class to improve 
application performance by not having to retrieve the data from the 
database each time it is needed. 
•The DataSet is a better choice 
when building a Web service that will return the retrieved data. Since a
 DataSet is serializable it can serve as the return value. Since a 
DataReader requires a persistent database connection, it cannot be used 
as a return type from a Web service.
................................................................................................................................
46)How can we made changes in database?
Ans: 
da.update()
..............................................................................................................................
47)One user changed one record in dataset and updated in
database but at same time another user also changed the same
record in his dataset and try nto update in database so is
the change is accepted in database or rejected? 
Ans: 
he
said no
...................................................................
48)Where dataset will store?
Ans:
Does dataset store all its datatables' records into server memory if I just call one datatable from it
Lets make an example, a dataset with three datatables - tbCompany, tbCompanyStaffs, tbSalesOrder
where tbCompany is the parent of tbCompanyStaffs. tbSalesOrder is an independant table.
Does dataset load all tbCompanyStaffs records into the server memory as well when a class retrive data from tbCompany?
.......................................................................................................................................................
49)What is heap memory?
Ans: On the other hand, heap is an area of memory used for dynamic memory allocation. Blocks of memory are allocated and freed in this case in an arbitrary order. The pattern of allocation and size of blocks is not known until run time. Heap is usually being used by a program for many different purposes.
................................................................................................................................................................
50)What is stack memory?
Ans:
The two sections other from the code segment in the memory are used for data. The stack is the section of memory that is allocated for automatic variables within functions.

Data is stored in stack using the Last In First Out (LIFO) method. This means that storage in the memory is allocated and deallocated at only one end of the memory called the top of the stack. Stack is a section of memory and its associated registers that is used for temporary storage of information in which the most recently stored item is the first to be retrieved.


Visit:"http://www.c-sharpcorner.com/uploadfile/rmcochran/csharp_memory01122006130034pm/csharp_memory.aspx?articleid=9adb0e3c-b3f6-40b5-98b5-413b6d348b91"
...............................................................................................................................................
51)When heap memory will create?
Ans:heap is the section of computer memory where all the variables
created or initialized at runtime are stored.

..........................................................................................................................................
52)When stack memory will create?
 Ans:stack is a place in the computer memory where all the variables that are declared and initialized before runtime are stored.
 ...........................................................................................................................................
53) If heap memory is full what happens? (how much memory it
extends? Or it uses the stack memory)
 Ans:Destroy Unwanted memory
........................................................................................................ 
54)If stack memory also full what happen?
Ans:
.......................................................................................................................
55)What is constructor?
 
Ans: A constructor is a special method for initializing a new instance of a class.The constructor method for a class will have the same name as the class.
 ...............................................................................
 56)Why we use constructor?
Ans:Initialization
 of values of different variables is critical in any application 
development. C# does initialize simple data-types to default values as 
per the language specification in the .Net framework, but for classes 
that are user specific, it is obvious that you would be the only one who
 can decide what is an ideal default value. The means of achieving this 
is Constructors. There is also a perception that constructors can only 
be used beyond initialization, which is true to some extent. We will 
examine them in the following sections.
.................................................................
57)What is destructor?
Ans: Destructors are used to release any resources allocated by the object.  E.g.,
class Lock might lock a semaphore, and the destructor will release
that semaphore.  The most common example is when the constructor uses new,
and the destructor uses delete.
refer:"http://sawaal.ibibo.com/computers-and-technology/what-destructor-469845.html"
...................................................................................
58)Why we use destructor?
Ans:Destructor main advantage is Clean unwanted resources
..................................................................................
60)Garbage collector?
Ans:In computer science, garbage collection (GC) is a form of automatic memory management. It is a special case of resource management
in which the limited resource being managed is memory. The garbage collector, or just collector, attempts to reclaim garbage
or memory occupied by objects that are no longer in use by the program.
..............................................................................
61)What is dispose?
Ans:
The Dispose method in .NET belongs to IDisposable interface 
and it is best used to release unmanaged objects like File 
objects, Windows API objects, Database connection objects, 
COM objects etc from the memory. Its performance is better 
than the finalize() method. 
............................................................
62) What is difference between dispose and close?
 
 Ans:
There is one major difference between
 calling the Close and Dispose methods on database connections. Close 
leaves the connection in a closed state; but, it is reusable—all 
properties, etc. can be accessed and Open can be called. On the other 
hand, after calling Dispose on a database connection—as with any 
object—, the connection object can no longer be accessed. 

However, calling Dispose does not remove the connection from the connection pool. 

[edit]Visual C# Best Practice
Only
 call the Close method on a Stream or a database connection if the 
object will be reused. Otherwise, use the Dispose method. 

The 
Dispose method may be called on any instance of any type implementing 
the IDisposable interface. This is supported by the C# using statement 
which makes calling Dispose automatically easy. 

Retrieved from "http://en.csharp-online.net/CSharp_FAQ:_What_is_the_difference_between_Close_and_Dispose" 
 
 ..........................................................................................
63)What is finalize?
Ans: 
 Method called automatically when an object is destroyed by the garbage collector. Finalize
 is useful for releasing unmanaged resources acquired by the object 
before the object is garbage collected. Managed resources do not require
 a  Finalize method; because, they will be released automatically by the garbage collector. Destructors defined in C# classes are mapped to Finalize methods. Also known as a finalizer
 .....................................................................................
64)How to remove the object reference?
Ans: passing null
value
..........................................................
65)What is final key word? 
Ans: 
 
..........................................................
66)What is autopostback?
Ans:The data is executed on server side
........................................................
67)What is dataview? Usage?
 Ans:
You have a DataTable in your program and want to use a DataView 
to selectively filter and sort the rows. The DataView class in 
System.Data is ideal for sorting data for UIs or for database INSERT. 
Here we look at ways you can utilize the data in your DataTable by 
sorting it with DataView. 
REfer:"http://dotnetperls.com/dataview"
......................................................................
68)What is caching?
Ans: this technique can be used to temporarily store page output or 
application data either on the client or on the server, which can then 
be re-used to satisfy subsequent requests and thus avoid the overhead of
 re-creating the same information. 
Caching is particularly suitable when you expect to return the same information in the same format for many different requests.
........................................................................................................
69)How to expire my cache?
Ans:
using duration in page
directive
.............................................................
70)If i store cache in server the server will over load
because of cache objects so how can i prevent that? 
Ans: 
using downstream caching eg: net provider serve and local
system cache
...................................................................
71)What is data cache?
Ans:
.......................................................................
72)How can i get the value from cache?
Ans:
...........................................................
73)If i want insert record in database tell me the steps?
Ans:
Open Sql database Write insert querry
..........................................................]
74)Diff between authentication and authorization?
Ans:
Authentication:
 The process of determining the identity of a user. In effect, 
authentication validates that the user is who he or she claims to be.

Authorization:
 The process of granting access privileges to resources or tasks within 
an application. Applications typically authenticate users and then 
authorize them based on their identities or roles within an 
organization.............................................................................
75)How to authenticate user in asp.net?
Ans:
ASP.NET supports three types of authentication methods. These are 
1.Windows-based authentication
2.Forms-based authentication
3.Microsoft Passport authentication
...........................................................................................................................
76)Types of authorizations?
Ans:
There are two forms of authorization available in ASP.NET:
  • FileAuthorization - relies on NTFS file permissions for granting access.
  • UrlAuthorization - in the Web.config file you can specify the authorization rules for various directories or files using the <authorization> element.
 .....................................................................
77)Explain the three types of authorizations?
Ans:
.......................................................................
78)How iis uses the windows authentication?
Ans:
With Windows-based authentication, the ASP.NET Web application relies on the Windows operating system to authenticate the user. ASP.NET uses Windows-based authentication in conjunction with IIS authentication.
With Windows-based authentication, the user requests a secure Web page from the Web application, and the request then goes through IIS. If the user’s credentials do not match those of an authorized user, IIS rejects the request. The user then has to enter his or her name and password into the logon form. The credentials are again verified by IIS. If correct, IIS directs the original request to the Web application. The secure Web page is then returned to the user
........ ...................................................................................
79)What is forms authentication?
Ans:
Forms-based authentication refers to a 
system where non-authenticated requests are redirected to a Hypertext 
Markup Language (HTML) form by using Hypertext Transfer Protocol (HTTP) 
client-side redirection. The user provides credentials and submits the 
form. If the application validates the credentials on the form, the 
system issues an authentication cookie to the user. Subsequent requests 
from the user are issued with the authentication cookie in the request 
headers, and then the user is authenticated based on those request 
headers. 
................................................................
80)What is impersonation?
Ans:
At times users access a resource as though they were 
someone else. This is known as impersonation. For example, 
if a web page has no access controls, then any user can 
access that web page. HTML pages, ASP pages, and components 
in version 3.0 and earlier can be accessed through two 
accounts named IUSR_machinename and IWAM_machinename. Both 
the accounts are set up during IIS installation, and are 
automatically added to all the folders in every web site on 
the server.

Anonymous access to a resource in IIS makes the task of 
identifying a user extremely difficult. But there is no 
need to authenticate a user in the case of IIS. When IIS 
receives a request for a web page or other resource that 
has permission for anonymous access, IIS treats the 
IUSR_machinename account as the user's account, to access 
the resources. If the resource requested by the user is an 
ASP page that uses a COM or COM+ component, that component 
is executed using the IWAM_machinename account. 
............................................................
81)What is default impersonation in asp.net?
Ans: 
When using impersonation, ASP.NET applications can optionally execute with the identity of the client on whose behalf they are operating. The usual reason for doing this is to avoid dealing with authentication and authorization issues in the ASP.NET application code. Instead, you rely on IIS to authenticate the user and either pass an authenticated token to the ASP.NET application or, if unable to authenticate the user, pass an unauthenticated token. In either case, the ASP.NET application impersonates whichever token is received if Impersonation is enabled. The ASP.NET application, now impersonating the client, then relies on the settings in the NTFS directories and files to allow it to gain access, or not. Be sure to format the server file space as NTFS, so that access permissions can be set.
For ASP compatibility, impersonation is disabled by default. If impersonation is enabled for a given application, ASP.NET always impersonates the access token that IIS provides to ISAPI extensions. That token can be either an authenticated user token, or the token for the anonymous user ( such as IUSR_MACHINENAME ). The impersonation occurs regardless of the type of authentication being used in the application and whether the user is authenticated, in which case, it is the anonymous user token.
Only application code is impersonated; compilation and configuration are read as the process token. If an application is on a UNC share, ASP.NET will always impersonate the token provided to IIS to access that share unless a configured account is used. If an explicit configured account is provided, ASP.NET will use that account in preference to the IIS UNC token. Applications that do want per-request impersonation can simply be configured to impersonate the user making the request.
Impersonation is disabled at the computer level by default and, unless overridden, all the application domains inherit this setting. You can enable impersonation by putting a configuration file in the application root directory. For more information about the ASP.NET configuration system, see ASP.NET Configuration.
As is the case with other configuration directives, this directive applies hierarchically. It is respected by nested applications in the hierarchy, unless explicitly overridden. The default value for this setting is as follows:
<impersonation enable = "false" /> A minimal configuration file to enable impersonation for an application might look similar to the following example:
<identity impersonate = "true" name = "username" password = "password" /> There is also name support for running an application as a configurable identity. For example:
<identity impersonate = "true" name = "Redmond\Dev" password = "bar" /> This enables the entire application to run as Redmond\Dev, regardless of the identity of the request, so long as the password is correct. This type of impersonation can be delegated to another computer.
....................................................................................................................................................
82)What is interface?

Ans:
An interface looks like a class, but has no implementation. It contains 
definitions of events, indexers, methods and properties. An interface 
inherited by classes An interface inheritance defined with keyword 
"interface". In C# Interface Inheritance also known as multiple 
inheritances.
.................................................................................
83)Usage of interface?
Ans:

Safe Changes to Code

Interfaces eliminate a significant problem of class inheritance: the likelihood of breaking code when you make post-implementation changes to your design. Even though class inheritance allows your classes to inherit implementation from a base class, it also forces you to make most of your design decisions when the class is first published. If your original assumptions turn out to be incorrect, you cannot always change your code safely in later versions.
For instance, suppose you define a method of a base class that expects an Integer argument, and then later determine that the argument should be of the Long data type. You cannot safely change the original class, because applications designed for classes derived from the original may not compile correctly. This problem can be magnified because a single base class can affect hundreds of subclasses.
One solution is to define a new method that overloads the original and that takes an argument of type Long. However, this might not be satisfactory because a derived class may need to override the method that takes the integer, and may not function properly if the method that takes a Long is not overridden also. Interfaces solve this problem by allowing you to publish an updated interface that accepts the new data type.

Flexibility in Implementation

There are several other reasons why you might want to use interfaces instead of class inheritance:
  • Interfaces are better suited to situations in which your applications require many possibly unrelated object types to provide certain functionality.
  • Interfaces are more flexible than base classes because you can define a single implementation that can implement multiple interfaces.
  • Interfaces are better in situations in which you do not need to inherit implementation from a base class.
  • Interfaces are useful in cases where you cannot use class inheritance. For example, structures cannot inherit from classes, but they can implement interfaces.
 
................................................................................. 
84)What is abstract?
Ans: Abstract class is a class that can not be instantiated, it exists 
extensively for inheritance and it must be inherited. There are 
scenarios in which it is useful to define classes that is not intended 
to instantiate; because such classes normally are used as base-classes 
in inheritance hierarchies, we call such classes abstract classes.



Abstract classes cannot be used to instantiate objects; because 
abstract classes are incomplete, it may contain only definition of the 
properties or methods and derived classes that inherit this implements 
it's properties or methods.



Static, Value Types & interface doesn't support abstract 
modifiers. Static members cannot be abstract. Classes with abstract 
member must also be abstract
.........................................................................
85)Interface methods are public and protected? Is it right?
Ans: If I use an interface internally for my application, to aid future

enhancement and maintainability.

All the methods will still be public.



I have a validation method which ordinarilly would be private.

It simply does nothing if validation succeeds or throws exceptions

otherwise.

Not a typical public method.



From a javadocs point of view this method will be right out there with the

rest of the public interface



I notice Sun has statements like this for some undesirably exposed methods:



"This method is public as an implementation side effect. do not call or

override."
...............................................................................
86)What is protected?
Ans: 
The Protected keyword confers protected access on one or more declared programming elements. Protected elements are accessible only from within their own class or from a derived class. Protected access is not a superset of friend access.
The Protected keyword can be used in conjunction with the Friend keyword in the same declaration. This combination confers both friend and protected access on the declared elements, so they are accessible from the same assembly, from their own class, and from any derived classes.
...........................................................................................................
87)What is polymorphism?
Ans:
  • Polymorphism is one of the primary characteristics (concept) of object-oriented programming.
  • Poly means many and morph means form. Thus, polymorphism refers to being able to use many forms of a type without regard to the details.
  • Polymorphism is the characteristic of being able to assign a different meaning specifically, to allow an entity such as a variable, a function, or an object to have more than one form.
  • Polymorphism is the ability to process objects differently depending on their data types.
  • Polymorphism is the ability to redefine methods for derived classes.
  • visit("http://www.dotnetfunda.com/articles/article505-what-is-polymorphism-.aspx")
.....................................................................................................................
88)Diff between overloading and overriding?
Ans:Overloading:
====================
Overloading means having more than one method with the same name, but a different list of arguments in the same class or in a combination of base and derived classes.

Overriding:
====================
Overriding means have a method with the same name and the same signature in the same class and derived classes.

.............................................................................................
89)How to restrict my class to inherited?
Ans:Using Static key word Avoidind Inhertence 
...........................................................................
90)How to restrict my class to create object?
Ans:Declare Class is a private avoid Object Creation
.......................................................................................................
91)What is delegate?
Ans:i) Delegate is a function pointer.
ii) It allows the programmer to encapsulate a reference to a method inside a delegate object.
iii)Delegates are type-safe and secure.
iv) Delegates are created at run time.

............................................................................................
92)What is thread?
Ans:
A thread can be loosely defined as a separate stream of execution that takes place simultaneously with and independently of everything else that might be happening. A thread is like a classic program that starts at point A and executes until it reaches point B. It does not have an event loop. A thread runs independently of anything else happening in the computer. Without threads an entire program can be held up by one CPU intensive task or one infinite loop, intentional or otherwise. With threads the other tasks that don't get stuck in the loop can continue processing without waiting for the stuck task to finish.
It turns out that implementing threading is harder than implementing multitasking in an operating system. The reason it's relatively easy to implement multitasking is that individual programs are isolated from each other. Individual threads, however, are not. To return to the printing example, suppose that while the printing is happening in one thread, the user deletes a large chunk of text in another thread. What's printed? The document as it was before the deletion? The document as it was after the deletion? The document with some but not all of the deleted text? Or does the whole system go down in flames? Most often in a non-threaded or poorly threaded system, it's the latter.
Threaded environments like Java allow a thread to put locks on shared resources so that while one thread is using data no other thread can touch that data. This is done with synchronization. Synchronization should be used sparingly since the purpose of threading is defeated if the entire system gets stopped waiting for a lock to be released. The proper choice of objects and methods to synchronize is one of the more difficult things to learn about threaded programming.
......................................................................................................................
93) What are the Ado.net objects?
Ans:
This chapter defines basic data objects as runtime data-access types that have ADODB counterparts. ADO.NET 2.0 provides the following basic data objects for data retrieval, updates, or both:
  • Connection objects define the data provider, database manager instance, database, security credentials, and other connection-related properties. The VB 2005 code to create a .NET Connection is quite similar to the VB6 code to create an ADODB.Connection object. You also can create a new, persistent (design-time) Connection object by right-clicking Server Explorer's Data Connections node and choosing Add Connection to open the Connection Properties dialog. Alternatively, choose Tools➪Connect to Database to open the dialog.
  • Command objects execute SQL batch statements or stored procedures over an open Connection. Command objects can return one or more resultsets, subsets of a resultset, a single row, a single scalar value, an XmlDataReader object, or the RowsAffected value for table updates. Unlike opening ADODB.Recordset objects from an ADODB.Connection, the ADO.NET Command object isn't optional. Command objects support an optional collection of Parameter objects to execute parameterized queries or stored procedures. The relationship of ADODB and ADO.NET parameters to commands is identical.
  • DataReader objects retrieve one or more forward-only, read-only resultsets by executing SQL batch statements or stored procedures. VB .NET code for creating and executing a DataReader from a Command object on a Connection object is similar to that for creating the default, cursorless ADODB Recordset object from an ADODB.Command object. Unlike the default forward-only ADODB.Recordset, you can't save a DataReader's resultset to a local file and reopen it with a client-side cursor by Save and Open methods.
  • XmlReader objects consume streams that contain well-formed XML documents, such as those produced by SQL Server FOR XML AUTO queries or stored procedures, or native xml columns of SQL Server 2005. XmlReaders are the equivalent of a read-only, forward-only cursor over the XML document. An XmlReader object corresponds to the ADODB.Stream object returned by the SQLXML 3.0 and later SQLXMLOLEDB provider.
Refer :http://searchsqlserver.techtarget.com/feature/Basic-ADONET-data-objects
Refer:http://www.exforsys.com/tutorials/vb.net-2005/access-and-manipulate-data-the-ado-.net-object-model.html


Any new Quationa Avilable Please Post Quations


0 comments:

Post a Comment