Tuesday, 26 June 2007
All type .Net faqs, interview questions & answers
http://www.dotnetinterviewfaqs.com/ is a new .Net website having all Microsoft related faqs, interview questions & answersTo visit click http://www.dotnetinterviewfaqs.com/
Saturday, 2 June 2007
What is the difference between the destructor and the Finalize() method?
When does the Finalize() method get called?
Finalize() corresponds to the .Net Framework and is part of the System.Object class.
Destructors are C#'s implementation of the Finalize() method.
The functionality of both Finalize() and the destructor is the same, i.e., they contain code for freeing the resources when the object is about to be garbage collected. In C#, destructors are converted to the Finalize() method when the program is compiled.
The Finalize() method is called by the .Net Runtime and we can not predict when it will be called. It is guaranteed to be called when there is no reference pointing to the object and the object is about to be garbage collected.
Finalize() corresponds to the .Net Framework and is part of the System.Object class.
Destructors are C#'s implementation of the Finalize() method.
The functionality of both Finalize() and the destructor is the same, i.e., they contain code for freeing the resources when the object is about to be garbage collected. In C#, destructors are converted to the Finalize() method when the program is compiled.
The Finalize() method is called by the .Net Runtime and we can not predict when it will be called. It is guaranteed to be called when there is no reference pointing to the object and the object is about to be garbage collected.
Monday, 7 May 2007
Interface
What is Interface
{
void GoForward(int Speed);
}
public class Truck : IDrivable
{
public void GoForward(int Speed)
{
// Implementation omitted
}
}
public class Aircraft : IDrivable
{
public void GoForward(int Speed)
{
// Implementation omitted
}
}
public class Train : IDrivable
{
public void GoForward(int Speed)
{
// Implementation omitted
}
}
Extra
- An Interface is a group of constants and method declaration.
- .Net supports multiple inheritance through Interface.
- Interface states �what� to do, rather than �how� to do.
- An interface defines only the members that will be made available by an implementing object. The definition of the interface states nothing about the implementation of the members, only the parameters they take and the types of values they will return. Implementation of an interface is left entirely to the implementing class. It is possible, therefore, for different objects to provide dramatically different implementations of the same members.
- Example1, the Car object might implement the IDrivable interface (by convention, interfaces usually begin with I), which specifies the GoForward, GoBackward, and Halt methods. Other classes, such as Truck, Aircraft, Train or Boat might implement this interface and thus are able to interact with the Driver object. The Driver object is unaware of which interface implementation it is interacting with; it is only aware of the interface itself.
- Example2, an interface named IShape, which defines a single method CalculateArea. A Circle class implementing this interface will calculate its area differently than a Square class implementing the same interface. However, an object that needs to interact with an IShape can call the CalculateArea method in either a Circle or a Square and obtain a valid result.
- Practical Example
{
void GoForward(int Speed);
}
public class Truck : IDrivable
{
public void GoForward(int Speed)
{
// Implementation omitted
}
}
public class Aircraft : IDrivable
{
public void GoForward(int Speed)
{
// Implementation omitted
}
}
public class Train : IDrivable
{
public void GoForward(int Speed)
{
// Implementation omitted
}
}
Extra
- Each variable declared in interface must be assigned a constant value.
- Every interface variable is implicitly public, static and final.
- Every interface method is implicitly public and abstract.
- Interfaces are allowed to extends other interfaces, but sub interface cannot define the methods declared in the super interface, as sub interface is still interface and not class.
- If a class that implements an interface does not implements all the methods of the interface, then the class becomes an abstract class and cannot be instantiated.
- Both classes and structures can implement interfaces, including multiple interfaces.
Making choice between Interface and Abstract Class
In which Scenario you will go for Interface or Abstract Class?
Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces
do not provide implementation. They are implemented by classes, and defined as separate entities from
classes. 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.
Abstract classes are useful when creating components because they allow you specify an invariant level
of functionality in some methods, but leave the implementation of other methods until a specific
implementation of that class is needed. They also version well, because if additional functionality is
needed in derived classes, it can be added to the base class without breaking code.
Thursday, 25 January 2007
Multiple - Language Development in .NET Framework
.NET Framework encourages cross-language development using multiple programming languages. To become a .NET language, any language should have a compiler that translates the source code written in different languages into Microsoft Intermediate Language (MSIL). MSIL code is called as Managed Code. Managed code runs in .NET environment.In .Net framework the Common Runtime Language (CLR) contains a
Thursday, 11 January 2007
Explain the delegates in C#.
Delegates
in C# are objects which points towards a function which matches its signature. Delegates are reference type used to encapsulate a method with a specific signature. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure.Here are some features of delegates:A delegate represents a class. A delegate is type-safe. We can use delegates both for static
in C# are objects which points towards a function which matches its signature. Delegates are reference type used to encapsulate a method with a specific signature. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure.Here are some features of delegates:A delegate represents a class. A delegate is type-safe. We can use delegates both for static
What is the purpose of connection pooling in ADO.NET?
Connection pooling enables an application to use a connection from a pool of connections that do not need to be re-established for each use. Once a connection has been created and placed in a connection pool, an application can reuse that connection without performing the complete connection creation process.By default, the connection pool is created when the first connection with a unique
Wednesday, 10 January 2007
What is the difference between classes and structs in Microsoft.Net?
A struct is a value type, while a class is a reference type. When we instantiate a class, memory will be allocated on the heap. When struct gets initiated, it gets memory on the stack. Classes can have explicit parameter less constructors. But structs cannot have this. Classes support inheritance. But there is no inheritance for structs. A struct cannot inherit from another struct or class, and
Tuesday, 9 January 2007
What is a Strong Name in Microsoft.Net?
In Microsoft.Net a strong name consists of the assembly's identity. The strong name guarantees the integrity of the assembly. Strong Name includes the name of the .net assembly, version number, culture identity, and a public key token. It is generated from an assembly file using the corresponding private key.Steps to create strong named assembly:To create a strong named assembly you need to have
What is the use of XSLT?
XSLT stands for Extensible Stylesheet Language Transformations. This language used in XSL style sheets to transform XML documents into other XML documents.XSLT is based on template rules which specify how XML documents should be processed. An XSLT processor reads both an XML document and an XSLT style sheet. Based on the instructions the processor finds in the XSLT style sheet, it produce a new
Monday, 8 January 2007
Explain ACID properties of the database?
All Database systems which include transaction support implement ACID properties to ensure the integrity of the database. ACID stands for Atomicity, Consistency, Isolation and DurabilityAtomicity: Each transaction is said to be �atomic.� If one part of the transaction fails, the entire transaction fails. Modifications on the data in the database either fail or succeed. Consistency: This property
What is the basic functionality of Garbage Collector in Microsft.Net?
The Common Language Runtime (CLR) requires that you create objects in the managed heap, but you do not have to bother with cleaning up the memory once the object goes out of the scope or is no longer needed. The Microsoft .NET Framework Garbage Collector provides memory management capabilities for managed resources. The Garbage Collector frees objects that are not referenced and reclaims their
Sunday, 7 January 2007
What is a static class?
We can declare a static class. We use static class when there is no data or behavior in the class that depends on object identity. A static class can have only static members. We can not create instances of a static class using the new keyword. .NET Framework common language runtime (CLR) loads Static classes automatically when the program or namespace containing the class is loaded.Here are some
What is static member of class?
A static member belongs to the class rather than to the instances of the class. In C# data fields, member functions, properties and events can be declared static. When any instances of the class are created, they cannot be used to access the static member.To access a static class member, use the name of the class instead of an instance variableStatic methods and Static properties can only access
What is the purpose of Server.MapPath method in Asp.Net?
In Asp.Net Server.MapPath method maps the specified relative or virtual path to the corresponding physical path on the server. Server.MapPath takes a path as a parameter and returns the physical location on the hard drive. SyntaxSuppose your Text files are located at D:\project\MyProject\Files\TextFilesIf the root project directory is MyProject and the aspx file is located at root then to get
Thursday, 4 January 2007
What is the difference between abstract class and interface?
We use abstract class and interface where two or more entities do same type of work but in different ways. Means the way of functioning is not clear while defining abstract class or interface. When functionality of each task is not clear then we define interface. If functionality of some task is clear to us but there exist some functions whose functionality differs object by object then we
What is the use of Master Pages in Asp.Net?
A master page in ASP.Net provides shared HTML, controls, and code that can be used as a template for all of the pages of a website.Every master page has asp:contentplaceholder control that will be filled by the content of the pages that use this master page. You can create a master page that has header and footer i.e. a logo, an image, left navigation bar etc and share this content on multiple
Wednesday, 3 January 2007
What is the difference between .Net Remoting and Asp.Net Web Services?
ASP.NET Web Services Can be accessed only over HTTP but .Net Remoting Can be accessed over various protocols like TCP, HTTP, SMTP etc. Web Services are based on stateless service architecture but .Net Remoting support for both stateful and stateless environment. Web Services support heterogeneous environments means interoperability across platforms but .Net remoting requires .Net on both server
What would be the common layers in an n- tier architecture based web application?
Common layers in an n- tier architecturePresentation GUI: Look & Feel ,Html, aspx file, JavaScript, window forms etc. Controller- Work flow layer: aspx.cs file, means event handlers and Data binding with controls etc. Business Logic: where we implement business rules like add book, search library etc. Data Access: SQLHelper.cs like create connection, get DataSet, Execute Query etc. Physical Data:
Subscribe to:
Comments (Atom)