Jun 12

Basic C# Interview Questions and Answers

81. What is the difference between CONST and READONLY?

Both are meant for constant values. A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or.

82. Does C# have a throws clause?

No, unlike Java, C# does not require (or even allow) the developer to specify the exceptions that a method can throw.

83. What are the different ways a method can be overloaded?

Different parameter data types, different number of parameters, different order of parameters.

84. Do events have return type?

No, events do not have return type.

85. What is event?

An event is an action performed based on another method of the program.

An event is a delegate type dass member that is used by an object or a class to provide a notification to other objects that an event has occurred.

An event can be declared with the help of the event keyword.

86. What is an identifier?

Identifiers are nothing but names given to various entities uniquely identified in a program.

87. What are the different types of literals in C#?

Boolean literals: True and False are literals of the Boolean type that map to the true and false state, respectively.

Integer literals: Used to write values of types Int, ulnt, long, and ulong.

Real literals: Used to write values of types float, double, and dedmal.

Character literals: Represents a single character and usually consists of a character in quotes, such as ‘a’.

String literals: C# supports two types of string literals, regular string literal and verbatim string literals. A regular string literal consists of zero or more characters enclosed in double quotes, such as “116110”. A verbatim string literal consists of an @ character followed by a double–quote character, such as ©”hello”.

The Null literal: Represents the null–type.

88. What is meant by data encapsulation?

Data encapsulation, also referred to as data hiding, is the mechanism whereby the implementation details of a class are kept hidden from the user. The user can only perform a restricted set of operations on the hidden members of the class by executing special functions called methods.

89. Can you override private virtual methods?

No. Private methods are not accessible outside the class.

90. What is the main difference between a subprocedure and a function?

Subprocedures do not return a value, while functions do.

Permanent link to this article: http://zappmania.in/2014/06/12/basic-c-interview-questions-answers.htm

Leave a Reply

Your email address will not be published.