Question 61 – What is Runtime Host?
Ranging
from Windows applications, Web applications to Mobile applications, CLR is
designed to support various types of applications. .NET Framework provides
different types of runtime hosts to manage the execution of application code(to
load runtime in to process, create application domain within process, load user
code in to application domain) and provides various services to the
application. Runtime hosts included in .Net framework are : ASP.NET, Microsoft
Internet Explorer and windows shell.
Question 62 – What is Connection Pooling?
- A Connection Pool is a
container of open and reusable connections. A Connection Pool is released
from the memory when the last connection to the database is closed.
- The Data Providers in ADO.NET
have Connection Pooling turned on by default; if you need to turn it off,
specify Pooling = false in the connection string being used.
- Connection Pooling gives you an
idle, open, reusable connection instead of opening a new one every time a
connection request to the database is made. When the connection is closed
or disposed, it is returned to the pool and remains idle until a request
for a new connection comes in.
- The pool can house connections
up to the maximum limit as specified in the connection string that was
used to connect to the database.
- Advantage of using Connection
Pooling is an improvement of performance and scalability
- Disadvantage is that one or
more database connections, even if they are currently not used, are kept
open.
Question 63 – What are the main parameters used by Connection Pooling?
Connection
Pooling is controlled and the parameters passed to a connection string
comprises the following:
- Connect Timeout
- Min Pool Size
- Max Pool Size
- Pooling
Question 64 – What is Connection Pool Manager?
A
Connection Pool is maintained internally by the Connection Pool Manager. When a
request for a subsequent connection comes in, the Connection Pool Manager
searches the pool for the availability of a free connection and returns it to
the application if one is available. Connection Pools works as below
- If any unused connection is
available, it returns one.
- If all connections are used up,
a new connection is created and added to the pool.
- If the number of connections
reaches the maximum number of connections in the pool, the requests are
queued until a connection becomes free for reuse.
Question 65 – What is Object Pooling?
It
is something that tries to keep a pool of objects in memory to be re-used later
and hence it will reduce the load of object creation to a great extent.
Whenever there is a request for a new object, the pool manager will take the
request and it will be served by allocating an object from the pool. Pooling
basically means utilizing the resources efficiently, by limiting access of the
objects to only the period the client requires it.
Question 66 – What are the Advantages of Object Pooling?
It
minimizes the consumption of memory and the system’s resources by recycling and
re-using objects as and when it is needed and serving the request for new
objects from the pool of ready-to-be-used objects. The objects that the
application is done with (the objects are no longer needed) are sent back to
the pool rather than destroying them from the memory.
According
to MSDN, “Once an application is up and running, memory utilization is affected
by the number and size of objects the system requires. Object pooling reduces
the number of allocations, and therefore the number of garbage collections,
required by an application.
Question 67 – What is the Difference between Connection Pooling and Object
Pooling?
Object
Pooling is great in the sense that it can optimize access to expensive
resources (like file handles or network connections) by pooling them in memory
and reusing them as and when they are needed.
According
to MSDN, “Object pooling lets you control the number of connections you use, as
opposed to connection pooling, where you control the maximum number reached.”
Question 68 – What is an Indexer?
- Indexers permit instances of a
class or struct to be indexed in the same way as arrays.
- Indexers are similar to
properties except that their accessors take parameters.
- The indexers are usually known
as smart arrays in C#.
- An indexer, also called an
indexed property, is a class property that allows you to access a member
variable of a class using the features of an array.
- Defining an indexer allows you
to create classes that act like virtual arrays. Instances of that class
can be accessed using the [] array access operator.
Question 69 – What are the important points to remember on indexers?
- Indexers are always created
with this keyword.
- Parameterized property are
called indexer.
- Indexers are implemented
through get and set accessors for the [ ] operator.
- ref and out parameter modifiers
are not permitted in indexer.
- Indexer is an instance member
so can’t be static but property can be static.
- Indexers are used on group of
elements.
- Indexer can be overloaded.
Question 70 – What is the Difference between Indexers and Properties?
|
Question 71 – What are the different Access Modifiers available?
- Public – Access to same
assembly or another assembly that references it.
- Private – Access to same class
or struct.
- Protected – Access to same
class or struct, or in a class that is derived.
- Internal – Access to any code
in the same assembly, but not from another assembly.
- Protected Internal – Access to
any code in the assembly in which it is declared, or from within a derived
class in another assembly.
No comments:
Post a Comment