Friday, September 2, 2011

C# Interview Questions And Answers


Difference Between Http And Https ?

Ans:-- What i know is http is hyper text transfer protocol which is responsible for transmitting and receiving information across the Internet where as https is secure http, which is used exchanging confidential information with a server, which needs to be secured in order to prevent unauthorized access.


What is DLL Hell in C sharp?

Ans:-DLL HELL is the problem that occures when an installation 
of a newer application might break or hinder other 
application as newer DLLs are copied into the system and 
the older application do not support or not compatible with 
them. .net overcomes this problem by supporting multiple 
versions of an assembly at any given time.this is called 
side-by-side component versioning.


1)When a child class is instantiated base class or child class constructor will be called first?

Ans:Base class constructor will be called first When a child class is instantiated.

2)Can a child class constructor call the base class constructor?

Ans:Yes, a child class constructor call the  base class constructor using the base keyword.

3)Can we overload a constructor in C#?

Ans:yes we can overload a constructor in C# same as having more than one constructor in a class.

4)Can static classes have constructors in C#?

Ans:yes static classes have constructors in C#.

5)can we have static constructors in C#?

Ans:Yes we can have static constructors in C# 

It is called automatically before any static members are accessed or first object of the class is created.

6)What is the use of private constructor in c#?

Ans:Private constructor prevents the creation of object of the class outside the class.

One of its use is to create singleton design pattern

where object is created inside the class and then

that object is accessed using class name.

public  class MyTestClass

{
    public static MyTest MyObj = new MyTestClass();  

    private MyTestClass()

    {

     //initialize variables

    }

}

static void Main()

{

 MyTestClass MyTestObj = MyTestClass.MyObj;

}

7)Can we have a constructor as private in C#?

Ans:Yes we can have a private constructor in C#.

8)Can we have more than one constructor in a c# class?

Ans:Yes we can have more than one constructor in a c# class.

9)can we overload and override static methods in C#?

Ans:we can overload the static methos but cannot override.

10)can Static methods and properties access non-static fields and events in C#?

Ans:No Static methods and properties cannot access non-static fields and events in their containing
       Type.

11)

No comments:

Post a Comment