Monday, February 16, 2009

C# InterviewQuestions- Part 2

Interview Questions
---------------------------

11. Can we use access modifier on static constructor?
a ) No

12. How many static constructors we can declare for a single class?
a ) A class can have only one static constructor.

13. What is method overloading?
a ) It is a process of creating methods that have the same name but with different parameter lists and different definitions. This method overloading is used when you want your methods to do same tasks but using different input parameters.

14. What happens when we use ‘private’ modifier to a constructor of a class?
a ) When we declare a constructor of a class as private then we can’t create a objects of that class and we can not use that class as a base class for inheritance

15. Can we overload constructors?
a ) Yes

16. What are instant variables?
a ) Class variables are known as instant variables. Instant variables are different for each object and they are accessed using the objects. When ever a class is instantiated a new copy of the each of the instant variable is created.

17. What are static variables?
a ) These are also known as class variables. Static variables are common for all objects of a class. Only one copy of static variables will be created for all the objects of a class.

18. What are the differences between structure and class
a ) Structure:
It is value type
It is stored on stack
Does not support inheritance
Suitable for small data structure
Class:
It is reference type
It is stored on heap
Supports inheritance
Suitable for complex data structures

19. What is a value type? Give examples
a ) It stores value directly. Value types are stored on stack. Separate memory will be given for each instant of a value type.
Ex: int, float, char, struct

20. What are reference type?
a ) It stores a reference to the value. They are stored on heap.
Ex: class, string, array.

13 comments:

Nina said...

Very nice. It reminds me of my C# class when I was in college. Good thing you posted this in your blog.

I'll enjoy reading a few answers here.

Thanks.

editor said...

I like your blog it is nice,I am expecting you comment on my blog.

Stas said...

I don't understand anything, but... should be it very interesting.
I checked- You don't have added descryption and keywords, what will make Your blog visible for search engines like Google. It very simple to add that, look at http://online-income-opportunities-vorsta.blogspot.com/2009/02/meta-tags-are-identifications-which.html
Enjoy!

Vinay Rai said...

nice set of questions . Very Helpful for everyone.

EnterBangla said...

Good collection. Visit enterbangla.blogspot.com for more questions.

LazyKing said...

I didnt learn C# but C++. I'm a friend from blogcatalog

admin said...

Nice info to share. i love the quality of your questions

Vinay Rai said...

These tips are really useful. Aspiring software programmers must have a look.

catatansemu.com said...

nice blog, i found your blog from blogcatalog

alwayswinner786 said...

A very helpful info for those in related fields.
Nice blog.
All the best.

Vinay Rai said...

I will like to see more questions here. Can you include questions on perl

Prem Godara said...

can you include questions in java, it wont be hard because both are object oriented? And do tell the difference between an interface and an abstract class. This is a very basic question but many people don't know the answer

dave said...

Great for programming interviews -- I've done C and some C++ programming, so it's nice to have a bit of a review. Nice post!