Microsoft .NET Interview Questions and Answers
Freshers / Beginner level questions & answers
Ques 1. Name 10 C# keywords.
abstract, event, new, struct, explicit, null, base, extern, object, this
Ques 2. What is public accessibility?
There are no access restrictions. All can access the public instance from anywhere.
Ques 3. What is private accessibility?
Access is restricted to within the containing class.
Ques 4. Class methods to should be marked with what keyword?
Static.
Ques 5. Does an object need to be made to run main?
No
Ques 6. Write a hello world console application.
using System;
namespace Console1
{
class Class1
{
[STAThread] // No longer needed
static void Main(string[] args)
{
Console.WriteLine("Hello world");
}
}
}
Ques 7. What is recursion?
Recursion is when a method calls itself.
Ques 8. What is a constructor?
A constructor performs initialisation for an object (including the struct type) or class.
Ques 9. What is a destructor?
A C# destuctor is not like a C++ destructor. It is actually an override for Finalize(). This
is called when the garbage collector discovers that the object is unreachable. Finalize()
is called before any memory is reclaimed.
Ques 10. Name 5 built in types.
Bool, char, int, byte, double
Ques 11. Is string Unicode, ASCII, or something else?
Unicode
Ques 12. Strings are immutable, what does this mean?
Any changes to that string are in fact copies.
Ques 13. Name a few string properties.
trim, tolower, toupper, concat, copy, insert, equals, compare.
Ques 14. What is boxing and unboxing?
Converting a value type (stack->heap) to a reference type (heap->stack), and viseversa.
Ques 15. Write some code to box and unbox a value type.
// Boxing
int i = 4;
object o = i;
// Unboxing
i = (int) o;
Ques 16. What is a heap and a stack?
There are 2 kinds of heap – 1: a chunk of memory where data is stored and 2: a tree
based data structure. When we talk about the heap and the stack we mean the first kind
of heap. The stack is a LIFO data structure that stores variables and flow control
information. Typically each thread will have its own stack.
Ques 17. What is a pointer?
A pointer is a reference to a memory address.
Ques 18. What does new do in terms of objects?
Initializes an object.
Ques 19. What is a struct?
Unlike in C++ a struct is not a class – it is a value type with certain restrictions. It is
usually best to use a struct to represent simple entities with a few variables. Like a Point
for example which contains variables x and y.
Ques 20. Describe 5 numeric value types ranges.
sbyte -128 to 127, byte 0 – 255, short -32,768 to 32,767, int -2,147,483,648 to
2,147,483,647, ulong 0 to 18,446,744,073,709,551,615
Ques 21. Write code for a case statement.
switch (n)
{
case 1:
x=1;
break;
case 2:
x=2;
break;
default:
goto case 1;
}
Most helpful rated by users:
- Name 10 C# keywords.
- What is public accessibility?
- .NET Stands for?
- What is private accessibility?
- What is protected accessibility?
Related interview subjects
ASP .NET interview questions and answers - Total 31 questions |
Microsoft .NET interview questions and answers - Total 60 questions |
ASP interview questions and answers - Total 82 questions |
LINQ interview questions and answers - Total 20 questions |
C# interview questions and answers - Total 41 questions |