Interview FAQs


FAQs of level

The first one performs a deep copy of the array, the second one is shallow.
StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time it is being operated on, a new instance is created.
Each instance of a reference type has two fields maintained by the runtime - a method table pointer and a sync block. These are 4 bytes each on a 32-bit system, making a total of 8 bytes per object overhead. Obviously the instance data for the type must be added to this to get the overall size of the object. So, for example, instances of the following class are 12 bytes each:

class MyInt
private int x;

However, note that with the current implementation of the CLR there seems to be a minimum object size of 12 bytes, even for classes with no data (e.g. System.Object).

Values types have no equivalent overhead.

Identifiers are the names given to classes, methods, variables and interfaces. It must be a whole word and starts with either an alphabet or an underscore. They are case sensitive. The main point you should bear in mind is that the names should not clash with C# keywords.

Some programmers use @ prefix as a first character while declaring identifiers to avoid clash with a keyword but it is not a recommended practice. Following names are valid identifiers in C#

1. Hello
2. hello
3. H_ello
4. HelloYOu
Keywords are special words built into the C# language and are reserved for specific use. This means you cannot use them for naming your classes, methods and variables. For instance, if you attempt to use a C# keyword (if) as your class name, the C# compiler will emit runtime error.
Yes, you can use MySQL with C#. You can connect to the database by using ODBC driver and the System.Data.Odbc namespace.
No, static indexer are not allowed in C#.
In both the C and C++ languages, each subarray of a particular multi-dimensional array must have identical dimensions. In other words, arrays must be orthogonal. However, in both the Java and C# languages, arrays need not be orthogonal; because, arrays are constructed as arrays of arrays.

In C#, each array is one-dimensional. Therefore, jagged arrays of varying sizes can be built. The contents of a jagged array is arrays of instances or of references to arrays. Therefore, the rows and columns of a jagged array need not be of uniform length.

The following C# example illustrates how to construct a jagged array:

int [][]anArray = new int[3][];
anArray [0] = new int[7];
anArray [1] = new int[13];
anArray [2] = new int[5];
PreviousDisplaying 7 of 25Next
Need Help? Contact Us.

Log in


Forgot password?


New User