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.
91. How does C# differ from C++?
C# does not support #include statement. It uses only using statement.
In C# , class definition does not use a semicolon at the end.
C# does not support multiple code inheritance.
Casting in C# is much safer than in c++.
In C# switch can also be used on string values.
Command line parameters array behave differently in C# as compared to C++.
92. What is nested class?
A Nested classes are classes within classes.
A nested class is any class whose declaration occurs within the body of another class or interface.
93. Can you have parameters for static constructors?
No, static constructors cannot have parameters.
94. Is String is Value Type or Reference Type in C#?
String is an object(Reference Type).
95. Does C# provide copy constructor?
No, C# does not provide copy constructor.
96. Can a class or a struct have multiple constructors?
Yes, a class or a struct can have multiple constructors. Constructors in C# can be overloaded.
97. Can you create an instance of an interface?
No, you cannot create an instance of an interface.
98. Can an Interface contain fields?
No, an Interface cannot contain fields.
99. Can a class have static constructor?
Yes, a class can have static constructor. Static constructors are called automatically, immediately before any static fields are accessed, and are generally used to initialize static class members. It is called automatically before the first instance is created or any static members are referenced. Static constructors are called before instance constructors. An example is shown below.
100. What is the main use of delegates in C#?
Delegates are mainly used to define call back methods.
0 comments:
Post a Comment