-
Platform specific code is obtained when
A) source code is compiled to get MSILB) when MSIL is compiled by CLRC) Both of the aboveExplanation: When CLR compiles the managed it generates the native code which is compatible to platform.
-
Code running under the control of CLR is often referred as
A) Source CodeB) Managed CodeC) Unmanaged CodeExplanation: Source code is compiled to MSIL, which is generally known as managed code
-
How do you add objects to hashtable
A) With Add methodB) With insert MethodC) With = operator
-
GetEnumerator( ) of Ienumerable interface returns
A) IenumeratorB) IcollectionC) Ienumerable
-
What happens when you create an arraylist as ArrayList Arr=new ArrayList()
A) An arraylist of object Arr is created with the capacity of 16B) An arraylist of object Arr is created with the capacity of 20C) An arraylist of object Arr is created with the capacity of 26Explanation: Default capacity is 16 if size is not specified
-
In order to use stringbuilder in our class we need to refer
A) System.TextB) System.IOC) System.StringBuilder
-
For performing repeated modification on string which class is preferred
A) StringB) StringBuilderC) Both
-
How are the attributes specified in C#
A) Enclosed with in [ ]B) Enclosed with in ( )C) Enclosed with in { }
-
Which preprocessor directive are used to mark that contain block of code is to be treated as a single block
A) # define & #undefB) # Region & #EndRegionC) #Line
-
Which method is implicitly called when an object is created
A) Main MethodB) Constructor MethodC) Destructor MethodExplanation: Constructor is the method which is implicitly created when ever a class is instantiated
-
Interface members can not be declared as
A) VirtualB) StaticC) PrivateD) All of the above
-
-
What is the difference between a struct and a class in C#?
From language spec:The list of similarities between classes and structs is as follows. Longstructs can implement interfaces and can have the same kinds of members as classes. Structs differ from classes in several important ways; however, structs are value types rather than reference types, and inheritance is not supported for structs. Struct values are stored on the stack or in-line. Careful programmers...
-
Sealed class can be inherited
A) TrueB) FalseExplanation: Sealed class cannot be inherited
-
Which of the following can not be declared as virtual
A) Static functionsB) Member fieldsC) Instance functions
-
Which of the following is not a C# reserved keyword
A) IsB) AsC) InD) Of
-
Use C# to turn on the 4th and 7th bits
Use C# to turn on the 4th and 7th bits of a said byte myFlag, in which right most bit is first bit.Answer[Flags] enum BitFlags : byte { One = (1
-
Write a class in C# which get an action in its construction
Write a class in C# which get an action (parameter less delegate) in its construction and has a single public method ‘bool execute()’ which does following: 1. Execute the action only if no other thread is currently executing the action.2. If another thread is already executing, wait until thread finished before returning (but without executing action again)3. Return true if current thread that action,...
-
Which of the member is not a member of Object
A) Equals ( )B) GetType ( )C) ToString ( )D) Parse( )
-
Which statement is invalid with regards to Constant
A) They must be initialized when they are declaredB) The value of the constant must be computable at compile timeC) Constants are not staticD) Constant is a variable whose value can be changed through out it’s life time when it is static.
C# Interview Questions
Ans