Qus: And if they have conflicting method names?
Ans: It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.
Qus: What’s the difference between an interface and abstract class?
Ans: In the interface all methods must be abstract, in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.
Qus: How can you overload a method?
Ans: Different parameter data types, different number of parameters, different order of parameters.
Qus: If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?
Ans:Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.
Qus: What’s the difference between System. String and System.StringBuilder classes?
Ans:System. String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed
Qus: How big is the data type int in .NET?
Ans:32 bits.
Qus: How big is the char?
Ans:16 bits (Unicode).
Qus: How do you initiate a string without escaping each backslash?
Ans: Put an @ sign in front of the double-quoted string.
Qus: What are valid signatures for the Main function?
Ans: public static void Main ()
public static int Main ()
public static void Main ( string[] args )
public static int Main (string[] args )
Qus: How do you initialize a two-dimensional array that you don’t know the dimensions of?
Ans: int [ , ] myArray; //declaration
myArray = new int [5, 8]; //actual initialization
Qus: What’s the access level of the visibility type internal?
Ans: Current application.
Qus: What’s the difference between struct and class in C#?
Ans: Structs cannot be inherited.
Structs are passed by value, not by reference.
Struct is stored on the stack, not the heap.
Qus: Explain encapsulation.
Ans: The implementation is hidden, the interface is exposed.
Qus: What data type should you use if you want an 8-bit value that’s signed?
Ans: sbyte .
Qus: Speaking of Boolean data types, what’s different between C# and /C++?
Ans: There’s no conversion between 0 and false, as well as any other number and true, like in C/C++.
Qus: Where are the value-type variables allocated in the computer RAM?
Ans: Stack.
Qus: Where do the reference-type variables go in the RAM?
Ans: The references go on the stack, while the objects themselves go on the heap.
Qus: What is the difference between the value-type variables and reference-type variables in terms of garbage collection?
Ans: The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null.
Qus: How do you convert a string into an integer in .NET?
Ans: Int32.Parse( string)
Qus: How do you box a primitive data type variable?
Ans: Assign it to the object, pass an object.
Qus: Why do you need to box a primitive variable?
Ans: To pass it by reference.
Qus: What’s the difference between Java and .NET garbage collectors?
Ans: Sun left the implementation of a specific garbage collector up to the JRE developer, so their performance varies widely, depending on whose JRE you’re using. Microsoft standardized on their garbage collection.
Qus: How do you enforce garbage collection in .NET?
Ans: System.GC.Collect ( );
Qus: Can you declare a C++ type destructor in C# like ~MyClass ()?
Ans:Yes, but what’s the point, since it will call Finalize(), and Finalize() has no guarantees when the memory will be cleaned up, plus, it introduces additional load on the garbage collector.
Qus: What’s different about namespace declaration when comparing that to package declaration in Java?
Ans: No semicolon.
Qus: What’s the difference between const and read only?
Ans: You can initialize read only variables to some runtime values. Let’s say your program uses current date and time as one of the values that won’t change. This way you declare public read only string DateT = new DateTime ().ToString ().
Qus: What does \a character do?
Ans: On most systems, produces a rather annoying beep.
Qus: Can you create enumerated data types in C#?
Ans: Yes.
Qus: What’s different about switch statements in C#?
Ans: No fall-throughs allowed.