affiliate_link

Wednesday, October 11, 2017

Latest C# Questions

Wherever you go in for your .NET interview in Montreal or Toronto, you should be ready to answer the following questions:
  1. How many languages .NET is supporting now? - When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. 
  2. How is .NET able to support multiple languages? - a language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.
  3. How ASP .NET different from ASP? - Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.
  4. Resource Files: How to use the resource files, how to know which language to use?
  5. What is smart navigation? - The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.
  6. What is view state? - The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control
  7. Explain the life cycle of an ASP .NET page.
  8. How do you validate the controls in an ASP .NET page? - Using special validation controls that are meant for this. We have Range Validator, Email Validator.
  9. Can the validation be done in the server side? Or this can be done only in the Client side? - Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.
  10. How to manage pagination in a page? - Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.
  11. What is ADO .NET and what is difference between ADO and ADO.NET? - ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.

1) The C# keyword .int. maps to which .NET type?
  1. System.Int16
  2. System.Int32
  3. System.Int64
  4. System.Int128
2) 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.;
3) 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;
4) 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.
5) What is boxing?
a) Encapsulating an object in a value type.
b) Encapsulating a copy of an object in a value type.
c) Encapsulating a value type in an object.
d) Encapsulating a copy of a value type in an object.
6) 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
7) 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.
8) What is a delegate?
  1. A strongly typed function pointer.
  2. A light weight thread or process that can call a single method.
  3. A reference to an object in a different process.
  4. An inter-process message channel.
9) How does assembly versioning in .NET prevent DLL Hell?
  1. The runtime checks to see that only one version of an assembly is on the machine at any one time.
  2. .NET allows assemblies to specify the name AND the version of any assemblies they need to run.
  3. The compiler offers compile time checking for backward compatibility.
  4. It doesn.t.
10) Which .Gang of Four. design pattern is shown below?
public class A {
    private A instance;
    private A() {
    }
    public
static A Instance {
        get
        {
            if ( A == null )
                A = new A();
            return instance;
        }
    }
}
  1. Factory
  2. Abstract Factory
  3. Singleton
  4. Builder
11) In the NUnit test framework, which attribute must adorn a test class in order for it to be picked up by the NUnit GUI?
  1. TestAttribute
  2. TestClassAttribute
  3. TestFixtureAttribute
  4. NUnitTestClassAttribute
12) Which of the following operations can you NOT perform on an ADO.NET DataSet?
  1. A DataSet can be synchronised with the database.
  2. A DataSet can be synchronised with a RecordSet.
  3. A DataSet can be converted to XML.
  4. You can infer the schema from a DataSet.
13) In Object Oriented Programming, how would you describe encapsulation?
  1. The conversion of one type of object to another.
  2. The runtime resolution of method calls.
  3. The exposition of data.
  4. The separation of interface and implementation.