Mcq Answers for C#

Mcq Answers for C#

  1. HashSet is an unordered collection.
  2. The default EqualityComparer checks whether the element supplied to the HashSet is unique or not.
  3. HashSet provides functionality for "conceptual sets" where the rules for membership can be specified without actually creating all of the items.
  4. All of the above
Answer: Answer is d
Further Reading:
A HashSet collection is not sorted and cannot contain duplicate elements.Useful resources, HashSet collectionHashSet

  1. System.DateTime
  2. System.TimeSpan
  3. System.Globalization.Calendar
  4. System.Globalization.CultureInfo
Answer: Answer is c
Further Reading:
A calendar divides time into units, such as weeks, months, and years. The number, length, and start of the divisions vary in each calendar. Useful resources, Calendar class

  1. A Nullable type is a reference type.
  2. An implicit conversion exists from any non-nullable value type to a nullable form of that type.
  3. A predefined conversion from the nullable type S? to the nullable type T? exists if there is a predefined conversion from the non-nullable type S to the non-nullable type T
Answer: Answer is b, c
Further Reading:
Useful resources, Nullable Types

  1. You can request that the garbage collector processes a generation if it determines that it is appropriate at specific points in your code    
  2. You can control the intrusiveness of the garbage collector (how often it performs collections) while your program is running    
  3. You can control the intrusiveness of the garbage collector (how often it performs collections) only during application initialization
  4. You should specify LowLatency when using Concurrent Server Garbage Collection to improve memory utilization
Answer: Answer is c
Further Reading:
Useful resources, GC ClassLatency Modes

  1. The compiler generates a backing field that is completely inaccessible from the application code.

  2. The compiler generates a backing field that is accessible via reflection.
  3. The compiler generates a code that will store the information separately from the instance to ensure its security.
Answer: Answer is a
Further Reading:
In general, you can’t accessBut there might be different stories. According to the accepted answer of Is it possible to access backing fields behind auto-implemented propertiesyou can do it, but is not confirmed nor provided any reference. So, as of now, our answer is The compiler generates a backing field that is completely inaccessible from the application code. Useful resources,Auto-Implemented Properties

  1. You declare (explicitly or implicitly) the accessibility of the property and get and set assessors, but do not provide any implementation or backing field
  2. You attribute a member field so that the compiler will generate get and set assessors
  3. The compiler creates properties for your class based on class level attributes
  4. They are properties which are automatically invoked as part of the object construction process
Answer: Answer is a
Further Reading:
Useful resources, Auto-Implemented Properties

  1. ApplicationState
  2. SessionState
  3. ViewState
  4. All of the above
Answer: Answer is d
Further Reading:
Useful resources, ASP.NET State Management

  1. int
  2. double
  3. long
  4. float
Answer: Answer is a, d
Further Reading:
Reads and writes of the following data types are atomic: bool, char, byte, sbyte, short, ushort, uint, int, float, and reference types. In addition, reads and writes of enum types with an underlying type in the previous list are also atomic. Reads and writes of other types, including long, ulong, double, and decimal, as well as user-defined types, are not guaranteed to be atomic. Useful resources, Atomicity of variable references

  1. It is pure Object Relational (O/R) model.
  2. It is a set of enhancements to the DataSet and DataTable classes.
  3. It requires the use of SQLServer as the database.
  4. Because LINQ is based on Queries, it cannot be used to modify the data in the database
Answer: Answer is a
Further Reading:

  1. They must handle case-sensitivity identically in both the GetHashCode() and Equals() methods.
  2. Key objects must be immutable for the duration they are used within a HashTable.
  3. Get HashCode() must be overridden to provide the same result, given the same parameters, regardless of reference equality unless the HashTable constructor is provided with an IEqualityComparer parameter.
  4. Each Element in a HashTable is stored as a Key/Value pair of the type System.Collections.DictionaryElement
  5. All of the above
Answer: Answer is e
Further Reading:
Useful resources, Hashtable


  1. They can be declared either static or instance members.
  2. Extension methods can be used to override existing instance methods
  3. Extension methods with the same signature for the same class may be declared in multiple namespace without causing compilation errors.
  4. They must be declared in the same assembley(but may be in different source files)
Answer: Answer is c
Further Reading:
Extension methods are defined as static methods but are called by using instance method syntax. Their first parameter specifies which type the method operates on, and the parameter is preceded by the this modifier. Extension methods are only in scope when you explicitly import the namespace into your source code with a using directive. Useful resources, Extension Methods

  1. More concise syntax
  2. The types for a Lambda Excpression may be omitted
  3. The body of an Anonymous method can not be an expression.
  4. Lambda Expressions permit deferred type inference that anonymous methods do not.
  5. All of the above.
Answer: Answer is a

Class MyClass
{ 
     public event EventHandler MyEvent;
}
  1. public void A_MyEvent(object sender, MyArgs e)
    {
    }
    
  2. public void A_MyEvent(object sender, EventArgs e)
    {
    }
  3. public void A_MyEvent(MyArgs e)
    {
    }
Answer: Answer is a
Further Reading:
Useful resources, Event handler methods

static void F1(params int [] y)
{
}

static void Sample()
{ 

int [] j = new Int32[3];
List k = new List();
// FURTHER READING GOES HERE
}
  1. F1(j);
  2. F1(k);
  3. F1(1, 2, 3);
  4. F1(new [] {1,2,3})
Answer: Answer is b
Further Reading:
F1() expects integer type parameter but k is a list type object. So, F1(k) will generate compile time error.

  1. Support is provided for the "Suite B" set of cryptographic algorithms as specified by the National Security Agency (NSA).
  2. Cryptography Next Generation (CNG) classes are supported on XP and Vista systems.
  3. The System.Security.Cryptography.AesManaged class allows custom block size, iteration counts and feedback modes to support any Rijndael based encryption.
  4. None of the above
Answer: Answer is d
Further Reading:
“Suite B”, CNG and System.Security.Cryptography.AesManaged not available under .net 3.5Also, Cryptography API Next Generation(CNG) is available from Windows Vista™and onward.Useful resources,Cryptography,AesManagedclass

  1. ApplicationException
  2. DataMisalignedException
  3. ExecutionEngineException
  4. SystemException
Answer: Answer is a
Further Reading:
The exception that is thrown when a non-fatal application error occurs. Useful resources,ApplicationException

  1. Bringing various existing communication technologies into a unified environment.
  2. Cross vendor/platform communication.
  3. Support for asynchronous communications.
  4. Support for distributed applications based on technologies such as MSMQ and/or COM+
  5. All of the above
Answer: Answer is e
Further Reading:
Useful resources, What is WCFWCF

  1. The DataReader provides a cursor that can be used to move forward and backwards through the result.
  2. The DataReader provides random access capabilities on the result.
  3. The DataReader can provide the Schema information of the result to the application code.
Answer: Answer is c
Further Reading:

  1. The DataSets and DataTables objects requires continuous connection to the database
  2. All tables in a dataset must come from the same database
  3. A given instance of a DataTable can be in only one DataSet
  4. Content from multiple DataSets can easily be combined into a single DataSet that contains the net result of all changes
Answer: Answer is d
Further Reading:

  1. ServiceContract
  2. OperationContract
  3. DataContract
  4. MessageContract
Answer: Answer is a
Further Reading:




  1. System.Web.Mail is not supported under version 3.5 of the Framework
  2. System.Web.Mail is deprecated under version 3.5 of the Framework, and it is officially recommended that System.Net.Mail be used.
  3. System.Web.Mail is the preferred solution when using IIS hosted applications.
  4. There are no functional differences; the items were moved to a new namespace to better reflect their applicability
Answer: Answer is b
Further Reading:
Useful resources, System.Net.Mail ,System.Web.Mail

  1. It is optimized for single processor/core operations.
  2. A thread which has a read lock on a resource may not acquire a write lock on the same resource.
  3. By default, a thread which has a read lock on a resource and attempts to get another read lock on the same resource will throw an exception
Answer: Answer is a
Further Reading:
Useful resources, ReaderWriterLockSlim Class

  1. 1
  2. 25
  3. 250
  4. 100
  5. 500
Answer: Answer is b
Further Reading:
There is one thread pool per process.You can set the upper limit of threads that the pool will create by calling Thread.Pool.SetMaxThreads, the defaults are,
25 per core in 2.0
250 per core in 3.5
1023 in 4.0 32 bit
32768 in 4.0 64 bit.
Useful resources, ThreadPool

  1. Expression trees are a data structure which can be initially composed using language syntax.
  2. Expression trees are a dynamically generated code which is executed to perform the desired function.
  3. Expression trees can be modified once they are created
Answer: Answer is a
Further Reading:
Useful resources,Expression Trees

  1. void Sample1(object o)
    {
      int i = (int)o;
    }   
    
  2. void Sample1(ValueType vt) 
    {
      int i = (int)vt; 
    }   
    
  3. enum E { Hello, World} void Sample1(System.Enum et) 
    {
      E e = (E) et; 
    }   
    
  4. class C {
      public int Value { get; set; }
    }
    void Sample1(C vt)
    {
      int i = vt.Value;
    } 
    
Answer: Answer is d
Further Reading:
Boxing is the process of converting a value type to the type object or to any interface type implemented by this value type. Unboxing extracts the value type from the object. Boxing is implicit; unboxing is explicit. In (d), it’s not followed the rules of unboxing. So, it’s not unboxing conversion. Useful resources, Boxing and Unboxing

  1. creating an instance of System.runtime.memoryFailpoint and monitoring for an insufficient memory Exception.
  2. Creating an instance of system.runtime.memoryFailpoint and monitoring for an out of memory Exception.
  3. There is no supported application level means determine if the specific amount of memory is available
  4. Using static methods of System.Runtime.MemoryFailPoint and checking the return value
Answer: Answer is a
Further Reading:
Useful resources, MemoryFailPoint Class

  1. C# allows non-type templateparameters.
  2. C# supports explicit specialization.
  3. C# allows the type parameter to be used as the base class for generic type.
  4. C# allows a generic type parameter itself to be a generic.
  5. C# enforces that all codes are valid for all types of parameters
Answer: Answer is e
Further Reading:
Useful resources,C# Generics

  1. Creating an instance of System.Runtime.MemoryFailPoint and monitoring for an InsufficientMemoryException
  2. Creating an instance of System.Runtime.MemoryFailPoint and monitoring for an OutOfMemoryException
  3. There is no supported application level means to determine if a specific amount of memory is available
Answer: Answer is a
Further Reading:
To use a memory gate, you must create a MemoryFailPoint object and specify the number of megabytes (MB) of memory that the next operation is expected to use. If enough memory is not available, anInsufficientMemoryException exception is thrown. Useful resources, MemoryFailPoint

  1. All elements in the initializer list must be of the same type.
  2. All elements in the initializer list must be implicitly convertible to a known type which is the actual type of at least one member in the initializer list.
  3. ll elements in the initializer list must be implicitly convertible to common type which is a base type of the items actually in the list
Answer: Answer is b
Further Reading:
ou can create an implicitly-typed array in which the type of the array instance is inferred from the elements specified in the array initializer. Useful resources, Implicitly Typed Arrays

var sample = "Hello World";
  1. The actual type is determined at compilation time, and has no impact on the runtime
  2. The actual type is determined at runtime, and late binding takes effect.
  3. "var" itself is a specific type defined by the framework, and no special binding takes place
Answer: Answer is a
Further Reading:
It is important to understand that the var keyword does not mean "variant" and does not indicate that the variable is loosely typed, or late-bound. It just means that the compiler determines and assigns the most appropriate type. Useful resources, Implicitly Typed Local Variables




  1. WS-Addressing
  2. WS-MetadataExchange
  3. WS-Security
  4. WS-Atomic Transaction
  5. All of the above
Answer: Answer is e
Further Reading:
Useful resources, WCF

  1. Collection Class must implement System.Collections.Generic.ICollection<T>
  2. Collection Class must implement System.Collections.Generic.IList<T>
  3.     Collection Class must implement System.Collections.Generic.ICollection<T>

    or

       Each of the Items in the Initializer List will be passed to the Add(T item) method
Answer: Answer is c
Further Reading:
In order to work with Collection initializers, a class must implement IEnumerable (not generic) and it must have an .Add() method.The method does not have to be Add(T) - it will work with non-generic collections as well.  The objects in the initialization list must match a valid Add(arg) method on the collection class. Useful resources,collection classesobject and collection initializer

  1. Access is limited to the containing class plus any classes derived from the containing class
  2. Access is limited to the current assembly
  3. Access is limited to the containing class plus any classes derived from the containing class that are also in the current assembly
  4. Access is limited to the containing class plus any classes derived from the containing class or any other class in  the current assembly
Answer: Answer is d
Further Reading:
The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Protected internal accessibility level means protected OR internal, not protected AND internal. In other words, a protected internal member can be accessed from any class in the same assembly, including derived classes. Useful resources, C# Access ModifiersAccess Modifiers

  1. Console Applications
  2. Windows Forms based Applications
  3. Windows Presentation Foundation based Applications
  4. ASP.NET based applications
  5. All of the above
Answer: Answer is e
Further Reading:
Windows Workflow Foundation (WWF) allows the runtime to be hosted in any Windows process, ranging from a simple console or Windows Forms application, to a complex server designed with workflow in mind. WWF ships with a set of services that allow the runtime to execute within ASP.NET, but ISVs and end users are free to create their own hosts or to host the Windows Workflow Foundation runtime in existing applications. Other Microsoft products including BizTalk Server and Windows SharePoint Services, can also host Windows Workflow Foundation. Useful resources, Windows Workflow FoundationIntroducing Microsoft Windows Workflow Foundation

  1. Information must be explicitly converted to/from a byte stream before it uses the MessageQueue class
  2. Invoking the MessageQueue.Send member defaults to using the System.Messaging.XmlMessageFormatter to serialize the object.
  3. Objects must be XMLSerializable in order to be transferred over a MessageQueue instance.
  4. The first entry in a MessageQueue must be removed from the queue before the next entry can be accessed
  5. Entries removed from a MessageQueue within the scope of a transaction, will be pushed back into the front of the queue if the transaction fails.
Answer: Answer is b, e
Further Reading:

  1. Assignment (=)
  2. Conditional (&&,||)
  3. Logical (&,|,^)
  4. Shift (<<, >>)
Answer: Answer is c, d
Further Reading:

  1. Classes
  2. Structs
  3. Methods
  4. Events
  5. Fields
Answer: Answer is a, b, c, d
Further Reading:
Useful resources, C# Generics

  1. well-known singleton
  2. well-known single call
  3. client activated
  4. context-agile
Answer: Answer is d
Further Reading:
Single Call, Singleton Objects and Client-Activated Objects (CAO)are the three types of objects that can be configured to serve as .NET remote objects. Useful resources, .NET Remoting

  1. Objects must be set to null in order to be eligible for garbage collection
  2. Unless specific steps are taken, an object may be moved in memory
  3. Objects become eligible for garbage collection as soon as it is impossible for any code to access them
  4. Objects which implement finalizers will always have the finalizer called at some point
Answer: Answer is c, d
Further Reading:
Useful resources, Garbage Collection

  1. It provides readable names for both regular time and, if appropriate, daylight savings time
  2. It provides a means of enumerating the known time zones that are available on the local system
  3. It provides functionality to create custom time zones
  4. It provides the period the time zone was in effect for. For example: From 1986 to 2006, it was observed from the first Sunday in April to the last Sunday in October, but since 2007, it is being observed from the second Sunday in March to the first Sunday in November
Answer: Answer is b, c
Further Reading:
Useful resources, TimeZoneInfo Class



  1. It always references the UTC (GMT) time
  2. It always references the Local  time
  3. It contains a member indicating which time zone it refers to
  4. It contains a member indicating whether the time is UTC, Local, or Unspecified
Answer: Answer is d
Further Reading:
Useful resources, DateTime

  1. The method provided by the TimerCallback delegate will always be invoked on the thread which created the timer.
  2. The thread which creates the timer must have a message processing loop (i.e. be considered a UI thread)
  3. The class contains protection to prevent reentrancy to the method provided by the TimerCallback delegate
  4. You can receive notification of an instance being Disposed by calling an overload of the Dispose method
Answer: Answer is d
Further Reading:
Useful resources,System.Threading.Timer

string t = "This Is a Test";
t.Replace("T", "?");
Console.WriteLine(t);
  1. ?his Is a ?est
  2. ?his Is a ?es?
  3. This Is a Test
  4. ?his Is a Test
Answer: Answer is c
Further Reading:
String is immutable, it’s can’t be modified. Replace will return new string. So we will not see any changes in our variable value “t”. Useful resources, String

  1. The permissions of the code which invoked the Demand method will be evaluated.
  2. For permissions which do a stack walk, an exception will occur only if NONE of the calling codes has the required permission
  3. For permissions which do a stack walk, an exception will occur if ANY of the calling codes does not have the required permission
  4. The permission levels of individual stack frames are always checked regardless of the  permission type.
Answer: Answer is c
Further Reading:
When a stack walk is performed, Demand succeeds only if no SecurityException is raised. Useful resources, IPermission.Demand method

  1. Structs can not implement interfaces
  2. Structs cannot inherit from a base struct
  3. Structs cannot have events interfaces
  4. Structs cannot have virtual methods
Answer: Answer is b
Further Reading:

  1. A Partial trust code can not emit and execute a code
  2. The generated code has no more permissions than the assembly which emitted it.
  3. It can be executed by calling System.Reflection.Emit.DynamicMethod( string name, Type returnType, Type[] parameterTypes ) without any special permissions
  4. None of the above
Answer: Answer is b, c
Further Reading:

  1. CreateComInstanceFrom
  2. CreateInstanceFrom
  3. GetInstance
  4. CreateInstance
  5. All of the above
Answer: Answer is a, b, d
Further Reading:
Useful resources, Activator class

class Sample 
{ 
  event MyEventHandlerType MyEvent; 
}
  1. MyEventHandlerType must be derived from System.EventHandler or System.EventHandler
  2. MyEventHandlerType must take two parameters, the first of the type Object, and the second of a class derived from System.EventArgs
  3. MyEventHandlerType may have a non-void return type
  4. If MyEventHandlerType is a generic type, event declaration must use a specialization of that type.
  5. MyEventHandlerType cannot be declared static
Answer: Answer is c, d

class Sample
{
  public Sample(int x)
  {
  }
}
  1. public Sample() : this(1) { }
  2. public Sample() : Sample(1) {}
  3. Both of the above
  4. One class constructor can not directly access another constructor
Answer: Answer is a
Further Reading:
Useful resources, C# Constructors

  1. They encapsulate native resource and must be properly Disposed to prevent potential exhausting of resources.
  2. They are all MarshalByRef derived classes, but functionality across AppDomains has specific limitations.
  3. You can inherit from these classes to provide enhanced or customized functionality
  4. They are Value Type objects.
Answer: Answer is a, b
Further Reading:




  1. class Sample 
    {    
     public static Sample()    
     {    
     } 
    }
    
  2. class Sample 
    {    
     static Sample()    
     {    
     } 
    }
    
  3. class Sample 
    {    
     static Sample(int value)
     {    
     } 
    }
    
  4. class Sample 
    {    
     static void Sample()
     {    
     } 
    }
    
Answer: Answer is b
Further Reading:
Useful resources, Static Constructors

  1. Interprocess communication through anonymous and/or named pipes.
  2. Access to named pipes using System.IO.Stream
  3. Access to system level pipe security implemented as discretionary access control lists (DACL) and/or system access control lists (SACL)
  4. Asynchronous read and write operations
  5. All of the above
Answer: Answer is e

  1. It must begin with a from clause
  2. It must begin with a select clause
  3. It can end with a group clause
  4. It must contain at least one where clause
  5. An orderby clause may optionally follow a select clause
Answer: Answer is a, c
Further Reading:
A query expression must begin with a from clause and must end with a select or group clause. Between the first from clause and the last select or group clause, it can contain one or more of these optional clauses:whereorderbyjoinlet and even additional from clauses. You can also use the into keyword to enable the result of a join or group clause to serve as the source for additional query clauses in the same query expression. Useful resources, Query Expression Basics

  1. Expression trees are a data structure which can be initially composed using language syntax.
  2. Expression trees are dynamically generated code which is executed to perform the desired function.
  3. Expression trees can only be created from Lambda Expressions
  4. Expression trees can be modified once they are created
  5. All of the Above
Answer: Answer is e
Further Reading:
Useful resources, Expression Trees

  1. They must be inherited from the System.Attribute
  2. Attributes are instantiated at the same time as instances of the class to which they are applied.
  3. Attribute classes may be restricted to be applied only to application element types.
  4. By default, a given attribute may be applied multiple times to the same application element.
Answer: Answer is a, d
Further Reading:
All attribute types derive directly or indirectly from the Attribute class. Attributes can be applied to any target element; multiple attributes can be applied to the same target element; and attributes can be inherited by an element derived from a target element. Use the AttributeTargets class to specify the target element to which the attribute is applied. Useful resources, Attribute Class , Attribute

  1. Use the DataRowCollection.Remove method to immediately delete  the row.
  2. use the DataRowCollection.Remove method to mark the row for deletion when DataRow.AcceptChanges is called.
  3. use the DataRow.Delete method to immediately delete  the row
  4. use the DataRow.Delete method to mark the row for deletion when DataRowAcceptChanges is called.
Answer: Answer is a, d
Further Reading:

  1. It adds properties for direct access to both the Key and the Value
  2. It is optimized to handle the structure of a Dictionary.
  3. It provides properties to determine if the Dictionary is enumerated in Key or Value order
  4. It provides reverse lookup methods to distinguish a Key from a specific Value
Answer: Answer is a
Further Reading:

  1. provide a means to rollback a failed transaction
  2. provide a means to undo a successfully committed transaction later
  3. provide a means to terminate an in process transaction
  4. achieve load balancing by adapting to the current activity
Answer: Answer is b
Further Reading:
Compensation in Windows Workflow Foundation (WF) is the mechanism by which previously completed work can be undone or compensated. Useful resources, Compensation

  1. Restricted to a Specific Application
  2. Restricted to a Specific AppDomain
  3. Restricted to a Specific User
  4. Restricted to a specific Physical Media
Answer: Answer is d
Further Reading:

  1. It provides an exact point in time relative to the UTC time zone
  2. It combines a DateTime structure with a TimeZone structure
  3. It provides arithmetical operations using values with different offsets from the UTC
  4. It can be used to determine the specific TimeZone for a local time
Answer: Answer is a, c
Further Reading:
Useful resources, DateTimeOffsetStructure




  1. Defining methods dynamically.
  2. Defining types dynamically
  3. Defining assemblies dynamically
  4. Defining Instances dynamically
  5. Exporting an executable code to a disk based assembly
Answer: Answer is a, b, c
Further Reading:
Useful resources, System.Reflection.Emit

  1. <exception>
  2. <code>
  3. <summary>
  4. <events>
Answer: Answer is a, b, c
Further Reading:
<events> is not a valid tag. Useful resources, Tags for Documentation Comments

  1. They can be derived from any reference type.
  2. Two anonymous types with the same named parameters in the same order declared in different classes have the same type.
  3. Anonymous types can have methods
  4. All properties of an anonymous type are read/write
Answer: Answer is b
Further Reading:
If two or more anonymous object initializers in an assembly specify a sequence of properties that are in the same order and that have the same names and types, the compiler treats the objects as instances of the same type. They share the same compiler-generated type information.Anonymous types contain one or more public read-only properties. No other kinds of class members, such as methods or events, are valid.Anonymous types are classtypes that derive directly from object, and that cannot be cast to any type except object. From the perspective of the common language runtime, an anonymous type is no different from any other reference type. Useful resources,Anonymous Types

  1. System.Reflection.PropertyInfo
  2. System.Reflection.EventInfo
  3. System.Type
  4. System.Reflection.InstanceInfo
Answer: Answer is a, b, c
Further Reading:

StringBuilder sb = new StringBuilder(10);
sb.AppendFormat("1234567890123");
Console.WriteLine(sb.Capacity);
  1. 10
  2. 20
  3. Some value equal to or larger than 13
  4. Int32.MaxValue
Answer: Answer is b
Further Reading:
Number in parameter denotes the capacity. The capacity parameter defines the maximum number of characters that can be stored in the memory allocated by the current instance. If the number of characters to be stored in the current instance exceeds capacity value, the StringBuilder object allocates additional memory to store them. Useful resources, StringBuilder ClassStringBuilder Constructor

  1. Usage of system settings for size, color, and font
  2. Support for Windows "High Contrast" option
  3. Usage of sound to notify of critical information
  4. Keyboard only access to all features including menus, and controls
Answer: Answer is d

  1. Methods
  2. Properties
  3. Fields
  4. Conversion operators
  5. Events
Answer: Answer is a, b, e
Further Reading:
Useful resources, Interfaces in C#

  1. int
  2. sbyte
  3. long
  4. All of the above
Answer: Answer is d
Further Reading:
By default each element in the enum is int. You can specify another integral numeric type by using a colon. Useful resources, Enumeration typeenum

  1. ASCII
  2. Unicode
  3. UTF-7
  4. UTF-8
  5. EBCDIC
Answer: Answer is e
Further Reading:
Useful resources, Encoding Class

  1. Changes to value parameters always involve making a copy of the original argument
  2. Items passed as Reference Parameters must be initialized prior to the call
  3. Output Parameters do not need to be assigned inside the method
  4. Variable Length argument lists are not supported
Answer: Answer is b
Further Reading:
Useful resources, Passing Parametersoutrefparams




  1. Integral types are considered equal if they represent the same value.
  2. Object types are considered equal if they both refer to the same object or if both are null
  3. String types are considered equal if they have identical lengths and identical characters in each character position
  4. String types are considered equal if they have identical dimensions  and identical content at each array index
Answer: Answer is a, b, c
Further Reading:
Useful resources,Equality Comparisons in C#

  1. Methods
  2. Events
  3. Fields
  4. Indexers
Answer: Answer is c
Further Reading:
Useful resources, Interfaces in C#

  1. The appropriate version of the .NET framework must be installed.
  2. All application components must be in the application directory, or a subdirectory.
  3. Shared components can be installed as part of the XCOPY.
  4. XCOPY deployment to a non-empty target directory may have unintended side-effects
Answer: Answer is c
Further Reading:
Useful resources, xcopy deployment

  1. you should modify the COM component to enable CLR functionallity.
  2. you should use TlbImp.exe to create a managed wrapper
  3. you should use TlbExp.exe to create a managed wrapper
  4. you should enable an unsafe code
Answer: Answer is c
Further Reading:

  1. A while statement will always execute its body at least once.
  2. A for loop will always execute its body at least once.
  3. A try statement must always include at least one catch block
  4. A case clause within a switch statement may not fall through to the next case clause
Answer: Answer is c
Further Reading:
Useful resources, try-catch

  1. The connection to the database must remain valid for the life of the data objects
  2. All tables in a dataset must come from the same database.
  3. A given instance of a DataTable can be in only one DataSet
  4. Changes made to multiple tables within a DataSet can easily be extracted to a new DataSet which contains only the changes
  5. Content from multiple DataSets can easily be combined into a single DataSet that contains the net result of all changes.
Answer: Answer is d, e
Further Reading:

  1. Enums are always equated to an integral constant value
  2. A variable of the enum type will always contain one of the declared symbolic constants
  3. The declared values of an enum are always assigned  sequential starting with 0
  4. The declared values of an enum must be mapped (explicitly or implicitly) to unique integral values
Answer: Answer is a
Further Reading:
By default each element in the enum is int. You can specify another integral numeric type by using a colon. Useful resources, Enumeration typeenum

  1. It is impossible to add a reference to both assemblies to any given assembly
  2. A new root can be added to the assemblies namespace hierarchy by the use of an extern alias
  3. The specific colliding name may be altered by using an extern alias
  4. The collision may be avoided by using a statement to provide an alias
Answer: Answer is c
Further Reading:
Useful resources, extern alias

  1. Static constructors are called before the main program is executed
  2. Static constructors are called before the first instance of a class is created
  3. Static constructors are called before any static (non-constructor) members are called
  4. Static constructors can take parameters
Answer: Answer is b, c
Further Reading:
Useful resources, Static Constructors

  1. A single assembly may contain multiple namespaces
  2. The same namespace may be used in multiple assemblies
  3. Namespaces may be aliased to provide a shorthand notation for a fully qualified identifier
  4. All of the above
Answer: Answer is d
Further Reading:




  1. A delegate requires an instance method be supplied.
  2. A delegate instance may encapsulate only one method
  3. Delegates are not typesafe
  4. A delegate instance does not know or care about the class type of the encapsulated method
Answer: Answer is b
Further Reading:
Useful resources, delegate

  1. They must have the same name
  2. They must have the same parameter signature
  3. They must have the same access level
  4. None of the above
Answer: Answer is a
Further Reading:
Useful resources, method overloading

  1. ObjRef
  2. MarshalByRefObject
  3. ObjectHandle
  4. RemotingServices
Answer: Answer is a
Further Reading:
ObjRef stores all relevant information required to generate a proxy in order to communicate with a remote object.Useful resources, ObjRef Class

  1. Anonymous methods have access to the local state of the containing function member.
  2. An anonymous method requires an explicit method signature
  3. An anonymous method can impact the lifetime of local variables and parameters of the containing function
  4. A struct may not declare an anonymous method which directly references member fields
Answer: Answer is a, c
Further Reading:
Useful resources, Anonymous Methods

  1. Call the Type.MakeGenericType() method on an instance of System.Type which represents the Generic, specifying the types of the generic parameters.
  2. Call the static Type.MakeGenericType(...) method specifying both the base type and the types of the generic parameters.
  3. Call the GetType() method on an instance of the specialization
  4. Call Reflection.Emit()
  5. Call the Type.GetGenericTypeDefinition() method
Answer: Answer is c
Further Reading:

  1. not supported except for implementing an indexer.
  2. properties which take one or more parameters (e.g. to retrieve one element from a member collection)
  3. properties which take one or more parameters (e.g. to retrieve one element from a member collection)
  4. properties which can be passed as Method Parameters so they can be invoked by the called method.
Answer: Answer is a

  1. It provides communication across heterogeneous networks
  2. It provides communication when one of the endpoints may be off-line
  3. It may behave differently depending on the current operating system
  4. A new system level queue may be created simply by creating  an instance of MessageQueue.
Answer: Answer is a, b, c
Further Reading:
Useful resources, MessageQueue class

  1. Identifier
  2. Whitespace
  3. Punctuator
  4. Operator
  5. All of the above
Answer: Answer is a, c, d
Further Reading:
There are several kinds of tokens: identifiers, keywords, literals, operators, and punctuators. White space and comments are not tokens, though they act as separators for tokens. Useful resources, Tokens

  1. Added
  2. Modified
  3. Dirty
  4. Detached
  5. Deleted
Answer: Answer is c
Further Reading:
Useful resources, DataRowState Enumeration

  1. Exceptions should be derived from the System.Exception, but are not required to do so.
  2. If no catch block is found for an exception, and the source is not a static constructor, a System.ThreadException will be thrown
  3. Mathematical errors such as divide by zero, or numeric overflow will generate an exception that is derived from System.Exception
  4. Every throw statement must have at least one catch block
Answer: Answer is c
Further Reading:
Useful resources, Exception




  1. Trace is enabled for both Release and Debug initial configurations
  2. Trace can be controlled both by preprocessor directives, and compiler directives
  3. To change the severity levels which generate output, you must recompile your program
  4. All of the Above
Answer: Answer is a
Further Reading:
Useful resources, Trace Class

  1. #define
  2. #line
  3. #include
  4. #error
  5. #pragma
Answer: Answer is c
Further Reading:
#include is not a valid C# preprocessor directive. Useful resources, C# Preprocessor Directives

  1. public static void Main() {}
  2. public static int Main() {}
  3. public static int Main(string[] args) {}
  4. public static int Main(string cmdline) {}
  5. private static int Main(string[] args) {}
Answer: Answer is d
Further Reading:
Main can either have a void or int return type and it can be declared with or without string[] parameter that contains command line argument. We can’t pass a simple string variable as Main method argument. Useful resources, Main

  1. Assigning a GUID to each exposed interface and implementation via the System.Runtime.InteropServices.GuidAttribute
  2. Enabling an unsafe code
  3. Registering the server assembly  with the system using RegAsm.exe
  4. Registering the server assembly  with the system using RegSvc32.exe
Answer: Answer is a, c
Further Reading:
Useful resources, Managed COM answered by jmsigler2

  1. Start
  2. Continue
  3. Pause
  4. Restart
Answer: Answer is d
Further Reading:
Useful resources, ServiceController Class

  1. C# does not support the use of "*" to indicate a pointer
  2. Pointers are a type derived from System.Object
  3. Pointers can be used as out and ref type parameters
  4. Pointer references are tracked by the garbage collector.
Answer: Answer is c
Further Reading:
Useful resources, Pointer types

  1. separating an item's public interface from the actual implementation
  2. embedding content as a resource into an executable program
  3. providing a short summary description of complex operations
  4. a technique using base and derived classes
Answer: Answer is a

  1. sorted by Key
  2. sorted by Element
  3. not sorted
Answer: Answer is c
Further Reading:
Useful resources, OrderedDictionary Class

  1. class SampleClass 
    {
    } 
    class SampleClass 
    {
    }
    
  2. class SampleClass 
    {
    } 
    class SampleClass<T,U> 
    {
    }
    
  3. class SampleClass where T : class 
    { 
    } 
    class SampleClass where T : struct 
    { 
    }
    
  4. class SampleClass 
    {
    } 
    class SampleClass where T : class 
    { 
    }
    
Answer: Answer is c

  1. One method may handle events from different sources
  2. A single event can be handled by multiple methods
  3. Event handlers can be dynamically added and removed at runtime
  4. Event handlers must be members of the same class as raised the event
  5. All of the above
Answer: Answer is c
Further Reading:
Useful resources, Handling and Raising Events



  1. If a class implements an interface, the implementation can be provided by a public member of a base class
  2. A class may partially implement an interface by only declaring some of the members
  3. Interface methods may be implemented so that they are NOT directly accessible using an instance reference to the class
  4. Since interface implementation methods can not be declared private,protected, or internal, they are always accessible from any point in an application
Answer: Answer is d
Further Reading:
Useful resources, Interfaces

  1. DataContractAttribute
  2. DataMemberAttribute
  3. EnumMemberAttribute
  4. CollectionDataContractAttribute
  5. DataObjectAttribute
Answer: Answer is e
Further Reading:
Useful resources, Serialization

  1. [XmlElement(Namespace:="http://address")]
  2. [XmlElement(ns="http://address")]
  3. [XmlElement(Namespace="http://address")]
  4. None of the above
Answer: Answer is c

  1. Asynchronous pattern decreases the performance of your application
  2. While using asynchronous pattern, you add two methods: StartYourMethod and EndYourMethod (where YourMethod is the actual name of your method)
  3. The "End" method does not require any special attributes
  4. Unless you have a compelling reason to do otherwise, always use the asynchronous pattern when you consume Web services in your production code
  5. All of the above
Answer: Answer is c, d
Share this article :

Post a Comment

 
Copyright © 2014. Mominul's Diary - All Rights Reserved
Developed by Mominul Islam