0% found this document useful (0 votes)
150 views

C# Question Bank and More

The document contains a bank of 35 multiple choice questions related to C#. Key topics covered include: 1. Overloading methods in C# and interface accessibility modifiers. 2. Inheritance, polymorphism, and the base Object class in .NET. 3. Constructors, properties, events, and delegates. 4. Namespaces, assemblies, and memory management features like boxing. The majority of the questions have a single correct multiple choice answer related to C# concepts and .NET fundamentals.

Uploaded by

Vũ Nam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
150 views

C# Question Bank and More

The document contains a bank of 35 multiple choice questions related to C#. Key topics covered include: 1. Overloading methods in C# and interface accessibility modifiers. 2. Inheritance, polymorphism, and the base Object class in .NET. 3. Constructors, properties, events, and delegates. 4. Namespaces, assemblies, and memory management features like boxing. The majority of the questions have a single correct multiple choice answer related to C# concepts and .NET fundamentals.

Uploaded by

Vũ Nam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

C# QUESTIONS BANK

1. How can you overload a method?

Select Answer :

1. Different parameter data types


2. Different number of parameters
3. Different order of parameters
4. All of the above

Answer : 4

2. What is the accessibility modifier for methods inside the interface?

Select Answer :

1. Private by default
2. Public by default
3. protected
4. Friend

Answer: 2

3. What’s the top .NET class that everything is derived from ?

Select Answer:

1. System.Net.All
2. System.IO
3. System.Collections
4. System.Object

Answer: 4

4. What does the keyword virtual mean in the method definition?

Select Answer :
1. Overload
2. Virtual
3. Imaginary
4. Overridden

Answer: 4

5. C# provides a default constructor for me. I write a constructor that takes a string as a
parameter, but want to keep the no parameter one . How many constructors should I write?

Select Answer :

1. One
2. Two
3. Three
4. None of the above

Answer: 2

6. Does C# support multiple inheritance?

Select Answer :

1. Yes
2. Partially
3. No
4. None of the above

Answer: 3

7. How do you inherit from a class on C#?

Select Answer:

1. Place a semicolon and then the name of the base class


2. Place a dot and then the name of the base class
3. Place a scope resolution and then the name of the base class
4. Place a colon and then the name of the base class

Answer: 4

8. What’s the implicit name of the parameter that gets passed in to the class’ set method?
Select Answer :

1. value
2. Datatype
3. value and its datatype
4. none of the above

Answer: 3

9. How can you sort the elements of the array in descending order?

Select Answer :

1. Desc()
2. ASCReverse()
3. By calling Sort() and then Reverse() methods
4. By calling ascen() and then Reverse() methods

Answer: 3

10. Can you override private virtual methods?(no private virtual)

Select Answer:

1. Yes
2. No
3. Either 1 or 2
4. None

Answer : 2

11. What is a delegate?

Select Answer :

1. A Strongly typed function pointer


2. A light weight thread or process that can call a single method
3. A reference to an object in a different process
4. An inter-process message channel

Answer: 1

12. What is boxing in .net ?


Select Answer :

1. Encapsulating an object in a value type.


2. Encapsulating a copy of an object in a value type
3. Encapsulating a value type in an object
4. Encapsulating a copy of a value type in an object

Answer: 4

13. Which of these string definitions will prevent escaping on backslashes in C#?

Select Answer :

1. string s = #”n Test string”;


2. string s = “n Test string”
3. string s = @”n Test string”
4. string s = “n Test string”;

Answer: 3

14. The C# keyword ‘int’ maps to which .NET type ?

Select Answer :

1. System.Int16
2. System.Int32
3. System.Int64
4. System.Int128

Answer: 2

15. Loading of .Net Assembly in Windows 98/ME is different than execution in Windows XP.

Select Answer :

1. Yes
2. No
3. Cant say

Answer: 1

16. Which program control statements aways executes the internal statements at least once?

Select Answer :
1. do{Statements}j=j+1;
2. if(j!=1){Statements} j = j+1;
3. while(j!=1){Statements} j=j+1;

Answer: 1

17. Which is the default interface for any COM component?

Select Answer :

1. Iunknown
2. IEnumerable
3. Enumerator
4. Idisposable

Answer: 1

18. Which interface allows a collection to be navigated using the foreach statement?

Select Answer :

1. IEnumerable
2. IUnknown
3. IEnumerator
4. Idisposable

Answer: 1

19. Term for the process by which the Runtime uses to find an assembly?

Select Answer :

1. Searching
2. Probing
3. Sorting
4. Caching
5. Bubbling

Answer: 2

20. Difference between the C# statements “catch(Exception ex),-” and “catch,-”?

1. A try statement can only have one catch{} statement(general catch clause)
2. general clause; if one is present it must be the last catch clause
3. general clause ; may also catch exceptions from other languages
4. “catch(Exception ex),-” is more powerful
5. 1,2&3

Answer: 5

21. If a method is marked as protected internal who can access it?

Select answer :

1. Classes that are both in the same assembly and derived from the declaring class.
2. Only methods that are in the same class as the method in question
3. Internal methods can be only be called using reflection
4. Classes within the same assembly, and classes derived from the declaring class

Answer: 4

22. Which of these statements correctly declares a two-dimensional array in C# ?

Select Answer :

1. int[,] myArray;
2. int[][] myArray;
3. int[2] myArray;
4. System.Array[2] myArray;

Answer: 1

23. Is it possible to restrict the scope of a field/method of a class to the classes in the same
namespace?

Select Answer :

1. There is no way to
2. restrict to a namespace. Namespaces are never units of protection
3. But if you’re using assemblies, you can use the ‘internal’
4. access modifier to restrict access to only within the assembly

Answer: 1

24. Is it possible to have different access modifiers on the get/set methods of a property?

Select Answer :

1. No. The access modifier on a property applies to both its get and set accessors
2. What you need to do if you want them to be different is make the property read –only(by
only providing a get accessor) and create a private/internal set method that is separate from
the property

Answer: 1

25. Is it possible to have a static indexer in C#?

Select Answer :

1. No. Static indexers are not allowed in C#?


2. Yes
3. Depend on some conditions.
4. I don’t know.

Answer: 1

26. For which of the following protocols is The Internet Transfer control used ?

Select Answer :

1. TCP only
2. FTP and TCP
3. FTP and IPX
4. HTTP and TCP
5. FTP and HTTP

Answer: 1

27. How do you retrieve the value of the Name property ?

Scenario : A public string property called Name has been added to class called Employee

Select Answer :

1. Person.Name
2. Employee!Person.Name
3. Person ->Name
4. Person(“Name”)
5. Employee.Name

Answer: 1

28. Event handing in .NET is handled by which feature


Select Answer :

1. Reflection
2. Remoting
3. Delegates
4. web service

Answer: 3

29. What is the value for I ?

Int i=0;

While(i++<10)

Console.WriteLine(“i=”+i);

Select Answer :

1. Compile Error
2. Runtime Error
3. 10
4. 11
5. None of the above

Answer: 4

30. What is the term for assemblies that are marked for aspecific culture via their
AssemblyCultureAttribute?

1. Global assemblies
2. Satellite assemblies
3. Universal assemblies
4. Dynamic assemblies

Answer: 1

31. Which one of the following is the term used to describe the basic unit of deployment and
versioning in the .NET Framework?

Select Answer :

1. Library
2. Managed Module
3. .NET Portable Executable (PE) file
4. Assembly

Answer: 4

32. Which one of the following statements is true about events and delegates ?

Select Answer :

1. Events must know what object handles its event


2. An event can only have one event handler
3. Delegates are not type – safe
4. A delegate can only hold methods that match the delegate’s method signature

Answer: 4

33. What is the format of assembly version number ?

Select Answer :

1. Major.Minor.Build.Revision
2. Revision.Major.Minor.Build
3. Major.Minor.Revision.Build
4. Build.Major.Minor.Revision
5. Minor.Build.Major.Revision

Answer: 3

34. C# supports Inheritance

Select Answer :

1. Yes
2. No
3. Some Time
4. Don’t know

Answer: 1

35. Can we have data members inside an interface ?

example:

interface ISample
{

int sample ;

void DisplaySample();

Is this a valid syntax

Select Answer :

1. No, We cannot have datamembers inside an interface.However, we can have properties.


2. No, We cannot have datamembers or properties inside an interface
3. Yes, the above example is valid
4. Yes, this is valid in c#. But not in VB.Net

Answer: 1

36. A class can inherit from how many interfaces?

Select Answer :

1. only one
2. two
3. ten
4. any number

Answer: 4

37. What is difference between Interface and abstract class

Select Answer :

1. Both are same


2. unlike interface abstracts class have no implementation
3. interface require inheritance

Answer: 2

38. What will the following code print ?

public interface Employee


{

int GetSalary();

void GiveRaise(int amount);

public struct Clerk : Employee

private int salary;

public Clerk(int salary)

this.salary = salary;

public int GetSalary()

return salary;

public void GiveRaise(int amount)

salary+= amount;

class Test

static void Main(string[] args)

Clerk c= new Clerk(1000);


((Employee)c).GiveRaise(50);

System.Console.WriteLine(c.GetSalary());

Select Answer :

1. We will get a runtime error


2. We will get a compilation error
3. 1050
4. 1000

Answer: 4

39. What output would you expect from the following code ?

Using System;

Class A

public virtual void F()

Console.Write(“A”);-

class B : A

public override void F()

,Console.Write(“B”);-

class C : B

new public virtual void F()


,Console.Write(“C”);-

class D:C

public override void F()

,Console.Write(“D”);-

class Test

static void Main()

D d =new D();

A a = d;

B b =d ;

C c =d;

a.F();

b.F();

c.F();

d.F();

Select Answer :

1. BBDD
2. BBCD
3. ABCD
4. ABBC
Answer: 1

40. Threads are :

Select Answer :

1. static methods
2. objects
3. instance methods
4. events

Answer: 2

41. What is the printout of the following ?

byte b1 =1;

byte b2 = 255;

byte total = b1+b2;

Console.WriteLine(total);

Select Answer :

1. We will get a runtime error


2. We will get a compilation err
3. 256
4. 1

Answer: 2

42. Are private class- level variables inherited?

Select Answer :

1. No, Not at all


2. At times, based on the namespace
3. Yes, but they are not accessible
4. No idea

Answer: 3

43. Multiple data type store in a System.Array?

Select Answer :
1. Yes
2. No
3. I don’t know
4. All the above

Answer: 2
44. What are interface class?

Select Answer :

1. Implemented in inherited class


2. Not implemented in inherited class
3. Public abstract methods defined in abstract class must be implemented in inherited class
4. All the above

Answer: 3
45. Will finally block get executed if the exception had not occurred ?

Select Answer :

1. No
2. Yes
3. Both
4. I don’t know

Answer: 2

46. Which is the main CLR System assembly which contains the classes for built – in CLR types?

Select Answer :

1. base
2. mscorlib
3. 1&2
4. none

Answer: 2
47. What is the output of following c# code ?

Using System;

Class MainClass

MainClass(Pointer argPointer, int aNumber)

{
Console.WriteLine(new Pointer()argPointer)(aNumber) -1);

delegate int Pointer (int aVar);

static int Increment (int aNumber)

Console.Write(aNumber);

Return aNumber+1;

static void Main()

new MainClass(new Pointer(Increment),new Pointer(Increment)(35));

Select Answer :

1. 363536
2. 353637
3. 353536
4. 373635
5. 353636
Answer: 5

48. Which language supports operator overloading in .net

Select answer :

1. vb.net
2. c#
3. JScript.net
4. j#.net

Answer: 2
49. In C# properties and methods are non – virtual by default, which means they can’t be
overridden in a derived class
Select Answer :

1. true
2. false

Answer: 1
50. What is the default initial capacity of a hashtable?

Select answer :

1. 16
2. 0
3. 24
4. -1

Answer: 2
51. What would be the output of the following program?

ArrayList myArrayList = new ArrayList();

myArrayList.TrimToSize();

Console.WriteLine(myArrayList.Capacity.ToString());

Select Answer :

1. 16 (*)
2. 0
3. ArgumentNullException, since the ArrayList contains no values

Answer: 1

52. Predict the output.

ArrayList myArrayList = new ArrayList();

myArrayList.Add(“Thank you”);

myArrayList.Add(“For”);

myArrayList.Add(“Visiting”);

string mySTring = “\””;

Console.WriteLine(myArrayList.LastIndexOf(myString).ToString());

Select Answer :
1. 0
2. 1
3. -1
4. ArgumentNullException

Answer: 3

53. If my ArrayList is an ArrayList with the element “1” and myQueue is a Queue with the
element “A”, what would be the output of the following program?

myArrayList.AddRange(myQueue);

foreach(string s in myArrayList)

Console.Write(s+”,”);

Select Answer :

1. 1, A
2. A,1
3. A
4. 1

Answer: 1

54. Each time an ArrayList is enlarged, how is its capacity affected?

Select answer :

1. The capacity remains unchanged


2. The capacity is doubled
3. The capacity is tripled
4. The capacity is quadrupled

Answer: 2

55. What would be the output of the following program?

ArrayList myArrayList = new ArrayList();

Console.WriteLine(myArrayList.Capacity.ToString());

Select answer :

1. Ten
2. Twelve
3. Fourteen
4. Sixteen
Answer: 4

56. How many classes can a single .NET DLL contain?

Select answer :

1. 1
2. many
3. 4
4. 5

Answer: 2

57. What is a satellite Assembly?

Select Answer :

1. Any DLL file used by an EXE file .


2. An assembly containing localized resources for another assembly
3. An assembly designed to alter the appearance or ‘skin ’ of application
4. A peripheral assembly designed to monitor per missions requests from an application

Answer: 2

58. How does VB.NET/C# achieve polymorphism

Select answer :

1. By Incapsulation
2. By Main function
3. By using Abstract classes/functions
4. By Using Implementation

Answer: 3

59. In Object Oriented Programming , how would you describe encapsulation?

Select answer :

1. The exposition of data


2. The runtime resolution of method calls
3. The separation of interface and implementation
4. The conversion of one type of object to another.

Answer: 3

60. How does assembly versioning in .NET prevent DLL Hell?


Select answer :

1. The compiler offers compile time checking for backward compatibility


2. The runtime checks to see that only one version of an assembly is on the machine at any
one time
3. .NET allows assemblies to specify the name AND the version of any assemblies they need to
run
4. All Above

Answer: 3

61. What will be the output of the code :

int i = new byte();

string str;

i =2005;

str = “This is Year”;

str = str+i;

Console.WriteLine(str);

Select answer :

1. Compile time error – Cannot implicitly convert type ‘byte’ to ‘int’


2. Compile time error – Cannot convert from int to string
3. Run time error – Invalid Cast
4. This is Year 2005

Answer: 4

62. What is the output of the following ?

Byte a = 5 ;

Byte b = 255;

Byte total a+b ;

Console.WriteLine(total);

Select answer :

1. 260
2. 1
3. Run –time error
4. Compilation Error

Answer: 4

63. Choose the best choice for satellite assembly

Select answer :

1. COM + component
2. A .Net DLL
3. .Net executable file contains user interface text information

Answer: 3

64. What if you compare Null against Null

Ex :

if NULL = NULL

[True Part]

Else

[False Part]

Select answer :

1. True
2. False
3. Fatal Error

Answer: 1

65. What is the output of the following snippet in c#?

Using System :

Class main

static long afield = 123 ;

static main()

{
Console.WriteLine(afield);

main()

afield = 1000;

Console.WriteLine(afield);

static void Main(String[] args)

main obj = new main();

Select answer :

1. 1000 123
2. 123
3. no output
4. 123 1000

Answer: 4

66. Which is the correct statement in the following to set the alias name for namespace in C#?

Select Answer :

1. using System Data.OracleClient = aliasName;


2. using aliasName = System.Data.OracleClient ;
3. string aliasName = using.System.Data.OracleClient ;
4. both 1 & 2
5. both 2 & 3

Answer: 2

67. Which Class can not be inherited ?

Select answer :
1. Virtual Class
2. Sealed Class
3. Abstract Class
4. Final Class

Answer: 2

68. What is the output of following C# code ?

Using System ;

Class AClass

ushort aField;

public AClass(ushort aField)

Console.Write (this.aField = aField);

Class MainClass

static void Main()

AnObj = new AClass(44);

AClass AnObj = new AClass(33);

Select Answer :

1. 33
2. Syntax Error *Cannot access ‘AnObj’ in ‘static void Main()’+
3. 44
4. 3344
5. 4433
Answer: 2

69. What is the output of following C# code ?

Class AClass

sbyte aField ;

public AClass (sbyte aField)

this.aField = aField;

System.Console.Write(aField);

class MainClass

AClass Third = new AClass(8);

static void Main()

static AClass Second = new AClass(7);

select answer :

1. 7
2. 8
3. 78
4. 87
5. No output

Answer: 1
70. Which of the following are/is value type datatypes of C#?

Select answer :

1. String
2. Object
3. Struct
4. 1&2
5. All

Answer: 3

71. What is the output of following C# code ?

Class AClass

sbyte aField ;

public AClass(sbyte aField)

this.aField = aField;

System.Console.Write(aField);

class MainClass

static void Main(){}

static MainClass()

First = new AClass(5);

AClass Third = new AClass(9);


static AClass First = null;

static AClass Second = new AClass(- 2);

Select answer :

1. 5-2
2. 5-29
3. -25 (*)
4. -259
5. -295

Answer: 3

72. Which operating system has the .NET Framework and Common Language Runtime(CLR)
natively installed?

Select answer :

1. Windows .NET Enterprise Servers


2. Windows XP Professional
3. Windows XP Home Edition
4. Windows 9x
5. Windows 2000

Answer: 2

73. From which one of the following locations does the garbage collector remove objects?

Select answer :

1. The download cache


2. The global assembly cache
3. The thread stack
4. The managed heap
5. The system registry

Answer: 4

74. Whether the following code will execute perfectly or not?

Static void Main(string[] args)

int i = 10 ;
try

Console.Write(“I= ”+ i);

catch(Exception ex)

Console.WriteLine(ex.Message);

finally

return;

Select answer :

1. yes
2. No

Answer: 1

75. Choose the correct differentces between a class and a structure from the following

Select answer :

1. Classes are reference types and structures are value types


2. Classes are value types and structures are reference types
3. The instance data for classes is allocated on heap and that of structures is allocated on stack
4. 1 &3
5. 2&3

Answer: 4

76. Which of the following is a valid statement ?

Select answer :
1. I = Integer.Parse(S)’Where I is an integer and S is a string
2. I = Parse(S)’Where I is an integer and S is a string
3. S = Parse(I)’Where I is an integer and S is a string
4. None

Answer: 1

77. The implicit conversion of value types to reference types is called

Select Answer :

1. Parsing
2. Boxing
3. Buffering
4. None

Answer: 2

78. The following namespace facilitates file access in .net

Select Answer :

1. System.file
2. System.FileIO
3. System.IO
4. System.Access

Answer: 3

79. When creating an array of reference types , declaring and initializing an array implies

Select answer :

1. an array is created that is filled with members of that type


2. an array of null references is created that can point to that type
3. array of new object is created
4. None of the above

Answer: 2

80. What is the output of following C# code?

class MainClass

static long afield = 1212;


static MainClass()

{ System.Console.Write(aField);

MainClass()

aField = 1000;

System.Console.Write(aField);

static void Main()

Select answer :

1. 1212
2. 1000
3. No output
4. Syntax Error*Class MainClass already defines a member ‘MainClass()’+
5. Syntax Error *No executable statements in entry point ‘Main()’+

Answer: 1

81. What is the output of following C# code ?

Class MainClass

static MainClass()

System.Console.Write(“Static ”);

public MainClass()
{

System.Console.Write(“Instance”);

class AClass

static void Main()

new MainClass();

Select answer :

1. Syntax Error *ambiguous call’static MainClass()’ and ‘MainClass()’+


2. Instance
3. Static
4. Instance Static
5. Static instance

Answer: 5

82. What is the output of following C# code?

class MainClass

static void Main()

int i = 10 ;

uint j =2 ;

i = i + j;

System.Console.Write(i);

}
}

Select Answer :

1. Throws ‘InvalidCastException’
2. 12
3. Syntax Error*Cannot implicitly convert type ‘long’ to ‘int’+
4. Syntax Error *Cannot implicitly convert type ‘int’ to ‘uint’+
5. Syntax Error *Cannot implicitly convert type ‘uint’ to ‘int’+

Answer: 3

83. What is the output of following C# code ?

Class MainClass

static void Main()

int I = 10;

uint j =2;

i+ = j;

System.Console.Write(i);

Select Answer :

1. Throws ‘InvalidCastException’
2. 12
3. Compiler Warning [Cannot implicitly convert type ‘int ’ to ‘uint’+
4. Syntax Error *Cannot implicitly convert type ‘int’ to ‘uint’+
5. Syntax Error *cannot implicitly convert type ‘uint’ to ‘int’+

Answer: 5

84. What is the C# equivalent of System.Single?

Select answer :

1. float(16 -bit)
2. float(32 -bit)
3. float(64 - bit)
4. float(128 -bit)
5. decimal(128 - bit)

Answer: 2

85. Which data type has maximum level of precision?

Select answer :

1. System.Float
2. System.Single
3. System.Decimal (*)
4. System.Double
5. System.Real

Answer: 3

86. What is the default value of System.Boolean?

Select answer :

1. false in C# (False in VB.NET )


2. true in C# (True in VB.NET)
3. No default value
4. 0
5. null in C#(Nothing in VB.NET)

Answer: 1

87. If a method is marked as protected internal who can access it?

Select Answer :

1. Classes that are both in the same assembly and derived from the declaring class
2. Only methods that are in the same class as the method in question
3. Internal methods can be only be called using reflection
4. Classes within the same assembly, and classes derived from the declaring class

Answer: 4

88. What is the output of following C# code?

using System;

class MainClass
{

static void Main()

Console.Write(“,0-,1-,2-,3-”,true^true,true^false, false^true,false^false);

Select answer:

1. True false false True


2. False True True True
3. True False False False
4. True True True False
5. False True True False

Answer: 5

89. What is the default datatype of enumeration constants ?

Select Answer :

1. System.Byte
2. System.Int 16
3. System.Int 32
4. System.Int 64
5. System.Int 128

Answer: 3

90. Which of the following statements are wrong ?

A static modifier can be used with events.

B static modifier can be used with types

C static modifier can be used with indexers

D static modifier can be constructors

E static modifier can be used with destructors

F static modifier can be used with local variables declared within a method
Select answer :

1. Only B,C,E & F


2. Only A,D,E & F
3. Only B,D,E & F
4. Only C,D,E& F
5. Only D, E & F

Answer: 1

91. What are the access levels of MainClass and innerClass?

class MainClass

class InnerClass

Select answer :

1. public and private


2. public and public
3. public and protected
4. private and private
5. public and internal

Answer: 1

92. What is the access level of InnerClass?

Internal class MainClass

public class InnerClass

}
}

Select answer :

1. private
2. public
3. protected
4. internal
5. protected internal

Answer: 4

93. What is the output of following C# code?

Class MainClass

static void Main()

{ System.Console.Write((int)(Vibgyor.Red));

enum Vibgyor : byte

Red,

Violet,

Indigo,

Blue,

Green,

Yellow,

Orange = 255,

Select answer :

1. 0
2. 256
3. Syntax Error *enumerator value ‘Vibgyor.Red’ is too large to fit in its type+
4. Syntax Error *cannot cast ‘vibgyor.Red’ to ‘int’+
5. 1

Answer: 1

94. Which of A,B,C,D,E is/are wrong ?

A.

static int Main(string []args)

//block of statements

return (0);

B.

static void Main()

//block of statements

return ;

C.

static int Main()

//block of statements

return 1;

D.

static uint Main(string []str)


{

//block of statements

return 0;

E.

Static public void Main(System.String [] s)

//block of statements

Select answer :

1. D& E
2. D
3. A& C
4. B
5. A&D

Answer: 2

95. Work Order of Garbedge Collector(GC) in .NET ?

Select answer :

1. Mark - >Generation -> Compact - > Allocation


2. Compact ->Allocation - > Mark -> Generation
3. Generation -> Allocation -> Mark -> Compact
4. Allocation - > Mark -> Generation - > compact
5. None

Answer: 4

96. Arrays in C# are of which type

Select answer :

1. Value type
2. Reference type
Answer: 2

97. We can make a property Write – only , by

Select answer :

1. Removing Set accessor


2. Removing Get accessor

Answer: 2

98. We can make a property read – only by

Select answer :

1. Removing Set accessor


2. Removing Get accessor

Answer: 1

99. Advantages of writing a managed code application instead of unmanaged code application

Select answer :

1. Automatic garbage collection


2. Memory management
3. Support for versioning and Security
4. None of the first above three answer
5. All of the first above three answer

Answer: 5

100. In which assembly does a Strong Name is required?

Select answer :

1. Private Assembly
2. Shared Assembly
3. Can be used in both Private and Shared Assembly
4. In Private assembly but with certain conditions
5. In Shared assembly but with certain conditions

Answer: 2

101. In C# single line comments are implemented by


Select answer:

1. !—Data
2. //Data
3. /*Data
4. –Data

Answer: 2

102. In C# multiline comments are implemented by

Select answer :

1.
2. //Data//
3. /*Date*/
4. Data-->

Answer: 3

103. A null value is an Empty value

Select answer:

1. True
2. fasle
3. Not a relevant comparison

Answer: 2

104. A null is equal to only another null

Select answer:

1. True
2. False
3. Not a relevant comparison

Answer:

105. The Basic Object – Oriented Concepts are

Select Answer :

1. Abstraction, Encapsulation, OverLoading, Overriding


2. Abstraction, Encapsulation, Overriding, Inheritance
3. Abstraction, Encapsulation, Polymorphism, Inheritance
4. Abstraction, Encapsulation, OverLoading, Inheritance
Answer: 3

106. By default, C# compiler create shared assembly

Select answer :

1. True
2. False
3. I don’t know

Answer: 2

107. Which tool use to register a shared assembly to global assemblies cache?

Select answer :

1. Just copy to <drive>:\<Windows NT dir>\assembly


2. sn –k
3. gacutil – i
4. tblimp

Answer: 3

108. We can add new element to an array name MyArray by :

Select answer :

1. MyArray.Add(new value)
2. MyArray[MyArray.Length] = new value
3. Cannot do that
4. MyArray[MyArray.Length -1] = new value

Answer: 3

109. What wrong with this snippet of code?

class ClassA

/*Do something*/

}
interface interfaceB : ClassA

/*Do something*/

class MainClass

static public void Main(System.String [] s)

//block of statements

Select answer :

1. Nothing wrong
2. Compiler error
3. Runtime error
4. Whatever

Answer: 2

110. What’s the .NET datatype that allows the retrieval of data by a unique key?

Select answer :

1. Primary
2. Integer
3. Unique Identifier
4. HashTable

Answer: 4

111. In C#, Default access modifier for class and fields is

Select answer :

1. public
2. private
3. internal
4. protected

Answer: 2

112. A character in C# is an

Select Answer :

1. signed 32 bit integer


2. unsigned 16 bit integer
3. signed 16 bit integer
4. Unsigned 32 bit integer

Answer: 2

113. If there are two interfaces having a same function which have same signature and
we are implementing both the interfaces in C# class then how will we define the methods in
our C# class?

Select answer :

1. Gives compilation error


2. Results in run – time error
3. Interface name dot method name will give you the access to particular method
4. Always calls the function in the first interface

Answer: 3

114. What is the difference between a virtual function and a abstract function ?

Select answer :

1. No difference
2. A virtual function can be overridden but an abstract cannot be overridden
3. A abstract function can be overridden but an virtual function cannot be overridden

Answer: 3

115. What will be the output of the following snippet code?

int i =12 ;

object obj = i;

i = 34;
Console.WriteLine(obj);

1. 12
2. 34
3. Compile error
4. Runtime it caught Exception

Answer: 1

116. How do you return more than one value in a function ?

Select answer :=

1. using return keyword


2. using multiple return keywords
3. using out or ref parameters
4. not possible

Answer: 3

117. In C#, the members inherited from the base class may not include which of the
following ?

Select answer :

1. constants
2. fields
3. methods
4. properties
5. None of the above choices

Answer: 5

118. The following code is meant to handle exceptions. Explain why this code is not
correct

1. try
2. {
3. …
4. }
5. catch(Exception),…-
6. catch(IOException),…-
Select answer :

1. We can’t use the type of IOException class as catch parameter here as such class doesn’t
exist
2. The code generates a compile time error because the most general exception is caught first
3. The type of class Exception can’t be used as catch parameter
4. This code is absolutely correct

Answer: 2

119. To convert a private assembly to a shared assembly which of the following should
you perform ?

Select answer :

1. Create a key pair


2. Sign the assembly with the key pair
3. Place the assembly in the global assembly cache
4. All of the above
5. None of the above

Answer: 4

120. It is possible for a derived class to define a member that has the same name as the
member in its base class. Which of the following keywords would you use If your intent is to
hide the base class member?

Select answer:

1. virtual
2. sealed
3. ref
4. new

Answer: 4

121. Identifiers in C# can be the same as reserved keywords [True/False]

Select answer :

1. False
2. True, you do this by prefixing the identifier with an @ symbol
3. True, you do this by suffixing the identifier with an @ symbol
4. True, you do this by suffixing the identifier with an & symbol

Answer: 2
C# 2.0 QUESTIONS
122. Which of the following are value types? (Choose all that apply.)

A. Decimal
B. String
C. System.Drawing.Point
D. Integer

Answers: A, C, and D

123. You pass a value-type variable into a procedure as an argument. The


procedure changes the variable; however, when the procedure returns, the
variable has not changed. What happened? (Choose one.)

A. The variable was not initialized before it was passed in.


B. Passing a value type into a procedure creates a copy of the data.
C. The variable was redeclared within the procedure level.
D. The procedure handled the variable as a reference.

Answer: B

124. Which is the correct declaration for a nullable integer?

A.

Nullable(int) i = null;

B.

Nullable<int> i = null;

C.

int i = null;

D.

int<Nullable> i = null;

Answer: B
125. You need to create a simple class or structure that contains only value
types. You must create the class or structure so that it runs as efficiently as
possible. You must be able to pass the class or structure to a procedure without
concern that the procedure will modify it. Which of the following should you
create?

A. A reference class
B. A reference structure
C. A value class
D. A value structure

Answer: D

126. Which of the following are reference types? (Choose all that apply.)

A. Types declared Nullable


B. String
C. Exception
D. All types derived from System.Object

Answers: B and C

127. What is the correct order for Catch clauses when handling different
exception types?

A. Order from most general to most specific.


B. Order from most likely to least likely to occur.
C. Order from most specific to most general.
D. Order from least likely to most likely to occur.

Answer: C

128. When should you use the StringBuilder class instead of the String class?

A. When building a string from shorter strings.


B. When working with text data longer than 256 bytes.
C. When you want to search and replace the contents of a string.
D. When a string is a value type.

Answer: A

129. Why should you close and dispose of resources in a Finally block instead
of a Catch block?

A. It keeps you from having to repeat the operation in each Catch.


B. Finally blocks run whether or not an exception occurs.
C. The compiler throws an error if resources are not disposed of in the Finally
block.
D. You cannot dispose of resources in a Catch block.

Answer: B

130. Which of the following statements are true? (Choose all that apply.)

A.Inheritance defines a contract between types.

B. Interfaces define a contract between types.

C. Inheritance derives a type from a base type.

D. Interfaces derive a type from a base type.

Answers: B and C

131. Which of the following are examples of built-in generic types? (Choose all
that apply.)

A. Nullable
B. Boolean
C. EventHandler
D. System.Drawing.Point

Answers: A and C

132. You are creating a generic class, and you need to dispose of the generic
objects.
How can you do this?

A. Call the Object.Dispose method.


B. Implement the IDisposable interface.
C. Derive the generic class from the IDisposable class.
D. Use constraints to require the generic type to implement the IDisposable
interface.

Answer: D

133. You’ve implemented an event delegate from a class, but when you try to
attach
an event procedure you get a compiler error that there is no overload that
matches the delegate. What happened?
A. The signature of the event procedure doesn’t match that defined by the
delegate.
B. The event procedure is declared Shared/static, but it should be an instance
member instead.
C. You mistyped the event procedure name when attaching it to the delegate.
D. The class was created in a different language.

Answer: A

134. Why should boxing be avoided? (Choose one.)

A. It adds overhead.
B. Users must have administrative privileges to run the application.
C. It makes code less readable.

Answer: A

135. Structures inherit ToString from System.Object. Why would someone


override
that method within a structure? (Choose as many correct answers as apply.)

A. To avoid boxing.
B. To return something other than the type name.
C. The compiler requires structures to override the ToString method.
D. To avoid run-time errors caused by invalid string conversions.

Answers: A and B

136. If there is no valid conversion between two types, what should you do
when
implementing the IConvertible interface?

A. Delete the ToType member that performs the conversion.


B. Throw an InvalidCastException.
C. Throw a new custom exception reporting the error.
D. Leave the member body empty.

Answer: B

137. With strict conversions enabled, which of the following would allow an
implicit
conversion? (Choose all that apply.)
A. Int16 to Int32
B. Int32 to Int16
C. Int16 to Double
D. Double to Int16

Answers: A and C

138. Which are acceptable ways to open a file for writing? (Choose all that
apply.)

A.
File.Open("somefile.txt", FileMode.Create);
B.
File.Open("somefile.txt", FileMode.Create, FileAccess.Write);
C.
File.Open("somefile.txt", FileMode.Create, FileAccess.Read);

D.
FileInfo file = new FileInfo("somefile.txt");
file.Open(FileMode.Create);

Answers: A, B, and D

139. Which of the following are types of changes that can be detected by the
FileSystemWatcher? (Choose all that apply.)

A. New files
B. New directories
C. Changed files
D. Renamed files
E. None

Answers: A, B, C, and D

140. The following code changes the extension of a file. (True or False)
string ourPath = @"c:\boot.ini";
Path.ChangeExtension(ourPath, "bak");

A. True
B. False

Answer: B

141. Which methods of the FileStream class affect the Position property?
(Choose all that apply.)

A. Read
B. Lock
C. Write
D. Seek
Answers: A, C, and D

142. How do you force changes in a StreamWriter to be sent to the stream it is


writing
to? (Choose all that apply.)

A. Close the StreamWriter.


B. Call the Flush method of the StreamWriter.
C. Set the AutoFlush property of the StreamWriter to true.
D. Close the stream.

Answers: A, B, and C

143. Which of the following create a FileStream for writing when you want to
open an existing file or create a new one if it doesn’t exist? (Choose all that
apply.)

A. Create a new instance of the FileStream class, with the FileMode option of
OpenOrCreate.
B. Call File.Create to create the FileStream.
C. Call File.Open with the FileMode option of OpenOrCreate.
D. Call File.Open with the FileMode option of Open.

Answers: A and C

144. When compressing data with the DeflateStream class, how do you specify
a stream into which to write compressed data?

A. Set the BaseStream property with the destination stream, and set the
CompressionMode
property to Compression.
B. Specify the stream to write into when the DeflateStream object is created
(for example, in the constructor).
C. Use the Write method of the DeflateStream class.
D. Register for the BaseStream event of the DeflateStream class.

Answer: B

145. What types of data can a GZipStream compress? (Choose all that apply.)

A. Any file
B. Any data
C. Any data less than 4 GB in size
D. Any file no larger than 4 GB in size
Answers: C and D

146. What methods can be used to create a new IsolatedStorageFile object?


(Choose all
that apply.)

A. IsolatedStorageFile.GetStore
B. IsolatedStorageFile.GetMachineStoreForAssembly
C. IsolatedStorageFile.GetUserStoreForAssembly
D. IsolatedStorageFile constructor

Answers: A, B, and C

147. An IsolatedStorageFileStream object can be used like any other FileStream


object.

A. True
B. False

Answer: A

148. You are writing an application to update absolute hyperlinks in HTML files.
You have loaded the HTML file into a String named s. Which of the following code
samples best replaces “http://” with “https://”?

A.
s = Regex.Replace(s, "http://", "https://");
B.
s = Regex.Replace(s, "https://", "http://");
C.
s = Regex.Replace(s, "http://", "https://", RegexOptions.IgnoreCase);
D.
s = Regex.Replace(s, "https://", "http://", RegexOptions.IgnoreCase);

Correct Answer: C

149. You are writing an application to process data contained in a text form.
Each file contains information about a single customer. The following is a sample
form:
First Name: Tom
Last Name: Perham

Address: 1 Pine St.


City: Springfield
State: MA
Zip: 01332
You have read the form data into the String variable s. Which of the following
code samples correctly stores the data portion of the form in the fullName,
address, city, state, and zip variables?

A.
string p = @"First Name: (?<firstName>.*$)\n" +
@"Last Name: (?<lastName>.*$)\n" +
@"Address: (?<address>.*$)\n" +
@"City: (?<city>.*$)\n" +
@"State: (?<state>.*$)\n" +
@"Zip: (?<zip>.*$)";
Match m = Regex.Match(s, p, RegexOptions.Multiline);
string fullName = m.Groups["firstName"] + " " + m.Groups["lastName"];
string address = m.Groups["address"].ToString();
string city = m.Groups["city"].ToString();
string state = m.Groups["state"].ToString();
string zip = m.Groups["zip"].ToString();
B.
string p = @"First Name: (?<firstName>.*$)\n" +
@"Last Name: (?<lastName>.*$)\n" +
@"Address: (?<address>.*$)\n" +
@"City: (?<city>.*$)\n" +
@"State: (?<state>.*$)\n" +
@"Zip: (?<zip>.*$)";
Match m = Regex.Match(s, p);
string fullName = m.Groups["firstName"] + " " + m.Groups["lastName"];
string address = m.Groups["address"].ToString();
string city = m.Groups["city"].ToString();
string state = m.Groups["state"].ToString();
string zip = m.Groups["zip"].ToString();
C.
string p = @"First Name: (?<firstName>.*$)\n" +
@"Last Name: (?<lastName>.*$)\n" +
@"Address: (?<address>.*$)\n" +
@"City: (?<city>.*$)\n" +
@"State: (?<state>.*$)\n" +
@"Zip: (?<zip>.*$)";
Match m = Regex.Match(s, p, RegexOptions.Multiline);
string fullName = m.Groups["<firstName>"] + " " + m.Groups["<lastName>"];
string address = m.Groups["<address>"].ToString();
string city = m.Groups["<city>"].ToString();
string state = m.Groups["<state>"].ToString();
string zip = m.Groups["<zip>"].ToString();
D.
string p = @"First Name: (?<firstName>.*$)\n" +
@"Last Name: (?<lastName>.*$)\n" +
@"Address: (?<address>.*$)\n" +
@"City: (?<city>.*$)\n" +
@"State: (?<state>.*$)\n" +
@"Zip: (?<zip>.*$)";
Match m = Regex.Match(s, p);
string fullName = m.Groups["<firstName>"] + " " + m.Groups["<lastName>"];
string address = m.Groups["<address>"].ToString();
string city = m.Groups["<city>"].ToString();
string state = m.Groups["<state>"].ToString();
string zip = m.Groups["<zip>"].ToString();

Correct Answer: A

150. Which of the following regular expressions matches the strings “zoot” and
“zot”?

A. z(oo)+t
B. zo*t$
C. $zo*t
D. ^(zo)+t

Correct Answer: B

151. Which of the following strings match the regular expression


"^a(mo)+t.*z$"? (Choose all that apply.)
A. amotz
B. amomtrewz
C. amotmoz
D. atrewz
E. amomomottothez

Correct Answers: A, C, and E

152. Which of the following encoding types would yield the largest file size?

A. UTF-32
B. UTF-16
C. UTF-8
D. ASCII

Correct Answer: A

153. Which of the following encoding types support Chinese? (Choose all that
apply.)

A. UTF-32
B. UTF-16
C. UTF-8
D. ASCII

Correct Answers: A, B, and C

154. You need to decode a file encoded in ASCII. Which of the following
decoding types would yield correct results? (Choose all that apply.)

A. Encoding.UTF32
B. Encoding.UTF16
C. Encoding.UTF8
D. Encoding.UTF7

Correct Answers: C and D

155. You are writing an application that generates summary reports nightly.
These reports will be viewed by executives in your Korea office and must contain
Korean characters. Which of the following encoding types should you use?

A. iso-2022-kr
B. x-EBCDIC-KoreanExtended
C. x-mac-korean
D. UTF-16.

Correct Answer: D

156. Which of the following ArrayList methods can be used to determine


whether an item exists in the collection? (Choose all that apply.)

A. Remove
B. Contains
C. IndexOf
D. Count

Correct Answers: B and C

157. What is the Comparer class used for? (Choose all that apply.)

A. To compare two objects, usually for sorting


B. To test whether two objects are the same reference of an object
C. To sort an ArrayList in the ArrayList.Sort method
D. To provide a default implementation of the IComparer interface

Correct Answers: A, C, and D

158. What does the Dequeue method of the Queue class do? (Choose all that
apply.)

A. Retrieves an item from the front of the collection


B. Adds an item to the collection
C. Removes the first item from the collection
D. Clears the collection

Correct Answers: A and C

159. In what order does a Stack retrieve items as you use its Pop method?

A. Random order
B. First-in, first-out
C. Last-in, first-out
D. Last-in, last-out

Correct Answer: C

160. When adding a key to a Hashtable, what methods can be called on the key
to
determine whether the key is unique? (Choose all that apply.)

A. GetType
B. GetHashCode
C. ToString
D. Equals

Correct Answers: B and D

161. Which of the following statements is true?

A. You can pass an instance of a class that supports the IEqualityComparer


interface when you construct a Hashtable to change the way keys are evaluated
for uniqueness.
B. You can assign an IEqualityComparer object to an existing Hashtable.
C. You cannot use an IEqualityComparer with a Hashtable.
D. A Hashtable implements IEqualityComparer.

Correct Answer: A

162. What types of collections can be made from the CollectionsUtil class?
(Choose all that apply.)
A. Case-insensitive StringDictionary
B. Culture-invariant Hashtable
C. Case-insensitive Hashtable
D. Case-insensitive SortedList

Correct Answers: C and D

163. What types of objects can stored as a Value in StringDictionary?

A. Strings
B. Objects
C. Arrays of strings
D. Any .NET Types

Correct Answer: A

164. What kind of object does the generic Dictionary enumerator return?

A. Object
B. Generic KeyValuePair objects
C. Key
D. Value

Correct Answer: B

165. Where can you add items to a LinkedList? (Choose all that apply.)

A. At the beginning of the LinkedList


B. Before any specific node
C. After any specific node
D. At the end of the LinkedList
E. At any numeric index in the LinkedList

Correct Answers: A, B, C, and D

166. Which of the following are required to serialize an object? (Choose all that
apply.)

A. An instance of BinaryFormatter
B. File permissions to create temporary files
C. Internet Information Services
D. A stream object

Answers: A and D

167. Which of the following attributes should you add to a class to enable it to
be serialized?
A. ISerializable
B. Serializable
C. SoapInclude
D. OnDeserialization

Answer: B

168. Which of the following attributes should you add to a member to prevent it
from being serialized by BinaryFormatter?
A. NonSerialized
B. Serializable
C. SerializationException
D. SoapIgnore

Answer: A

169. Which of the following interfaces should you implement to enable you to
run a method after an instance of your class is serialized?
A. IFormatter
B. ISerializable
C. IDeserializationCallback
D. IobjectReference

Answer: C

170. Which of the following are requirements for a class to be serialized with
XML serialization? (Choose all that apply.)
A. The class must be public.
B. The class must be private.
C. The class must have a parameterless constructor.
D. The class must have a constructor that accepts a SerializationInfo parameter.

Answers: A and C
171. Which of the following attributes would you use to cause a member to be
serialized as an attribute, rather than an element?

A. XmlAnyAttribute
B. XMLType
C. XMLElement
D. XMLAttribute

Answer: D
172. Which tool would you use to help you create a class that, when serialized,
would produce an XML document that conformed to an XML schema?

A. Xsd.exe
B. Xdcmake.exe
C. XPadsi90.exe
D. Xcacls.exe

Answer: A
173. Which of the following attributes should you add to a member to prevent it
from being serialized by XML serialization?
A. XMLType
B. XMLIgnore
C. XMLElement
D. XMLAttribute

Answer: B
174. Which parameters must a constructor accept if the class implements
ISerializable? (Choose all that apply.)
A. SerializationInfo
B. Formatter
C. StreamingContext
D. ObjectManager

Answers: A and C
175. Which event would you use to run a method immediately before
deserialization occurs?

A. OnSerializing
B. OnDeserializing
C. OnSerialized
D. OnDeserialized

Answer: B
176. Which event would you use to run a method immediately after serialization
occurs?
A. OnSerializing
B. OnDeserializing
C. OnSerialized
D. OnDeserialized

Answer: C
177. Which of the following are requirements for a method that is called in
response to a serialization event? (Choose all that apply.)
A. Accept a StreamingContext object as a parameter.
B. Accept a SerializationInfo object as a parameter.
C. Return void.
D. Return a StreamingContext object.

Answers: A and C
178. Which of the following methods would you use to draw a square with a
solid color?
A. Graphics.DrawLines
B. Graphics.DrawRectangle
C. Graphics.DrawPolygon
D. Graphics.DrawEllipse
E. Graphics.FillRectangle
F. Graphics.FillPolygon
G. Graphics.FillEllipse

Answer: E
179. Which of the following methods would you use to draw an empty triangle?
A. Graphics.DrawLines
B. Graphics.DrawRectangle
C. Graphics.DrawPolygon
D. Graphics.DrawEllipse
E. Graphics.FillRectangle
F. Graphics.FillPolygon
G. Graphics.FillEllipse

Answer: C
180. Which of the following classes is required to draw an empty circle?
(Choose all that apply.)
A. System.Drawing.Graphics
B. System.Drawing.Pen
C. System.Drawing.Brush
D. System.Drawing.Bitmap

Answers: A and B
181. Which of the following brush classes would you use to create a solid
rectangle that is red at the top and gradually fades to white towards the bottom?
A. System.Drawing.Drawing2D.HatchBrush
B. System.Drawing.Drawing2D.LinearGradientBrush
C. System.Drawing.Drawing2D.PathGradientBrush
D. System.Drawing.SolidBrush
E. System.Drawing.TextureBrush

Answer: B
182. What type of line would the following code sample draw?
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red, 10);
p.StartCap = LineCap.Flat;
p.EndCap = LineCap.ArrowAnchor;
g.DrawLine(p, 50, 50, 400, 50);

A. An arrow pointing up
B. An arrow pointing down
C. An arrow pointing left
D. An arrow pointing right

Answer: D
183. Which of the following classes could you use to display a JPEG image from
an existing file in a form? (Choose all that apply.)
A. System.Drawing.Image
B. System.Drawing.Bitmap
C. System.Drawing.Imaging.Metafile
D. System.Windows.Forms.PictureBox

Answers: A and B
184. How can you draw a black border around a JPEG image that you have
saved to disk, and then save the updated image back to the disk?
A. Create a Graphics object by loading the JPEG image from disk. Draw the
border by calling Graphics.DrawRectangle. Finally, save the updated image
by calling Graphics.Save.
B. Create a Bitmap object by loading the JPEG image from disk. Draw the border
by calling Bitmap.DrawRectangle. Finally, save the updated image by
calling Bitmap.Save.
C. Create a Bitmap object by loading the JPEG image from disk. Create a
Graphics object by calling Graphics.FromImage. Draw the border by calling
Graphics.DrawRectangle. Finally, save the updated image by calling Bitmap.
Save.
D. Create a Bitmap object by loading the JPEG image from disk. Create a
Graphics object by calling Bitmap.CreateGraphics. Draw the border by calling
Graphics.DrawRectangle. Finally, save the updated image by calling Bitmap.
Save.

Answer: C
185. Which format should you choose to save a photograph that could be
opened by a wide variety of applications?
A. ImageFormat.Bmp
B. ImageFormat.Gif
C. ImageFormat.Jpeg
D. ImageFormat.Png

Answer: C
186. Which format should you choose to save a pie chart that could be opened
by a wide variety of applications?

A. ImageFormat.Bmp
B. ImageFormat.Gif
C. ImageFormat.Jpeg
D. ImageFormat.Png

Answer: B
187. What are the steps for adding text to an image?
A. Create a Graphics object and a string object. Then call string.Draw.
B. Create a Graphics object, a Font object, and a Brush object. Then call Graphics
.DrawString.
C. Create a Graphics object, a Font object, and a Pen object. Then call Graphics
.DrawString.
D. Create a Bitmap object, a Font object, and a Brush object. Then call Bitmap
.DrawString.

Answer: B
188. Which of the following is a class would you need to create an instance of to
specify that a string should be centered when drawn?
A. StringFormat
B. StringAlignment
C. FormatFlags
D. LineAlignment

Answer: A
189. Which of the following commands would cause a string to be flush left?

A. StringFormat.LineAlignment = Near
B. StringFormat.LineAlignment = Far
C. StringFormat.Alignment = Near
D. StringFormat.Alignment = Far

Answer: C
190. What type of object is required when starting a thread that requires a single
parameter?
A. ThreadStart delegate
B. ParameterizedThreadStart delegate
C. SynchronizationContext class
D. ExecutionContext class

Answer: B
191. What method stops a running thread?
A. Thread.Suspend
B. Thread.Resume
C. Thread.Abort
D. Thread.Join
Answer: C
192. Assuming there is not a writer lock in place, how many readers can
simultaneously read data with a ReaderWriterLock?
A. 0
B. 1
C. 10
D. Unlimited

Answer: D
193. Which of the following can be used to synchronize threads across
AppDomain and process boundaries? (Choose all that apply)

A. Monitor class
B. Mutex class
C. Semaphore class
D. C#’s lock or Visual Basic’s SyncLock keyword

Answers: B and C
194. What method of the ThreadPool class is used to have the ThreadPool run
some specified code on threads from the pool? (Choose all that apply.)

A. ThreadPool.RegisterWaitForSingleObject
B. ThreadPool.QueueUserWorkItem
C. ThreadPool.UnsafeRegisterWaitForSingleObject
D. ThreadPool.UnsafeQueueUserWorkItem

Answers: B and D
195. How do you temporarily stop a Timer from firing?

A. Call Dispose on the Timer.


B. Call Timer.Change, and set the time values to Timeout.Infinite.
C. Let the Timer object go out of scope.
D. Call Timer.Change, and set the time values to zero.

Answer: B
196. Which of the following are valid reasons to create an application domain?
(Choose all that apply.)
A. It is the only way to launch a separate process.
B. You can remove the application domain to free up resources.
C. Application domains improve performance.
D. Application domains provide a layer of separation and security.

Answers: B and D
197. Which of the following are valid ways to run an assembly within an
application domain? (Choose all that apply.)
A. AppDomain.CreateDomain
B. AppDomain.ExecuteAssembly
C. AppDomain.ExecuteAssemblyByName
D. AppDomain.ApplicationIdentity
Answers: B and C
198. Which command would you use to close the application domain in the
following code sample?
// C#
AppDomain d = AppDomain.CreateDomain("New Domain");
d.ExecuteAssemblyByName("MyAssembly");
A. d.DomainUnload()
B. d = null
C. d.Unload()
D. AppDomain.Unload(d)

Answer: D
199. How does the runtime use evidence when creating an application domain?
A. To determine the priority at which the process should run
B. To identify the author of the assembly
C. To determine which privileges the assembly should receive
D. To track the actions of the assembly for audit purposes

Answer: C
200. Which of the following code samples runs an assembly as if it were located
on the Internet? (Choose all that apply.)
A.
object [] hostEvidence = {new Zone(SecurityZone.Internet)};
Evidence e = new Evidence(hostEvidence, null);
AppDomain d = AppDomain.CreateDomain("MyDomain", e);
d.ExecuteAssembly("Assembly.exe");
B.
object [] hostEvidence = {new Zone(SecurityZone.Internet)};
AppDomain d = AppDomain.CreateDomain("MyDomain");
Evidence e = new Evidence(hostEvidence, null);
d.Evidence = e;
d.ExecuteAssembly("Assembly.exe");
C.
AppDomain myDomain = AppDomain.CreateDomain("MyDomain");
myDomain.ExecuteAssembly("Assembly.exe", new Zone(SecurityZone.Internet));
D.
Evidence e = new Evidence();
e.AddHost(new Zone(SecurityZone.Internet));
AppDomain myDomain = AppDomain.CreateDomain("MyDomain");
myDomain.ExecuteAssembly("Assembly.exe", e);

Answers: A and D
201. How can you set the base directory for an application in an application
domain?
A. Create an instance of the AppDomain class, and then set the Dynamic-
Directory property.
B. Create an instance of the AppDomain class, and then set the BaseDirectory
property.
C. Create an instance of the AppDomainSetup class, and then set the Dynamic-
Base property. Pass the AppDomainSetup object to the AppDomain constructor.
D. Create an instance of the AppDomainSetup class, and then set the Application-
Base property. Pass the AppDomainSetup object to the AppDomain constructor

Answer: D
202. You need to notify the user if your assembly is running without the ability
to use HTTP to download assemblies. How can you determine whether you have
that permission?
A. Examine AppDomain.CurrentDomain.SetupInformation.DisallowCodeDownload.
B. Examine AppDomain.CurrentDomain.DisallowCodeDownload.
C. Examine AppDomain.CurrentDomain.SetupInformation.DisallowPublisherPolicy.
D. Examine AppDomain.CurrentDomain.DisallowPublisherPolicy.

Answer: A
203. Which account type should you choose to minimize security risks?
A. LocalService
B. NetworkService
C. LocalSystem
D. User

Answer: A
204. Which account type should you choose to minimize the possibility of
problems caused by overly restrictive permissions on the local computer?
A. LocalService
B. NetworkService
C. LocalSystem
D. User

Answer: C
205. Which of the following are valid ways to install a service on a computer?
(Choose all that apply.)
A. Add a shortcut to your assembly to the user’s Startup group.
B. Use InstallUtil to install your service.
C. Configure Scheduled Tasks to launch your assembly upon startup.
D. Use Visual Studio to create an installer for your service.

Answers: B and D
206. Which tools can you use to change the user account for a service after the
service is installed?
A. My Computer
B. Computer Management
C. Net
D. Microsoft .NET Framework 2.0 Configuration

Answer: B
207. Which code segment shows the best way to retrieve the “Foo” section of
the following configuration file?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Foo" value="Hello World!"/>
</appSettings>
</configuration>
A.
NameValueCollection AllAppSettings = ConfigurationManager.AppSettings;
Console.WriteLine(AllAppSettings["Hello World!"]);
B.
Console.WriteLine(ConfigurationSettings.AppSettings["Foo"]);
C.
NameValueCollection AllAppSettings = ConfigurationManager.AppSettings;
Console.WriteLine(AllAppSettings[5]);
D.
NameValueCollection AllAppSettings = ConfigurationManager.AppSettings;
Console.WriteLine(AllAppSettings["Foo"]);

Answer: D
208. What will happen if you try to use the following section of code to store a
connection string?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<SqlConnectionStrings>
<clear/>
<add name="AdventureWorksString"
providerName="System.Data.SqlClient"
connectionString="Data Source=localhost;Initial
Catalog=AdventureWorks;
Integrated Security=true"/>
</ SqlConnectionStrings >
</configuration>
A. There is no problem with this file, and the connection string values can be
retrieved without any issues.
B. The <clear/> tag is unnecessary because there is only one connection
string, and this tag will cause the file not to parse.
C. As long as you use the SqlConnectionStrings property of the Configuration-
Manager object, it will retrieve the value correctly.
D. There is no predefined property for SqlConnectionStrings, so the file will not
process correctly. If SqlConnectionStrings were changed to connectionStrings,
everything would work properly.

Answer: D
209. Which of the following objects or interfaces is the best solution to provide
customized configuration manipulation? (Choose all that apply.)
A. IConfigurationSectionHandler
B. ConfigurationValidatorBase
C. IConfigurationSystem
D. ApplicationSettingsBase

Answer: D
210. What base class should you derive from when creating custom
applications?
A. The InstallContext class
B. The InstallerCollection class
C. The ManagedInstallerClass class
D. The Installer class

Answer: D
211. You want to create an installation that, in the event of failure, undoes
everything it has done so far. Which of the following mechanisms accomplishes
that task?

A. The Rollback method of the Installer class


B. The Undo method of the Installer class
C. The Clear and Rollback methods of the Installer class
D. The Uninstall method of the Installer class.

Answer: A
212. What visual tool does Visual Studio 2005 use to allow developers to edit
and manage registry keys?
A. The Custom Actions view
B. The File System view
C. The Registry Editor view
D. The Registry view

Answer: D
213. What can be handled by using the .NET Framework 2.0 Configuration tool?
(Choose all that apply.)
A. View All running processes and manage their permission sets
B. View All running services and manage their operation
C. ViewAll configured applications
D. View All assemblies in the global assembly cache (GAC)

Answers: C and D
214. Which of the following items can be created by using the .NET Framework
2.0 Configuration tool?
A. Permission sets
B. Code sets
C. Assembly sets
D. Application sets

Answer: A
215. Which methods of the Configuration class are valid ways to open a
configuration file? (Choose all that apply.)
A. OpenExeConfiguration
B. OpenMachineConfiguration
C. OpenMappedExeConfiguration
D. OpenMappedMachineConfiguration

Answers: A, B, C, and D
216. What method causes settings to be read from an
IconfigurationSectionHandler object?
A. Create
B. ReadSection
C. GetConfig
D. GetAppSettings

Answer: A

You might also like