Interview questions

.NET constructors & destructors

.NET constructors and destructors - Interview questions

<<Previous  Next>>

.NET constructors and destructors - October 30, 2008 at 18:10 pm by Amit Satpute

Explain constructor and destructor with an example using C#.NET.

A constructor is a member function that performs the task of initializing the objects with the default values to be assigned after creation.

A destructor is a function that is run to release the resources held by an object when it is no longer needed by the application.

In C#.NET we can create constructor and destructor in the following manner:


class C
       private int x;     
       private int y;
       public C (int i, int j)
                 x = i;
                 y = j;
       public void display ()      
               Console.WriteLine(x + "i+" + y);


class D
        public D()
            // constructor
           // Destructor

<<Previous  Next>>

Also read

Object Serialization in .NET

Explain about Serialization in .NET. Explain binary serialization and XML serialization.
What is Formatters? Explain the binary formatter and the SOAP formatter.
Explain why Serialization.
Explain the components that comprise the binary serialization architecture......

What is a CLR (Common Language Runtime)?

Common Language Runtime is a run time environment for .NET..........

Explain the concepts of CTS and CLS(Common Language Specification).

CTS define how these different variables are declared and used in run time...........

Explain Boxing and Unboxing in .NET.

Boxing permits any value type to be implicitly converted to type object or to any interface type Implemented by value type.............

What is Operator Overloading in .NET?

Operator overloading is the most evident example of Polymorphism. In operator overloading, an operator is ‘overloaded’.............

What is Finalize method in .NET?

Object.Finalize method in .NET is typically used to clean and release unmanaged resources like OS files, window etc..............

Write your comment - Share Knowledge and Experience

Latest placement tests
Latest links
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring