Get benefited from interview Q/A and Online Test section. Subscribe to this blog to get updates directly in your mail box.
Best View in Google Crome, Mozilla firefox or IE 7 or above
Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts

Sunday, April 6, 2014

Difference between constructor and method in c#

This is a very basic question mainly asked in Beginner level interviews (1 to 2 years of experience).
The interviewer can twist the question as below as well.


  • Difference between method and constructor in c#
  • Difference between constructor and method in dotnet with example
  • Difference between methods and constructors in object oriented programming


Answer:

Here are few differences between Constructor and methods in bullet points.


Constructor:
1. Name of constructor should be same as class name
2. Constructor is used to initialize class members (variables). It is used to create an instance of  a class.
3. Returns nothing. Hence no return type.
4. Called implicitly at the time of object creation


Method:
1. Name is independent from class name
2. Method is having some functionality. It is used to perform some operations.
3. Must return something. If nothing to return, explicitly return type should be void.
4. Need to be called explicitly


Sunday, July 24, 2011

Dotnet Interview Questions for 1 year experience

Here are few basic dotnet interview questions asked in interview for a 1 year experience candidate.

About your project:

Get maximum knowledge about your current project. You should know the architecture diagram of your project. Also, you have to explain the Dataflow. You might be asked to tell what all dotnet new features used in your project.

Then follows technical discussion.

Dotnet Framework Interview Questions for 1 Year Experience:

1. What is CLR and it's functions?
2. How memory is managed in Dotnet applications?
Hint: Automatically by Garbage collector
3. What is an assembly?
4. What is a strong name?
5. What is MSIL?

C# Interview Questions for 1 Year Experience:

1. What are the 4 pillars of Object Oriented Programming?
2. What is a Class? What is an Object?
3. What is a partial class?
4. What is a sealed class?
5. What is constructor?
6. What is stringbuilder?

ADO.Net Interview Questions for 1 Year Experience:

1. What is connection string?
2. What is Datareader?
3. Difference between Dataset and datareader?
4. What is Ado.Net?
5. Namespace for using sqlserver database?

ASP.Net Interview Questions for 1 Year Experience:

1. What is web.config file and it's use?
2. What is global.asax?
3. What is session?
4. Which all controls you have used in your project?
5. What is gridview?
6. What is Authentication in ASP.Net and types of authentication?

SQL Server Interview Questions for 1 Year Experience:

1. What is Primary key, unique key and difference between them?
2. What is index? Types of index?
3. What is a stored procedure? Why it is better than inline query?
Hint: Stored Procedure is precompiles and has a execution plan. Hence faster execution.
4. You might be asked to write simple query
5. What is inner join

Also, if you know any advance concepts like WCF, WPF, LINQ, MVC, JQuerymention while telling "about yourself". You will be given preference. But, make sure you know the basics or worked on them for sometime.

Post questions you faced in interview in comments. Also post answers in comments to questions mentioned above.

Wednesday, March 30, 2011

Interview Question on Inheritance and Default Constructor

Here is a question on OOPS concepts like Inheritance and Default Constructor. The code provided is in C#.

There are three classes named A, B and C.
Class A has a default constructor that writes "In A" to console. Similarly Class B and C has default constructors that write "In B", and "In C" to Console respectively.
Class C inherits from Class B and Class B inherits from class A.

[Code]
class A
{
public A()
{
Console.WriteLine("In A");
}
}

class B:A
{
public B()
{
Console.WriteLine("In B");
}
}

class C:B
{
public C()
{
Console.WriteLine("In C");
}
}

[/Code]

Now, the question is as below.
If we instanciate class C, what will be the output.

[Code]
static void Main(string[] args)
{
C objC = new C();
Console.Read();
}

[/Code]

Result:
The result will be:
In A
In B
In C

  © Blogger templates Shiny by Ourblogtemplates.com 2008

Back to TOP