Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

search topic

Tuesday, August 5, 2008

CSharp Technical Interview Questions - 3 IMP interview questions

C Sharp Technical Interview Questions and Answers, solutions, solved programs For IT Companies Placement papers, software developers jobs

  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?

    • public static void Main()

    • public static int Main()

    • public static void Main( string[] args )

    • public static int Main(string[] args )

  5. Does Main() always have to be public? No.

  6. How do you initialize a two-dimensional array that you don’t know the dimensions of?

    • int [, ] myArray; //declaration

    • myArray= new int [5, 8]; //actual initialization

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

  8. What’s the difference between struct and class in C#?

    • Structs cannot be inherited.

    • Structs are passed by value, not by reference.

    • Struct is stored on the stack, not the heap.

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

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

  11. 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++.

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

  13. Where do the reference-type variables go in the RAM? The references go on the stack, while the objects themselves go on the heap. However, in reality things are more elaborate.

  14. 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.

  15. How do you convert a string into an integer in .NET? Int32.Parse(string), Convert.ToInt32()

  16. How do you box a primitive data type variable? Initialize an object with its value, pass an object, cast it to an object

  17. Why do you need to box a primitive variable? To pass it by reference or apply a method that an object supports, but primitive doesn’t.

  18. 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.

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

  20. 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. The only time the finalizer should be implemented, is when you’re dealing with unmanaged code.

  21. What’s different about namespace declaration when comparing that to package declaration in Java? No semicolon. Package declarations also have to be the first thing within the file, can’t be nested, and affect all classes within the file.

  22. 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().

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

  24. What’s different about switch statements in C# as compared to 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.

  27. Describe the compilation process for .NET code? Source code is compiled and run in the .NET Framework using a two-stage process. First, source code is compiled to Microsoft intermediate language (MSIL) code using a .NET Framework-compatible compiler, such as that for Visual Basic .NET or Visual C#. Second, MSIL code is compiled to native code.

  28. Name any 2 of the 4 .NET authentification methods. ASP.NET, in conjunction with Microsoft Internet Information Services (IIS), can authenticate user credentials such as names and passwords using any of the following authentication methods:

    • Windows: Basic, digest, or Integrated Windows Authentication (NTLM or Kerberos).

    • Microsoft Passport authentication

    • Forms authentication

    • Client Certificate authentication

  29. How do you turn off SessionState in the web.config file? In the system.web section of web.config, you should locate the httpmodule tag and you simply disable session by doing a remove tag with attribute name set to session.



  30. What is main difference between Global.asax and Web.Config? ASP.NET uses the global.asax to establish any global objects that your Web application uses. The .asax extension denotes an application file rather than .aspx for a page file. Each ASP.NET application can contain at most one global.asax file. The file is compiled on the first page hit to your Web application. ASP.NET is also configured so that any attempts to browse to the global.asax page directly are rejected. However, you can specify application-wide settings in the web.config file. The web.config is an XML-formatted text file that resides in the Web site’s root directory. Through Web.config you can specify settings like custom 404 error pages, authentication and authorization settings for the Web site, compilation options for the ASP.NET Web pages, if tracing should be enabled, etc.

No comments: