C Sharp Interview Questions and Answers - 3

Question: 11

What’s the difference between const and read only?

You can initialize read only 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 read only string DateT= new DateTime().ToString().

Question: 12

Overloaded constructor will call default constructor internally?

No

Question: 13

What’s different about switch statements in C#?

No fall-throughs allowed. Unlike the C++ switch statement, C# does not support an explicit fall through from one case lable to another. If you want, you can use goto a switch-case, or goto default.

Case 1:

        Cost += 25;

        Break;

Case 2:

        Cost += 25;

        Goto case 1;

Question: 14

What are features of C#?

Features of C# are as given under:

C# is very powerful and simple language for building interoperable, scalable and robust applications.

With C#, console, windows as well as web applications can be developed

Supports Garbage collection and automatic memory management

Being an object oriented language, it supports data encapsulation, inheritance, polymorphism, method overriding etc.

C# includes native support for the COM and windows based applications.

To avoid any redundancy, the values of the primitive data types are automatically initialized to zeros and reference types like objects and classes etc. are initialized to null

C# doesn’t supports unsafe type casts, pointers and 0 or 1 for Boolean values.

Question: 15

What is partial class?

The concept of partial classes is applied to the long classes for breaking them up into manageable chunks.

That is, class is split into several C# (.cs) files.

Besides being split into several files, there is no difference between partial and a normal class.

On compilation, the compiler tracks down each piece of the splitted class and assemble it into a single unit.

They only thing to take care while splitting the class into separate files is that the name of the class must be consistent in all the files.

Every fragment of a partial class must use the partial keyword in the class declaration.

Related Questions