DotNet using C# MCQs

DotNet using C# MCQs

Our experts have gathered these DotNet using C# MCQs through research, and we hope that you will be able to see how much knowledge base you have for the subject of DotNet using C# by answering these 100+ multiple-choice questions.
Get started now by scrolling down!

1: Which of the following are true about delegates?

A.   A delegate requires an instance method be supplied.

B.   A delegate instance may encapsulate only one method

C.   Delegates are not typesafe

D.   A delegate instance does not know or care about the class type of the encapsulated method

2: Elements in a System.Collections.Specialized.OrderedDictionary are:

A.   sorted by Key

B.   sorted by Element

C.   not sorted 

3: Which System.Runtime.Remoting class is used to store all relevant information required to generate a proxy in order to communicate with a remote object?

A.   ObjRef

B.   MarshalByRefObject

C.   ObjectHandle

D.   RemotingServices

4: Which of the following types are derived from System.Reflection.MemberInfo?

A.   System.Reflection.PropertyInfo

B.   System.Reflection.EventInfo

C.   System.Type

D.   System.Reflection.InstanceInfo 

5: Which of the following is true about exceptions?

A.   Exceptions should be derived from the System.Exception, but are not required to do so.

B.   If no catch block is found for an exception, and the source is not a static constructor, a System.ThreadException will be thrown

C.   Mathematical errors such as divide by zero, or numeric overflow will generate an exception that is derived from System.Exception

D.   Every throw statement must have at least one catch block

6: Parameterized Properties in C# are__________.

A.   not supported except for implementing an indexer.

B.   properties which take one or more parameters (e.g. to retrieve one element from a member collection)

C.   properies which use one or more attributes to control their behavior

D.   properties which can be passed as Method Parameters so they can be invoked by the called method. 

7: Which of the following  is a primary characteristic of System.Xml.XmlDataDocument?

A.   It provides synchronized operations viewing the content either as an XmlDocument or as a DataSet

B.   It provides the basic  abilities for XMLDocument instances to be created from or exported to DataSets

C.   It provides a limited set of capabilities compared to the  System.Xml.XmlDocument class

D.   It provides the basic  abilities to allow DataSets to be loaded from or exported to XML files.

8: Which of the following are true about statements?

A.   A while statement will always execute its body at least once.

B.   A for loop will always execute its body at least once.

C.   A try statement must always include at least one catch block

D.   A case clause within a switch statement may not fall through to the next case clause 

9: Which of the following are true about enums?

A.   Enums are always equated to an integral constant value

B.   A variable of the enum type will always contain one of the declared symbolic constants

C.   The declared values of an enum are always assigned  sequential starting with 0

D.   The declared values of an enum must be mapped (explicitly or implicitly) to unique integral values 

10: Which of the following operations can NOT be performed inside a catch block?

A.   Prevention of the caught exception from leaving the catch block

B.   Allowing the original exception to propagate after it has been caught, with all of the information (including context) intact

C.   Wrapping the caught exception inside a newly created exception of a different type

D.   Generating a new exception with no information about the original exception

E.   Altering the Message , TargetSite and/or StackTrace, of the existing exception before re-throwing

11: Which of the following is an effect of marking resources in satellite assemblies?

A.   It renders the resources unavailable.

B.   It ensures that resources are used only with the appropriate culture

C.   It prevents identifier collisions between multiple satellite assemblies

D.   It has no impact since access specifiers for resources are not applied.

12: Which of the following are true about pointers?

A.   C# does not support the use of "*" to indicate a pointer.

B.   Pointers are a type derived from System.Object

C.   Pointers can be used as out and ref type parameters

D.   Pointer references are tracked by the garbage collector.

13: Which of the following is not a valid value for DataRowState?

A.   Added

B.   Modified

C.   Dirty

D.   Detached

E.   Deleted

14: Which of the following can an interface NOT contain?

A.   Methods

B.   Events

C.   Fields

D.   Indexers 

15: Which of the following code samples will cause a compilation error?

A.   class SampleClass {}
class SampleClass<T> {}

B.   class SampleClass<T> {}
class SampleClass<T,U> {}

C.   class SampleClass<T> where T : class { }
class SampleClass<T> where T : struct { }

D.   class SampleClass {}
class SampleClass<T> where T : class { }

16: Which of the following applies to interface inheritance?

A.   If a class implements an interface, the implementation can be provided by a public member of a base class.

B.   A class may partially implement an interface by only declaring some of the members

C.   Interface methods may be implemented so that they are NOT directly accessible using an instance reference to the class

D.   Since interface implementation methods can not be declared private,protected, or internal, they are always accessible from any point in an application 

17: Which of the following is NOT part of an assembly?

A.   Manifest

B.   MetaData

C.   Intermediate Language Code

D.   Resources

E.   Native Executable Code 

18: Which of the following are true about operator precedence?

A.   The Conditional Operator (?:) has the lowest precedence.

B.   All binary operators are left-associative, and evaluate from left to right.

C.   The Assignment and Conditional Operators are right-associative.

D.   The Conditional And (&&) and Or (||) operators have higher precedence than the Logical And (&) and Or (|) operators. 

19: Which of the following are defined as a "token"?

A.   Identifier

B.   Whitespace

C.   Punctuator

D.   Operator

E.   All of the above

20: Which of the following is NOT a valid C# preprocessor directive?

A.   #define

B.   #line

C.   #include

D.   #error

E.   #pragma 

21: Which of the listed characteristics is found in the following code sample?
[DllImport("msvcrt.dll")]
public static extern int puts([MarshalAs(UnmanagedType.LPStr)]  string m);

A.   It physically includes the native code for puts in the current assembly

B.   It generates a wrapper class for the puts method

C.   It provides sufficient information so the Platform Invoke functionality can  be used to call the function in the msvcrt.dll

D.   It enables an unsafe code 

22: Which of the following are true about namespaces and assemblies?

A.   A single assembly may contain multiple namespaces

B.   The same namespace may be used in multiple assemblies

C.   Namespaces may be aliased to provide a shorthand notation for a fully qualified identifier

D.   All of the above

23: Which of the following conditions are true regarding System.Diagnostics.Trace?

A.   Trace is enabled for both Release and Debug initial configurations

B.   Trace can be controlled both by preprocessor directives, and compiler directives

C.   To change the severity levels which generate output, you must recompile your program

D.   All of the Above

24: Which of the following encodings are NOT supported by classes in the System.Text namespace?

A.   ASCII

B.   Unicode

C.   UTF-7

D.   UTF-8

E.   EBCDIC 

25: Which of the following are true about event handling?

A.   One method may handle events from different sources

B.   A single event can be handled by multiple methods

C.   Event handlers can be dynamically added and removed at runtime

D.   All of the above

26: Which of the following is false regarding arrays?

A.   For reference types A and B; if a conversion from A to B exists, a conversion from A[] to B[] also exists

B.   For value types A and B; if a conversion from A to B exists, a conversion from A[] to B[] also exists

C.   Assignments to arrays elements may require a runtime check to validate the type safety of the assignment

27: Which of the following are true about using the System.Messaging.MessageQueue class?

A.   It provides communication across heterogeneous networks

B.   It provides communication when one of the endpoints may be off-line

C.   It may behave differently depending on the current operating system

D.   A new system level queue may be created simply by creating an instance of MessageQueue.

28: Transactions initiated in which of the following are supported by System.Transactions infrastructure?

A.   SQL Server

B.   ADO.NET

C.   MSMQ

D.   Microsoft Distributed Transaction Coordinator (MSDTC).

E.   All of the above 

29: Which of the following are true when comparing built in types for equality?

A.   Integral types are considered equal if they represent the same value.

B.   Object types are considered equal if they both refer to the same object or if both are null

C.   String types are considered equal if they have identical lengths and identical characters in each character position

D.   String types are considered equal if they have identical dimensions  and identical content at each array index

30: Which of the following is NOT a requirement for an application to be certified in the "Certified for Windows Program"?

A.   Usage of system settings for size, color, and font

B.   Support for Windows "High Contrast" option

C.   Usage of sound to notify of critical information

D.   Keyboard only access to all features including menus, and controls 

31: Which of the following are true for parameters?

A.   Changes to value parameters always involve making a copy of the original argument

B.   Items passed as Reference Parameters must be initialized prior to the call

C.   Output Parameters do not need to be assigned inside the method

D.   Variable Length argument lists are not supported

32: Which of the following is not a standard service behavior supported by the System.ServiceProcess.ServiceController class members?

A.   Start

B.   Continue

C.   Pause

D.   Restart 

33: Which of the following characteristics are found in an iterator?

A.   It is a statement block which may contain a yield return statement to provide the next value of the iteration

B.   It is a statement block which may contain a yield break statement to provide the next value of the iteration

C.   It is a statement block which may contain a yield return statement to indicate that the iteration is complete

D.   It is a statement block which may contain a yield break statement to indicate that the iteration is complete

E.   It is a class which implements Ienumerable 

34: Which of the following are valid as the underlying type for an enumeration?

A.   int

B.   sbyte

C.   long

D.   All of the above

35: Which of the following are typical steps in creating a managed COM server component?

A.   Assigning a GUID to each exposed interface and implementation via the System.Runtime.InteropServices.GuidAttribute

B.   Enabling an unsafe code

C.   Registering the server assembly with the system using RegAsm.exe

D.   Registering the server assembly with the system using RegSvc32.exe

36: Which of the following characteristics is found in The DateTime type?

A.   It always references the UTC (GMT) time

B.   It always references the Local  time

C.   It contains a member indicating which time zone it refers to

D.   It contains a member indicating whether it is UTC, Local, or Unspecified

37: Which of the following does NOT apply to XCOPY deployment?

A.   The appropriate version of the .NET framework must be installed.

B.   All application components must be in the application directory, or a subdirectory.

C.   Shared components can be installed as part of the XCOPY.

D.   XCOPY deployment to a non-empty target directory may have unintended side-effects 

38: The term Encapsulation is most commonly used to mean:

A.   separating an item's public interface from the actual implementation

B.   embedding content as a resource into an executable program

C.   providing a short summary description of complex operations

D.   a technique using base and derived classes 

39: When developing a managed client to be used with an existing COM Component, __________.

A.   you should modify the COM component to enable CLR functionallity.

B.   you should use TlbImp.exe to create a managed wrapper

C.   you should use TlbExp.exe to create a managed wrapper

D.   you should enable an unsafe code 

40: If two assemblies contain the same fully qualified class, which of the following will be true?

A.   It is impossible to add a reference to both assemblies to any given assembly

B.   A new root can be added to the assemblies namespace hierarchy by the use of an extern alias

C.   The specific colliding name may be altered by using an extern alias

D.   The collision may be avoided by using a statement to provide an alias 

41: Which of the following can Interfaces contain?

A.   Methods

B.   Properties

C.   Fields

D.   Conversion operators

E.   Events

42: Which of the following properties are found in Static Constructors?

A.   Static constructors are called before the main program is executed

B.   Static constructors are called before the first instance of a class is created

C.   Static constructors are called before any static (non-constructor) members are called

D.   Static constructors can take parameters

43: Which of the following is not a valid attribute for impacting serialization?

A.   DataContractAttribute

B.   DataMemberAttribute

C.   EnumMemberAttribute

D.   CollectionDataContractAttribute

E.   DataObjectAttribute 

44: Which of the following is not an application entry point?

A.   public static void Main() {}

B.   public static int Main() {}

C.   public static int Main(string[] args) {}

D.   public static int Main(string cmdline) {}

E.   private static int Main(string[] args) {} 

45: Which of the following can one perform to create a System.Type instance for a given specialization of a generic?

A.   Call the Type.MakeGenericType() method on an instance of System.Type which represents the Generic, specifying the types of the generic parameters.

B.   Call the static Type.MakeGenericType(...) method specifying both the base type and the types of the generic parameters.

C.   Call the GetType() method on an instance of the specialization

D.   Call Reflection.Emit()

E.   Call the Type.GetGenericTypeDefinition() method 

46: What output will be generated by the following code?
StringBuilder sb = new StringBuilder(10);
sb.AppendFormat("1234567890123");
Console.WriteLine(sb.Capacity);

A.   10

B.   20

C.   Some value equal to or larger than 13

D.   Int32.MaxValue 

47: Which of the following will be executed without error?
Public Class Fruit
End Class
Public Class Apple
    Inherits Fruit
End Class

A.   Dim list As New List(Of Fruit)
        list.Add(New Apple)
        list.Add(New Fruit)

B.   Dim list As New List(Of Fruit)
        list.Add(New Apple)
        list.Add(New Fruit)

C.   Dim list As New List(Of Apple)
        list.Add(New Apple)
        list.Add(New Fruit)

D.   Dim list As New List(Of Apple)
        list.Add(New Apple)
        list.Add(New Fruit)

48: Given the following code, which calls will be valid ways to add the elements of a string array to a List(Of String)?
        Dim values() As String = {"1", "2", "3", "4"}
        Dim valueList As New List(Of String)

A.   valueList.Insert(values)

B.   valueList = values

C.   valueList.Add(values)

D.   valueList.AddRange(values)

49: What is the value of b3 after the following code is executed?
Dim b1 As Boolean? = True
Dim b2 As Boolean? = Nothing
Dim b3 As Boolean? = IIf(b1 AndAlso b2, b1, b2)

A.   System.DbNull.Value

B.   TRUE

C.   FALSE

D.   Nothing

E.   None of the above (An InvalidCastException is thrown) 

50: Which of the following are valid means of reading all data from a file into a string?

A.   Dim sr As New System.IO.StreamReader("C:\temp\myfile.txt")
        Dim s As String = sr.ReadLine

B.   Dim sr As New System.IO.StreamReader("C:\temp\myfile.txt")
        Dim s As String = sr.Read

C.   Dim sr As New System.IO.StreamReader("C:\temp\myfile.txt")
        Dim s As String = sr.ReadAll

D.   Dim s As String = My.Computer.FileSystem.ReadAllText(