Sunday, July 1, 2012

C# interview questions with answers, Part 1

C# developer interview questions with answers.



The C# keyword .int. maps to which .NET type?

  1. System.Int16
  2. System.Int32
  3. System.Int64
  4. System.Int128

Answer : 
2. System.Int32


Which of these statements correctly declares a two-dimensional array in C#?

  1. int[,] myArray;
  2. int[][] myArray;
  3. int[2] myArray;
  4. System.Array[2] myArray;


Answer : 
1. int[,] myArray;




Which of these string definitions will prevent escaping on backslashes in C#?

  1. string s = #.n Test string.;
  2. string s = ..n Test string.;
  3. string s = @.n Test string.;
  4. string s = .n Test string.;
Answer : 
3. string s = @.n Test string.;



If a method is marked as protected internal who can access it?

  1. Classes that are both in the same assembly and derived from the declaring class.
  2. Only methods that are in the same class as the method in question.
  3. Internal methods can be only be called using reflection.
  4. Classes within the same assembly, and classes derived from the declaring class.


Answer : 
4. Classes within the same assembly, and classes derived from the declaring class.



What is boxing?

  1. Encapsulating an object in a value type.
  2. Encapsulating a copy of an object in a value type.
  3. Encapsulating a value type in an object.
  4. Encapsulating a copy of a value type in an object.


Answer : 
4. Encapsulating a copy of a value type in an object.



What compiler switch creates an xml file from the xml comments in the files in an assembly?

  1. /text
  2. /doc
  3. /xml
  4. /help
Answer : 
2. /doc


What is a satellite Assembly?

  1. A peripheral assembly designed to monitor permissions requests from an application.
  2. Any DLL file used by an EXE file.
  3. An assembly containing localized resources for another assembly.
  4. An assembly designed to alter the appearance or .skin. of an application.
Answer : 
3. An assembly containing localized resources for another assembly.


No comments:

Post a Comment