IBM C# Jobs Interview Question and Answers:Part 3

9/29/2009 No Comment
This is a list of Microsoft C#.NET Interview Questions gathered from various sources
1. How big is the datatype int in .NET? 32 bits.

2. How big is the char? 16 bits (Unicode).

3. How do you initiate a string without escaping each backslash? Put an @ sign in front of the double-quoted string.

4. What are valid signatures for the Main function?
l public static void Main()
l public static int Main()
l public static void Main( string[] args )
l public static int Main(string[] args )

5. How do you initialize a two-dimensional array that you don’t know the dimensions of?
l int [, ] myArray; //declaration
l myArray= new int [5, 8]; //actualinitialization

6. What’s the access level of the visibility type internal? Current assembly.

7. What’s the difference between struct and class in C#?
l Structscannot be inherited.
l Structsare passed by value, not by reference.
l Struct is stored on the stack, not the heap.

8. Explain encapsulation. The implementation is hidden, the interface is exposed.

9. What data type should you use if you want an 8-bit value that’s signed? sbyte.

10. Speaking of Boolean data types, what’s different between C# and C/C++? There’s no conversion between 0 and false, as well as any other number and true, like in C/C++.

11. Where are the value-type variables allocated in the computer RAM? Stack.

12. Where do the reference-type variables go in the RAM? The references go on the stack, while the objects themselves go on the heap.

13. What is the difference between the value-type variables and reference-type variables in terms of garbage collection? 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.

14. How do you convert a string into an integer in .NET? Int32.Parse(string)

15. How do you box a primitive data type variable? Assign it to the object, pass an object.

16. Why do you need to box a primitive variable? To pass it by reference.

17. What’s the difference between Java and .NET garbage collectors? 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.

18. How do you enforce garbage collection in .NET? System.GC.Collect();

19. Can you declare a C++ type destructor in C# like ~MyClass()? 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.

20. What’s different about namespace declaration when comparing that to package declaration in Java? No semicolon.

21. What’s the difference between const and readonly? You can initialize readonly 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 readonly string DateT = new DateTime().ToString().

22. What does \a character do? On most systems, produces a rather annoying beep.

23. Can you create enumerated data types in C#? Yes.

24. What’s different about switch statements in C#? No fall-throughs allowed.

25. What happens when you encounter a continue statement inside the for loop? The code for the rest of the loop is ignored, the control is transferred back to the beginning of the loop.

26. Is goto statement supported in C#? How about Java? Gotos are supported in C#to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality

Related Posts


No comments :

 

Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer