You are on page 1of 56

vaC# - I

1.21
1) Which of the following is not a class?
a. A Ford Ikon car with the registration number XXXX
b. Fruit
c. Mammal
d. Fish
2) Which method displays the message “”Hello People” on the screen?
a. Console.WriteLine(“Hello People”);
b. System.WriteLine(“Hello People”);
c. Console(“Hello People”);
d. Console.writeline(“Hello People”);
3) Console is a .
a. Namespace
b. Class
c. Function
d. Escape sequence character
4) In a C# program, which is the first function to be executed?
a. Main()
b. main()
c. Console.WriteLine()
d. Void Accept_bike_Details()
5) Which of the following is used to denote a newline character?
a. \b
b. \n
c. \v
d. /n
2.14
6) In the statement, using System, System is a .
a. Namespace
b. Class
c. Object
d. Keyword
7) Which of the following is not an example of value type?
a. char
b. int
c. float
d. string
8) The compiler is used for c#.
a. cc
b. csc
c. c++
d. cs
9) The statement //Hello world in a c# program:
a. Displays the text Hello world on the screen
b. Is not executed by the compiler and will be treated as a comment
c. Declares a variable Hello world
d. Causes all code lines following it to be treated as comments
10) In which of the following datatype does the Console.Readline() function accept a
value?
a. int
b. float
c. bool
d. string
3.26
11) Consider the following code:

static void Main(string[] args)


{
char character;
Console.WriteLine("Enter a character: ");
character = Convert.ToChar(Console.ReadLine());

if (character == 'X')
Console.WriteLine("The characters is X");
else
Console.WriteLine("The character is not X");
Console.ReadLine();
}
Note: The Convert.ToChar() converts a value to the char datatype.

What will be the output if the input of the preceding code is x?


a. The character is x
b. The character is not x
c. Error message
d. x
12) To which category of operators do the ++ belong?
a. Arithmetic operators
b. Arithmetic assignment operators
c. Unary operators
d. Comparison operators
13) Which of the following operators can be used to evaluate an expression to true only if
both the conditions are true?
a. &&
b. ||
c. >=
d. !=
14) State whether the following statement is true or false:
The continue statement if used in the while and do…while loop causes the program
control to pass to the top of the loop avoiding the other statements in the loop. true
15) State whether the following statement is true or false:
A termination expression is evaluated at each iteration of the for loop. true
4.32
16) State whether the given statement is true or false:
Encapsulation means preventing access to nonessential details. true
17) Consider the following statements:
Statement A: Static variables retain their values even after the function to which they
belong has been executed.
Statement B: static functions can access static as well as non-static variables.
Which of the given statements are true?
a. A and B both are true
b. A is true and B is false
c. A is false and B is true
d. A and B both are false
18) Which of the following statement about access specifiers is true?
a. An access specifier determines which feature of a class can be used by other
classes.
b. Protected variables are not accessible to the subclasses of the class in which they
are declared.
c. A method declared as public in a superclass cannot be accessed by the subclasses
of that superclass.
d. A variable declared inside a method can have access specifiers.
19) State whether the following statement is true or false:
In a public access specifier, all the public members of the base class become
protected. false
20) State whether the given statement is true or false:
Abstraction represents the essential characteristics of an object or classes that
differentiate it from other objects or classes. True
5.28
21) If an array is declared as, int[] arr = new int [5], the total number of elements in the
array is .
a. 5
b. 2
c. 1
d. 0
22) Consider the following code:
int Number1 = 0;
int Number2 = 0;
int[] Array1 = new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
foreach (int Ctr in Array1)
{
if (Ctr % 2 == 1)
{ Number1++;
else
Number2++;
Console.WriteLine(Ctr)
}
}
What is the output of the code?
a. 3,5,7,9,11
b. 2,4,6,8,10
c. Ctr
d. 2,3,4,5,6,7,8,9,10,11
23) If an array is declared as string[] arr = new string[5], the base type of the array is
.
a. string
b. int
c. long
d. byte
24) Consider the following code:
class ArrayClass
{
static void Main()
{
string[] String_Array = new string[4];
String_Array[0] = "str1";
String_Array[1] = "str2";
for (int i = 0; i < 2; i++)
{
Console.WriteLine("arr[{0}] = {1}", i,String_Array[i]);
}
}
}
View the problem statement and answer the following question. What is the output of
the program?
a. str1
b. str2
c. error message is displayed
d. arr[0] = str1
arr[1] = str2
25) The subscript number of an array starts from .
e. 0
f. -1
g. 1
h. 2
6.14
26) Which of the following statement is true about garbage collection?
a. In garbage collection the objects are not destroyed.
b. In garbage collection the objects are destroyed every time.
c. In garbage collection only unreferenced objects are destroyed.
27) A destructor has the same name as its class but is prefixed with . ~
28) process identified the unused objects and releases them in c#.
Garbage Collection
29) Consider the following code and identify which line will generate an error on
compilation:
//Life Cycle of an Object
namespace Objects
{
class Draw
{
public void Shape()
{
Console.WriteLine("In shape method");
}
public Draw() //line 1
{
Console.WriteLine("This is a constructor");
}
public static void Main(string[] arg)
{
Draw obj = new Draw();//line 2
obj.Draw(); // line 3
obj.Shape(); // line4
}
}
}
Consider the preceding code and answer the following question. Which line in the
code will generate an reeor on compilation?
a. line 1
b. line 2
c. line 3
d. line 4
30) The Idisposable interface contains the method. Dispose
7.28
31) Which of the following options about implementing polymorphism is NOT true?
a. You can implement polymorphism by implementing an interface.
b. You can also achieve polymorphism by inheritance.
c. You can implement polymorphism by encapsulation.
d. You can implement polymorphism by using abstract classes
32) Consider the following statements:
Statement A: In dynamic polymorphism, appropriate methods of a program can be
invoked. depending on the context.
Statement B: In early binding, function calls are bound at run time.
Which of the following option is true about these statements?
a. Statement A is true, and statement B is false.
b. Statement A is false, and statement B is true.
c. Both statements are true.
d. Both statements are false.
33) Which of the following is an example of function overloading?
a. void example();
char example();
b. void example1();
void example2();
c. void example1(int, int);
void example1(char,char);
d. void example(int, int);
int example1(char,char);
34) Consider following statements:
Statement A: Overloading a binary operator is similar to overloading a unary operator
except that a binary operator requires an additional parameter.
Statement B: Binary operators include arithmetic assignment operators.
Which of following option is true about the preceding statements?
a. Statement A is true, and statement B is false.
b. Statement A is false. And statement B is true.
c. Both statements A and B are true.
d. Both statements A and B are false.
35) which of the following statements is true about operator overloading?
a. The + operator cannot be overloaded. false
b. Binary operators are operators that work with two operands. True
C# - II
8.25
36) Consider the following statements:
Statement A: Inheritance reduces the redundancy in code. Statement B: Inheritance
enables easy maintenance of code.
Which of the following is true about the given statements?
a. Statement A is true, and statement B is false.
b. Statement A is false, and statement B is true.
c. Both statements A and B are true.
d. Both statements A and B are false.
37) Consider the following code:
public interface Interface1
{
void a();
void b();
}
public interface Interface2 : Interface1
{
void c();
void d();
}
View the preceding code, and determine which of the following options comprises
the members of the Interface2 interfacce?
a. void c() and void d()
b. void a() and void b()
c. void a(), void b(), void c() and void d()
d. void a(), void c(), anf void d()
38) which of the following is true about abstract classes?
a. An abstrct class defines properties common to the classes derived from it.
b. An abstract class can be declared as final.
c. Abstract classes connot be extended.
d. Classes declared using the abstract keyword can be instantiated.
39) Consider the following code:
interface a
{
void b();
}
class c
{
void a. b { }
}
Which of the following statement generates the compilation error in the preceding
code?
a. interface a
b. void b()
c. void a. b() {}
d. class c
40) Consider the following statements:
Statement A: A class cannot have more than one derived class.
Statement B: Inheritance increases the functionality of a base class by adding
additional features to its derived classes.
Which of the following statement is true?
a. Statement A is true, and statement B is false.
b. Statement A is false, and statement B is true.
c. Both statement are true.
d. Both statements are false.
9.18
41) Which method in the following code writes the input to the stream?
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
class Write
{
public static void Main(String[] arg)
{
FileStream fs = new FileStream("MyFile.txt",FileMode.Append.
FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
String str = Console.ReadLine();
sw.Write(str);
sw.Flush();
sw.Close();
fs.Close();
}
}

a. String str = Console.ReadLine();


b. sw.Write(str);
c. sw.Flush();
d. fs.Close();
42) You need to access a file named MyFile.txt. If the file already exists on the system,
you need to open it; else you need to ensure that a new file with the file name
MyFile.txt is created. Which of the following statements would you write to do the
preceding task?
a. FileStream fs = new
FileStream("c:\\MyFile.txt",FileMode.Create, FileAccess.Write);

b. FileStream fs = new
FileStream("c:\\MyFile.txt",FileMode.CreateNew,
FileAccess.Write);

c. FileStream fs = new FileStream("c:\\MyFile.txt",FileMode.Open,


FileAccess.Write);

d. FileStream fs = new
FileStream("c:\\MyFile.txt",FileMode.OpenOrCreate,
FileAccess.Write);
43) The method that is used to alter the positions from where a read or write operation
can occur is . SeekOrigin
44) Match the following terms in column B to the description in Column A.

A B

Attribute Gets or sets CreationTime of the current file

CreationTime Gests a Boolean value indicating whether the


directory exist or not
Exits Gets or sets attribute associated with the
current file. This property is inherited from
FileSystemInfo

45) John wants to perform a read/write operation on a file. He does not want the file to be
overwritten when he is performing the write operation. Which FileMode should he
use? Append
10.17
46) The base class of all exceptions is . System.Exception
47) The set of statements the need to be executed whether an exeption is thrown or not
thrown is included in the block. finally
48) Can a try block have more than one catch handler? Yes
49) State whether the following statement is true or false:
A try block ensures that an exception is handled. false
50) An attempt to divide by zero throws the exception.
System.DivideByZeroException
11.35
51) Which of the following is true about the ‘not runnable’ state of a thread?
a. A sleeping thread enters the ‘ not runnable’ state when the specified time has
elapsed.
b. A thread is in a ‘ not runnable’ state if it is dead.
c. When the Start() method is invoked. the thread enters the ‘not runable’ state.
d. When a thread is blocked by another thread. it enters the ‘not runnable’ state.
52) You need to create a spreadsheet application with automatic recalculation facility.
Which of the following statements is/are true with respect to the required application?
A. The application should be multithreaded.
B. A thread object has to be created for performing automatic recalculation.
C. The thread taking care of automatic recalculation should have the highest
a. A only
b. A. B. C
c. B. C
d. A. B
53) Which class is used to construct and access individual threads in a multithreaded
application?
a. System.Thread
b. System.Threading
c. System.Thread. Threading
d. System.Threading.Thread
54) You are creating an application, using the concept of multithreading, in which you
can play audio files and watch animated images at the same time. Which of the
following methods should be invoked for a thread to enter the runnable state?
a. start()
b. sleep()
c. Run()
d. Resume()
55) You are developing a multithreaded application. Which of the following will you use
to make a thread. animThread. enter the non-runnable state?
a. Thread animThread = new Thread(this);
b. animThread. Sleep(2000);
c. animThread. Resume();
d. animThread. Start();
12.19
56) Identify the correct statement about delegates.
a. Before you declare an event inside a class, you can optionally declare a delegate
by using the delegate keyword.
b. The delegate type consists of the set of arguments that it receives from the method
that handles the event.
c. Multiple events cannot share the same delegate.
d. By using a single-cast delegate, you can invoke only one method corresponding to
different events.
57) Which of the following code is correct to assign more than one method address to
a delegate?
a. Delegatevariable = new MyDelegate(Function1)
Delegatevariable += new MyDelegate(Function2)
b. Delegatevariable = MyDelegate(Function1);
Delegatevariable += MyDelegate(Function2);
c. Delegatevariable = new MyDelegate(Function1);
Delegatevariable += new MyDelegate(Function1 +Function2);
d. Delegatevariable = new MyDelegate(Function1);
Delegatevariable += new MyDelegate(Function2);
58) State whether the given statement is true or false.
A publisher is an object that contains the definition of the event and the delegate. false
59) Match the following delegate concepts with there implementation

Delegate Implementation Syntax

Declaring Delegates TestDelegate Var = new TestDelegate(Func);

Instantiating Delegates Public delegate void TestDelegate(string arg);

Using Delegates TestDelegate(“Test”);

60) State whether the given is true or false.


Delegates used with the events should be declared void. true
13.22
61) State whether the following statement is true or false:
Reflection emit allows creation of new types at runtime. true
62) Consider the following statements:
Statement A: Named parameters are used to specify essential information of an attribute.
Statement B: Positional parameters are used to convey optional information in an
attribute.
a. Statement A is false, statement B is true.
b. Statement B is true, statement B is false.
c. Both statements A and B are true.
d. Both statements A and B are false.
63) Which predefined attribute allows you to call an unmanaged code in programs
developed outside the.NET environment?
a. Conditional
b. DLLImport
c. Obsolete
d. WebMethod
64) Attribute property indicates that if an attribute is applied to base class and all its
derived classes. Inherited
65) Which window displays the complete metadata information of an application
containing the custom attributes? MetaInfo
14.21
66) What is Just-In-Time compilation?
The Just-In-Time (JIT) compilation translates the code in IL into machine
language á and when required
67) Which CLR feature ensures that data types are accessible across different
applications? Type safety
68) What is project output?
An executable file (.exe) and dynamic link library (.dll) created when a project is
built is called the project output
69) Which Visual C# template allows you to create a custom control that can be used in a
GUI game?
a. Windows Control Library
b. Device Application
c. Class Library
d. Crystal Repots Application
70) You need to select the option from the Debug menu to execute a game developed in
Visual Studio .NET. Start Debugging
71) State whether the given statement is true or false:
JIT compilation saves time and memory required to convert the complete IL into
machine language. True
GUI - I
1.13
72) The dialog box does not allow you to work on an application as long as the
dialog box is not close. Modal
73) State whether the following statement is true or false.
A system modal dialog box allows you to switch to another area of the
application, which has invoked the dialog box. False
74) What is the difference between the system modal and modeless dialog boxes?
When the system modal dialog box appears on the screen it does not allow a user
to switch to or inter act with any other Windows application until the system
modal dislog box disappears. However, a modeless dialog box allows a user to
switch to another area of the application, which has invoked the dialog box or
another Windows application, while the modeless dialog box is being displayed.
75) The .dll extension stands for . Dynamic link libraries
76) State whether the flowing statement is true or false.
In dynamic linking the program does not need recompilation if the library is update. True
2.30
77) What is the expanded from of JIT? Just-in-time
78) Which template in the Project types pane of the New Project dialog box is used to
create a custom control that can be added to the user interface?
Windows Control Library
79) You need to select the option from the Debug menu to execute an
application developed in Visual Studio 2005. Start Debugging
80) Name the three navigational features provided by the Visual Studio .NET IDE?
The three navigational features provided by the Visual Studio.NET IDE are:
a. Docking
b. Tabbed navigation
c. Auto hide
81) State True or False.
During JIT compilation, code is checker for type safety. True
3.55
82) Which namespace will you include to inherit a Form class?
a. System.Windowns
b. System.Text
c. System.Windows.Forms
d. System.Drawing
83) What is the third step of a typical drag-and-drop operation?
a. Handle the DragDrop event of destination control
b. Set the AllowDrop property of destination control
c. Handle drag event
d. Call the DoDragDrop menthod
84) What is the default maximum size of text that a user can enter in the TexBox control
?
a. 2K
b. 4K
c. 8K
d. 12K
85) The default value of the SelectionMode property of the ListBox is:
a. None
b. One
c. MultiSimple
d. MultiExtended
86) Which property of the ListBox control is not available at design time ?
a. Sorted
b. Item
c. SlectionMode
d. SelectItem
4.25
87) Which of the following property is user to fill any remaining space on the statusStrip
control with the StatusLabel control?
a. Text property
b. Spring property
c. Size property
d. Padding property
88) Name the property, which specifies the layout orientation of the StatusStrip control.
The LayoutStyle property
89) Name the property of the ErrorProvider control, which indicates the rate in
milliseconds at which the error icon blinks. The BlinkRate property
90) List the child controls that can be added to the StatusStrip control.
The child controls that can be added to the StatusStrip control are:
a. StatusLabel
b. ProgressBar
c. DropDownButton
d. SplitButton
91) Name the property, which is added to the property list of a form when an
ErrorProvider control is added to the form.
The Error on <erorProviderControlName> property
5.49
92) Which of the following class cannot be instantiated directly?
a. ColorDialog class
b. FontDialog class
c. FileDialog class
d. OpenfileDialog class
93) Which of the following method is overridden by the classes inherited from
CommonDialog class?
a. Show()
b. ShowDialog()
c. RunDialog()
d. FilwDialog()
94) Whith of the following common dialog enables user to retrieve the path of a folder?
a. FileDialog()
b. FolderBrowserDialog()
c. OpenFileDialog()
d. SaveFileDialog()
95) To create a custom dialog box, you need to set the value of a form prpperty to
FixedDialog. Which of the following properties should you use?
a. FormBorderStyle
b. RightToLeftLayout
c. AutoScaleMode
d. WindowState
96) Which of the following value is the default value of MergeAction property of
ToolStripMenuITem control?
a. Append
b. Insert
c. Replace
d. Remove
6.58
97) Indentify the category under which the ReportSource property of the CrytalReport
Viewer control appears in the property window.
a. Data
b. Layout
c. Design
d. Misc
98) Name the object which is inserted in a Crystal Reports when the data is to be
displayed in the form of compact rows, columns, and summary fields.
a. Charts
b. Cross-tab objects
c. ReportLabels
d. Da te and Time
99) Name the section of Crystal Reports that displays the actual values in the report.
a. Report Footer
b. Report Header
c. Page Header
d. Details
100) Indentify the property which can be user to get or set a value indicating how
large the pages will appear.
a. AutoZoom
b. Document
c. Zoom
d. AntiAlias
101) Which event of the PrintDocument object is used to specify the text which is to
be printed?
e. QueryPageSettings
f. EndPrint
g. BeginPrint
h. PrintPage
7.67
102) The propety of a control specifies a name for the control by which the
accessibility aids identify the control.?
a. Name
b. AccessibleName
c. AccessibleAidName
d. AccessibleIdentity
103) Which of the following option lists the culuture code for Chinese language,
China region?
a. en-CA
b. fr-FR
c. zh-CN
d. de-DE
104) Which of the following involves customizing an application for specific
cultures?
a. Globalization
b. Localization
c. Culture-specific formatting
d. Deployment
105) Which property for a form needs to be set to implement right-to-left display?
a. RightToLeft
b. Direction
c. Display
d. TextAlign
106) Which method is used to convert an existing encoding to Unicode?
a. Encoding.GetEncoding
b. Encoding.ToUnicode
c. Encoding.Convert
d. Encoding.Translate
8.36
107) What are user-defined components?
The controls, which are created by the programmer as per the requirements, are
called user defined controls
108) Name the categories of .NET components.
.NER components can be categorized into two types. The types are
a. In-process components
b. Out-of-process components
109) Name the accessors that are used to red and set the value of a private variable in
a property. Get and Set
110) Which is the base class of user controls?
a. System.Windows.Forms.TextBox
b. System.Windows.Forms.Control
c. System.Windows.Forms.UserControl
d. System.Windows.Forms.Button
111) 5.Name the types of user-defined controls
There are three types of user-defined controls. These are:
a. User control
b. Controls inherited from an existing control
c. Custom control
9.26
112) 1.What is the difference between Synchronous and Asynchronous
programming?
In synchronous programming, each time a function is called program execution
waits until that function is completed. before continuing with the next line of
code. Asynchronous programming allows the user to perform other tasks while
the computer is executing a function, which is taking a long time to complete.
113) Name the method. which requests the cancellation of a pending background
.operation. The CancelAsync() method
114) What is a race condition?
It is a condition that occurs when the outcome of a program depends on which of
the thread gets access to a particular block of code first.
115) Define a deadlock?
It is a situation that occurs when a thread tries to lock a resource that is already
locked by another thread.
116) Identify the class that controls access to objects by granting a lock for an object
to a single thread.
a. Monitor
b. Mutex
c. Threadpool
d. Semaphore
10.60
117) What is an assembly?
An assembly is the smallest deployable unit. An assembly file has an extension of
.dll or .exe.
118) Identify the elements of an assembly.
The elements of an assembly are:
a. Manifest
b. MSIL Code
c. Required Resources
119) Which strong naming utility is used to generate a public/private key pair?
sn.exe
120) Which is the option in the Security tab of the properties dialog box of an
application that can be used to analyze code and determine the permissions required
by the application/ Calculate Permissions
121) List the launch conditions.
There are five launch conditions. These are:
a. File launch condition
b. Registry launch condition
c. Windows Installer launch condition
d. .NET Framework launch condition
e. Internet Information services (IIS) launch condition
11.42
122) What is the extension of a configuration file?
a. .config
b. .exe
c. .mcs
d. .cs
123) Name the three types of configuration files.
The three types of configuration files are:
a. Application configuration files
b. Machine configuration files
c. Security configuration files
124) Which element is a child element of <dependentAssembly>?
a. <runtime>
b. <assemblyBinding>
c. <bindingRedirect>
d. <supportedRuntime>
125) Which element is used to specify the version of the CLR that an application
support?
a. <runtime>
b. <supportedRuntime>
c. <codebase version=”000”>
d. <publisherpolicy>
126) Name the types of Identity objects provided by.NET Framework
The .NET Framework provides the following types of Identity objects:
a. Windows Identity
b. Generic Identity
Knowledge Bank – GUI
1.15
127) Identify the correct steps in the process of compilation of the source code within
the .NET Framework
a. 1. The compiler translates the code into Intermediate Language (IL).
2. The JIT compiler converts the IL into machine language during runtime.
b. 1. The compiler translates the code into machine language
2. The JIT compiler converts the machine language.
c. 1. The JIT compiler translates the code into Intermediate Language (IL).
2. The IL code is converted into the machine language during run time.
d. 1. The JIT compiler translates the code into Intermediate Language (IL).
2. The JIT compiler then converts the IL into machine language during run time.
128) John has been assigned a task of developing a student registration system in the
.NET Framework. To accomplish this task, he has developed various forms for
different purposes. In addition, he has added different classes and images in his
project. Which of the following windows would enable John to view the list of the
items he has added in his project?
a. Properties window
b. Solution Expoler window
c. Dynamic Help window
d. Output window
129) Henry is developing a Windows-based application for a library system in .NET.
While developing the application, he constantly needs to refer to the Solution
Explorer window to add or remove items from the project. Therefore, he wants to
place the Solution Exporer window fixed along the edge of the parent window. Which
navigation feature should John use?
a. Floating
b. Hide
c. Dockable
d. Auto hide
130) Sam is developing a Windows-based application in C#. Currently, there are two
forms in his application, Form1 and Form2. Form1 is set as the startup form. He
needs Form2 to be displayed when he clicks the button, named Show, on Form1.
What code should Sam write on the click event of the button control to accomplish
his task?
a. Form1 obj= new Form1();
obj.Close();
b. Form1 obj = new Form1();
obj.Hide();
c. Form2 obj = new Form1();
obj.Activate();
d. Form2 obj = new Form1();
obj.Show();
131) John is developing a Windows=based application for library management
system in .NET . He has added a new form, Form1, to the project. This form contains
a listbox called listBooks, which would display a list of all the books in the library.
However, he does not want the listbox to be displayed initially when the form
loads.Which of the following code snippet would enable John to accomplish this
task?
a. private void Form1_Load(EventArgs e, object sender)
{
listBooks.Hide();
}
b. private void Form1_Load( object sender, EventArgs e)
{
listBooks.Hide();
}
c. private void Form1_Load( object sender)
{
listBooks.Hide();
}
e. private void Form1_Load(EventArgs e)
{
listBooks.Hide();
}
1.17
132) Which of the following is the default value of the StartPosition property of a
windows form?
a. Manual
b. CenterScreen
c. WindowsDefaultLocation
d. WindowsDefaultBounds
133) Which of the following is the correct syntax to add items to a ListBox control at
runtime?
a. Listbox1.Items.Add(“Australia”);
b. Listbox1.Items.Add(Australia);
c. Listbox1. Add . Items (“Australia”);
d. Listbox1. Add . Items =“Australia”;
134) What of the following is the default value of the Selectionmode property of the
ListBox control?
a. One
b. None
c. MultiSimple
d. MultiExtended
135) Which of the following controls is used to set a format for the user input?
a. NotifyIcon
b. PropertyGrid
c. CheckedListBox
d. MaksedTextBox
136) Which of the following syntax is correct for connecting the click event with
code that specifies the event handler?
a. btn.Click += new EventHandler(btn_Click);
b. btn_Click += new EventHandler(btn_Click);
c. btn.Click += new EventHandler(btn.Click);
d. btn.Click += new EventHandler();
137) The Form class is derived form the class.
a. control
b. Forms
c. Container
d. Windows
138) Which property is used to specify whether a form will be displayed as a normal,
maximized. or minimized window on startup?
a. StartPosition
b. Position
c. WindowState
d. SizeGripStyle
139) Which of the following is NOT a method?
a. SetDesktopLocation
b. Show
c. Initialize
d. Activate
140) Identify the event of the form that can be used to initialize variables.
a. Load
b. Activate
c. Paint
d. Enter
141) Which property is used to set or retrieve the position of the currently selected
item in the list box?
a. SelectedIndex
b. Index
c. SelectedItem
d. Items
2.12
142) Identify the class, which has the PrintPage event.
a. PrintDocument
b. PrintPreview
c. Printdialog
d. PageSetupDialog
143) Name the namespace that needs to be used for the PrintingPermission class.
a. System.Drawing
b. System.Drawing.Print
c. System.Drawing.Printing
d. System.Print
144) Identify the property of the PrintPreviewControl, which is used to get or set
page settings.
a. Document
b. DefaultPageSettings
c. StartPage
d. Zoom
145) The Show() method of the MessageBox class takes parameters.
a. 2
b. 3
c. 4
d. 5
146) If you want to have a question mark icon in the message box, which of the
following options would you choose.
a. MessageBoxIcon.Question
b. MessageBoxIcon.QuestionMark
c. MessageBoxIcon.Warning
d. MessageBoxIcon.Exclamation
147) Which of the following is NOT a child control of the StatusStrip control?
a. SplitLabel
b. ProgressBar
c. DropDownButton
d. SplitButton
148) Identify the property that specifies the amount to increment the current value of
the control when the Perform Step() method is called
a. Step
b. Minimum
c. Maximum
d. Value
149) You need to arrange all the opened child forms of an MDI form in a vertically
tiled maner.Identify the correct code for this
a. this.LayoutMdi(MdiLayout.TileVertical);
b. this.MdiLayout (LayoutMdi.TileVertical);
c. this.LayoutMdi(MdiLayout.Vertical);
d. this.LayoutMdi(MdiLayout. VerticallyTiled);
150) Which of the following is NOT an MdiLayout value?
a. ArrangeIcons
b. CascadeIcons
c. TitleHorizontal
d. TitleVertical
151) The PageSettings class is included in the namespace.
a. System.Drawing.Printing
b. System.Printing
c. System.Drawing
d. System.Printing.Drawing
3.14
152) Match the following components of the report designner with their respective
descriptions.

Column A Column B

Report Header It contains field titles of the report. It is


displayed at the top of each page of the
report.

Page Header It is displayed at the end of each page of


the report.

Report Footer It contains the report title. It appears at


the start of the report.

Page Footer It is displayed at the end of the report.

153) Sam wants to develop an application in .NET Framework in which he wants to


implement German language formatting for most of the elements.Identify the correct
code snippet that would enable Sam to accomplish his task?
a. CultureInfo myCulture =new CultureInfo();
myCulture.CultureTypes = “de-DE”;
Thread.CurrentThread.CurrentCulture = myCulture;
b. CultureInfo myCulture = new CultureInfo(“de-DE”);
Thread.CurrentThread.CurrentCulture= myCulture;
c. CultureInfo myCulture = new CultureInfo(Thread.CurrentThread.CurrentCulture);
myCulture.CultureTypes = “de-DE”;
d. CultureInfo myCulture = new CultureInfo(de-DE);
Thread.CurrentThread.CurrentCulture = myCulture;
154) John is developing a Windows-based application that generates the sales report
using the .NET Framework. The application involves the use of crystal reports to
generate reports in a presentable format. The details related to sales are stored in a
database. John wants to display the number of each record of the table being
displayed in the report. He also wants to display the page number in the report.Which
field should John use in the Field Explorer window to accomplish his task?
a. Formula Fields
b. Group Name Fields
c. Special Fields
d. Running Total Fields
155) Which of the following holds TRUE for the Pull model?
a. The Pull model is used to access data from the data source is cached in a dataset.
b. The Pull model is used to access data from the data source without writing the
code for creating a connection.
c. The Pull model is generally useful for connection sharing scenarios.
d. The Pull model is used to fill the dataset before executing the application to view
the crystal report.
156) What happens when you select the As a Blank Report option in the crystal
report gallery?
a. It opens the Crystal Reports Designer where you can add the fields to be
displayed in the Crystal Reports.
b. It creates a new Crystal Reports with the same design as another report that you
specify.
c. It guides you through the process of report creation and creates a report based on
the choices that you make.
d. It opens the Crystal Reports Designer in which some default fields are already
added.
157) What happens when you select the Using the Report Wizard option in the
crystal report gallery?
a. It opens the Crystal Reports Designer where you can add the fields to be
displayed in the Crystal Reports.
b. It creates a new Crystal Reports with the same design as another report that you
specify
c. It guides you through the process of report creation and creates a report based on
the choices that you make
d. It opens the Crystal Reports Designer in which some default fields are already
added.
158) Which section in the Report Designer displays the actual values in the report?
a. Report Header
b. Details
c. Report Footer
d. Page Header
159) Which section in the Report Designer should be used to display some
information at the end of each page of the report?
a. Report Header
b. Details
c. Page Footer
d. Page Header
160) Which of the following holds TRUE for the flobalization phase of
internationalization?
a. It involves testing an application, which has been globalized to ensure that its
executable code is independent of the culuture and language specific data.
b. It involves writing the executable code for an application in such a way that
makes it culture-neutral and language-neutral.
c. It involves testing how the application adapts itself to various locales.
d. It involves the customization of an application for a specific locale.
161) Which of the following holds TRUE for the localization phase of
internationalization?
a. It involves testing an application, which has been globalized to ensure that its
executable code is independent of the culture and language specify data.
b. It involves writing the executable code for an application in such a way that
makes it culture-neutral and language-neutral
c. It involves testing how the application adapts itself to various locales.
d. It involves the customization of an application for a specific locale.
162) Which namespace should be used to implement globalization and localization in
your applications?
a. System.Net
b. System.Resources
c. System.Globalization
d. System.Collections
163) Which of the following class is used to access culture information?
a. Compareinfo
b. CultureInfo
c. RegionInfo
d. NumberFormatInfo
164) Which of the following fields in the Field Explorer window is used to insert
calculated fields?
a. Parameter Fields
b. Special Fields
c. Group Name Fields
d. Formula Fields
4.12
165) John is creating a .NET application using Visual C#. In a form, he has added a
Button control, named button1, and a ToolTip control, named toolTip1. Now he
wants to set the value of the tooltiptext property for the button1 control as “Save a
record”. Which of the following code will correctly set the tooltiptext property?
a. button1.ToolTipText =”Save a record”
b. toolTip1.ToolTipText = “Save a Record”;
c. toolTip1.SetToolTip(button1, “Save a record”);
d. button1.SetToolTip(toolTip1, “Save a Record”)
166) John is creating a .NET application using Visual C#. He has added a ToolTip
control in a windows form to display the tool tip for the controls present in the form.
He wants to make sure that a tool tip displays for five seconds when the mouse
pointer is stationary on a control. Which of the following property of the ToolTip
control does he need to set to per form this activity?
a. AutomaticDelay
b. AutopopDelay
c. InitialDelay
d. ReshowDelay
167) Henry is creating a .NET component named Calculations. He wants that this
component can be used inside the assembly only. What should be the access level of
the constructor written for the Calculations component?
a. public
b. private
c. protected
d. internal
168) Henry is creating a .NET application using Visual C#. To implement the help
system in the application, he has created a help file. He also added a HelpProvide
control in the form. Now he wants to attach the help file with the application. Which
of the following property of the HelpProvider control he needs to set to perform this
activity?
a. HelpNamespace
b. HelpKeyword
c. Helnavigator
d. HelpString
169) Henry is creating a .NET application using Visual C#. In a Windows form he
adds a Button control, named button1. Now he wants to provide the popup help for
button1. Identify the correct steps to perform this activity.
a. 1. Set the MinimizeBox and MaximizeBox properties of the form to False.
2. Set the HelpButton property of the form to true.
3. Add a HelpProvider control named helpProvider1 to the form.
4. Set the HelpString on helpProvider1 property of the button1 control to specify
the help text for the control.
b. 1. Set the MinimizeButton and MaximizeButton properties of the form to False.
2. Set the HelpButton property of the form to true.
3. Add a HelpProvider control named helpProvider1 to the form.
4. Set the HelpKeyword on helpProvider1 property of the button1 control to
specify the help text for the control.
c. 1. Set the Minimize and Maximize properties of the form to False.
2. Set the HelpButton property of the form to true.
3. Add a HelpProvider control named helpProvider1 to the form.
4. Set the HelpString on helpProvider1 property of the button1 control to specify
the help text for the control.
d. 1. Set the MinimizeButton and MaximizeButton properties of the form to False.
2. Set the HelpButton property of the form to true.
3. Add a HelpProvider control named helpProvider1 to the form.
4. Set the HelpKeyword on helpProvider1 property of the button1 control to
specify the help text for the control.
170) Which of the following is NOT a type of constructor?
a. Internal Private constructors
b. Public constructors
c. Internal constructors
d. Private constructors
171) Which of following does NOT come under the category of user-defined controls
provided by the .NET Framework?
a. Activex Controls
b. Custom controls
c. Controls inherited from an existing control
d. User control
172) Which of the following controls are also called composite controls?
a. Activex Controls
b. Custom controls
c. Controls inherited from an existing control
d. User controls
173) Identify the correct path where the dll file is created when a user control is
created and compiled?
a. <Application Folder>\bin\Debug
b. <Application Folder>\Debug
c. <Application Folder>\Debug\bin
d. C:\program files\bin\debug
174) Which of the following methods has to overridden to change the appearance of
the control that is inherited from an existing control?
a. CreateControl()
b. BeginInvoke()
c. Paint()
d. OnPaint()
175) Identify the dialog box, which is used to add a user-defined component in any
project.
a. Add Control
b. Add Component
c. Add Reference
d. Add Class
176) A property is created by using only the Get accessor. Which type of property it
is?
a. Read Only
b. Write Only
c. ReadWrite
d. Execute only
177) All user controls inherit the class.
a. System.Windows.Forms.UserControl
b. System.Windows.UserControl
c. System.Forms.UserControl
d. System.Forms.Windows.UserControl
178) The Windows Control library Template is used for:
a. Creating a user control
b. Creating a user component
c. Creating a device application
d. Creating a setup project
179) Which of the following is not a type of user-defined control provided by .NET
Framework?
a. User control
b. Control inherited from an existing control
c. Custom controls
d. Typed Controls
5.6
180) John has developed a Windows-based application in C# that involves the use of
multiple threads. He wants to keep a check in his application so that the total number
of threads that accesses resources concurrently is limited. Which class should John
use to accomplish this task?
a. Monitor
b. Semaphore
c. Mutex
d. ReadWriteLock
181) Henrry is required to remove an assembly, Info.dll, from the global assembly
cache.Which command should he type in the command prompt to accomplish this
task?
A. gacutil Info.dll -u
B. gacutil -I Info.dll
C. gacutil -u Info.dll
D. gacutil Info.dll - I
182) Mary has modified an exiting assembly and saved the same with the final
changes. The version number of the final assembly is 6.3.1.2. She now builds the
project, which increments the build number of the assembly by one. Identify the
updated version number of the assembly.
a. 6.3.2.2
b. 7.3.1.2
c. 6.4.1.2
d. 6.3.1.3
183) John wants to specify the version of the CLR that his application supports.
Which of the following code snippet would enable John to accomplish his taks?
a. <configuration>
<startup>
< gcConcurrent version =”v1.1.3522”/>
</startup>
</configuration>
b. <configuration>
<startup>
< supportedRuntime version =”v1.1.3522”/>
</startup>
</configuration>
c. <configuration>
<startup>
< codeBase version =”v1.1.3522”/>
</startup>
</configuration>
d. <configuration>
<startup>
< bindingRedirect version =”v1.1.3522”/>
</startup>
</configuration>
184) Sam has developed a Windows-based application in C#. He wants to implement
a restriction in his application so that the program will not be able to access the
registry or security policy settings of the system. In addition, the program should not
be able to access the local file system without user intervention. However, the
program should be able to connect back to their site of origin, resolve domain names,
and use all Windows resources except the registry or security policy settings. Which
trust level should Sam implement to accomplish this task?
a. Full trust
b. Medium trust
c. Low trust
d. No trust
5.8
185) Which special folder server as a repository that stores data and document for
each user?
a. User’s Desktop
b. User’s Favorites Folder
c. User’s Personal Data Folder
d. User’s Programs Menu
186) Which special folder contains shared system fields?
a. Windows Folder
b. Common fiels Folder
c. Program Fiels Folder
d. System Folder
187) Which registry key stores configuration information?
a. HKEY_CLASSES_ROOT
b. HKEY_CURRENT_USER
c. HKEY_LOCAL_MACHINE
d. HKEY_USERS
188) Which of the following registry keys stores information about file extensions
and their association with executable files?
a. HKEY_CLASSES_ROOT
b. HKEY_USERS
c. HKEY_CURRENT_USER
d. HKEY_LOCAL_MACHINE
189) Which of the following elements is used to specify the supported runtime
versions in a configuration file?
a. <supportedRuntime>
b. <gcConcurrent>
c. <codebase>
d. <probing>
190) You need to search for a specific file on the target computer or a key in the
registry Identify the editor to be used?
a. Launch Conditions Editor
b. User Interface Editor
c. Custom Actions Editor
d. File TypesEditor
191) Which of the following elements specifies whether the CLR runs garbage
collection on a separate thread?
a. <supportedRuntime>
b. <probing>
c. <codebase>
d. <gcConcurrent>
192) Identify the editor that allows you to add project output, such as.exe and. dll
files and additional files, such as readme.txt to the deployment project
a. File System Editor
b. Registry Editor
c. File Types Editor
d. User Interface Editor
193) Which editor will you user if you have to set values for environment variables
or specify the Control Panel settings for the target computer?
a. File system Editor
b. Registry Editor
c. File Types Editor
d. User interface Editor
194) Which registry key stores configuration information, such as the hardware
components used by a computer?
a. HKEY_CLASSES_ROOT
b. HKEY_USERS
c. HKEY_CURRENT_USER
d. HKEY_LOCAL_MACHINE
Knowledge Bank – C#
1.16
195) Which of the following options is NOT true about object-oriented programing?
a. The object-oriented approach allows systems to evolve.
b. Object cannot respond diferently to same mesages
c. Object oriented programing facilitates
d. The object-oriented approach sllows you to identify entities as objects having
attributes and behavior.
196) Console class is part of which namespace?
a. Collections
b. Data
c. System
d. Security
197) Which of the following is the correct syntax to comment a line of code?
a. /
b. //
c. \
d. \\
198) Which of the following is a type of arthmetic operator?
a. %
b. +=
c. ++
d. >=
199) Which of the following is a type of arthmetic assignment operator?
a. %
b. +=
c. ++
d. >=
200) Which of the following operator should be used to evaluete an expression that
returns TRUE when all the conditions are true?
a. !
b. &&
c. =
d. ==
201) Which of the following is a conditional construct?
a. if-else
b. while
c. do-while
d. for
202) How many memory bytes are required to store a value of a double data type?
a. 4
b. 1
c. 8
d. 2
203) Which keyword is used to include a namespace in a program?
a. class
b. using
c. namespace
d. enum
204) Which of the following is used to compile a program writen in C#?
a. csc<filename>.cs
b. <filename>.cs
c. <filename>
d. <filename>.csc

2.15
205) Which of the following option holds true for CLR?
A. It provides only memory allocation service.
B. It allows the execution of code across different platforms
C. It translates the code into Intermediate Language.
D. It consists of a set of common rules followed by all the languages of .NET
206) What happens during JIT compiletion?
A. Management allocation and deallocation of memory
B. Conversion of intermedia language into machine language.
C. Loading assemblies in the memory.
D. Identification of namespace in the assemblies
207) What happens during garbage collection?
A. Management of allocation and deallocation of memory
B. Conversion of intermedia language into machine language.
C. Loading assemblies in the memory.
D. Identification of namespace in the assemblies
208) Which of the following does NOT holds true for namespace?
A. They are single deployable units that contain all the information about the
implementation of classes, structures, and interfaces.
B. They are logical groups of related and interfaces.
C. Thay avoid any naming conflict between alasses, which have the same names.
D. They enable you to access the classes belonging to a namespace by simply
importing the namespace into the application.
209) Which of the following iis NOT a feature of the .NET framework?
A. Consistent programing model
B. Multi language intergration
C. Manual resource amanegement
D. Ease of deployment
2.16
210) Which of the following access specifiers allows a class to hide its member
variables and member functions from other class objects and function?
A. private
B. protected
C. internal
D. protected internal
211) Which of the following access specifiers allows a class to hide its member
variables and member functions from other class objects and function, except the
child class?
A. private
B. protected
C. internal
D. protected internal
212) Which of the following is the default access specifier for a class?
A. private
B. protected
C. internal
D. protected internal
213) Which of the following is NOT a parameter passing mechanism?
A. values
B. InputOutput
C. Reference
D. Output
214) Which of the following statement is NOT true ragarding the Output parameter?
A. The variable that is supplied for the output parameter need to be assigned a valu
before the call is made
B. Output parameter is a reference to a storage location subplied by the caller
C. Output parameters transfer data out of the method
D. Output paremeters can be used to return more than one value

215) Name of the feature of OOPs, which involves extracting only the relevant
information
A. Abstraction
B. Encapsulation
C. Inheritance
D. Polymorphism
216) Name the element of a method. which determines the extent to which a variable
or method can be accessed from another class?
A. Method name
B. Paremeter list
C. Method body
D. Access specifier
217) Name the element of a method. which needs to be unique and is case-sensitive?
A. Method name
B. Paremeter list
C. Method body
D. Access specifier
218) Name the element of a method. which contains the set of instructions needed to
complete the required activity?
A. Method name
B. Paremeter list
C. Method body
D. Access specifier
219) Identify the correct syntax for defining a method?
A. <Access specifier> <Return Type> <Method Name> (Parameter List)
B. <Access specifier> <Method Name> <Return Type> (Parameter List)
C. <Access specifier> (Parameter List) <Return Type> <Method Name>
D. <Return Type> <Method Name> (Parameter List)
3.15
220) John has to write code in C# in which he needs to implement a search operation
to search the details of a student on the basic of his/her roll number. Which of the
following class of the System.Collection namespace would be the most appropriate to
enable John to accomplish this task?
A. Hashtable
B. ArrayList
C. Queue
D. Stack
221) Which of the following is a correct syntax to initialize an array in C#?
A. int[ ] Score = new int[10];
B. int[10] Score = new int[ ];
C. int[10] Score = new int[10];
D. int[10] Score = new int[ ];

222) Henry is assigned the responsibility of writing a program to handle the booking
of tickets in a movie theatre. He needs to ensure that the request that came first for
booking tickets should be processed first before the next request. Which of the
following class of the System.Collection namespace would enable Henry to
accomplish this task?
A. Hashtable
B. ArrayList
C. Queue
D. Stack
223) Consider the following code snippet:
class Test
{
int a. b;
string str;
Test()
{
Console.WriteLine("Hello");
}
Test(int i)
{
a = i;
}
Test(int i, string s)
{
a = i;
str = s;
}
Test(string s)
{
str = s;
}
}
}
How will you initialize class, Test, if you just want to display “Hello” on the screen?
A. Test obj = new Test();
B. Test obj = new Test(17);
C. Test obj = new Test(17,”Hello”);
D. Test obj = new Test(“Hello”);
224) Which of the following holds true for the Finalize() method?
A. CLR calls the Finalize() destructor using a system called reference-tracing
garbage collection
B. The Idisposable interface constains the Finalize() method
C. The Finalize() destructor is called before the last reference to an object is released
from memory
D. The .NET Framwork cannot automatically call the Finalize() destructor to destroy
objects in memory
3.17
225) Which of the following statements is NOT true about constructor?
A. A constructor is used to initilize members of the class
B. A constructor is complementary to a destructor
C. A constructor is invoked when a new instance of a class is created
D. A constructor needs to be called explicitly
226) Which of the following statements is true about static constructors?
A. Static constructors are called whenever an instance of a class is created.
B. Static constructors have implicit private access
C. Static constructors are used to initialize all the variable of a class
D. The static keyword is optional while declaring a static constructor.
227) Which of the following statements is NOT true about destructors?
A. Destructors are used to release the instance of a class from memory
B. A programmer has no control on when to call the destructor
C. Destructors can be overloaded
D. A destructor has the same name as its class, but is prefixed with a~.
228) Which of the following statements is NOT true about function overloading?
A. The number of arguments and their types could be the same, but the return type
should be diffrent?
B. The number of arguments and their types could be the same, but thier sequence
C. The number of aguments or thier types must be different
D. The function must have the same name
229) Which of the following operators CANNOT be overloaded?
A. =
B. ++
C. -
D. +
230) Identify the correct syntax for creating an object?
A. Calculator c1 = new Calculator();
B. Calculator c1 = new Calculator;
C. Calculator c1 = new calculator();
D. calculator c1 = new Calculator();
231) Identify the correct syntax for creating a destructor for a class named Calculator
A. Calculator()
B. ~Calculator()
C. Calculator
D. ~Calculator
232) You need a function that converts distance in kilometers to miles, and kilometers
can either be an integer or a float. Which OOPs concept would you use?
A. Inhertance
B. Polymorphism
C. Encapsulation
D. Data Hiding
233) Identify the operator that takes two operands
A. ~
B. ++
C. --
D. +
234) Identify the operator that can be overload
A. =
B. ?:
C. .
D. ==
4.11
235) Consider a class, Student, which consists of different attributes and behaviors.
What will be the relationship between a student, John, and the class, Student?
A. Instantiation
B. Utilization relationship
C. Inheritance relationship
D. Composition relationship
236) Consider a class, Cat, Lions, Tigers, and Leopards belong to the cat family.
Identify the relationship between Cat and Lion.
A. Instantiation
B. Utilization relationship
C. Inheritance relationship
D. Composition relationship
237) Consider two classes, CPU and motherboard. Identify the relationship between
the two?
A. Instantiation
B. Utilization relationship
C. Inheritance relationship
D. Composition relationship
238) 4. Consider the following program:
class A
{
public A()
{
Console.WriteLine("Inside A");
}
}
class B : A
{
public B()
{
Console.WriteLine("Inside B");
}
}
class C : B
{
public C()
{
Console.WriteLine("Inside C");
}
public static void Main()
{
C obj = new C();
}
}
Identify the output of the program:
A. Inside A
Inside B
Inside C
B. Inside B
Inside A
Inside C
C. Inside C
Inside B
Inside A
D. Inside C
239) Consider the following program:
class A
{
public A()
{
Console.WriteLine("Welcome");
}
public A(string str1)
{
Console.WriteLine(str1);
}
public A(string str2)
{
Console.WriteLine(str2);
}
public static void Main()
{
A obj = new A("John");
}
}
Identify the output of the program
A. Welcome
John
B. John
Welcome
C. The code will give an error
D. John
4.13
240) Which namespace needs to be used for file handing?
A. System.Text
B. System.Generic
C. System.IO
D. System
241) Which member of the FileMode enumerator is used to open a file and then
delete its contents?
A. Create
B. CreateNew
C. Append
D. Truncate
242) Which member of the FileMode enumerator is used to open a file and add the
contents at the end?
A. Create
B. CreateNew
C. Append
D. Truncate
243) Which of the following is NOT a member of the FileAccess enumerator?
A. read
B. Write
C. ReadWrite
D. WriteRead
244) Identify the class that is used to write binary data to a stream
A. BinaryReader
B. BinaryWriter
C. StreamReaader
D. StreamWriter
245) Which access specifier allows a class to expose its member variables and
member function ro another function and objects?
A. private
B. internal
C. protected internal
D. friend

246) Which of the following code snippet is syntactically correct according to the
rules appliced for declaring the prefix and postfix notations for operator overloading?
A. internal static over operator++ (over X) { }
B. static static over operator++ (over X) { }
C. private static over operator++ (over X) { }
D. public static over operator++ (over X) { }
247) Constructor overloading is an approach to implement:
A. Inheriance
B. Abstraction
C. Static polymorphism
D. Dynamic polymorphism
248) Which of the following is not true about abstract classes?
A. cannot create an instance of an abstract class
B. Cannot declared an abstract method outside an abstract class
C. Cannot be declared sealed
D. Cannot be declared public
249) Identify the operator that cannot be overload
A. ?:
B. ==
C. !=
D. %
5.11
250) John is using the StreamWriter class in a program. He needs to write any
buffered data to the underlying stream. Which method of the StreamWriter class
should John use?
a. Flush
b. Close
c. Write
d. WriteLine
251) Mary needs to write code in C# that displays the names of all the files within
a specified directory. Identify the correct code snipper that would enable Mary to
accomplish this task.
a. DirectoryInfo MydirInfo = new DirectoryInfo(@”c:\WINDOWS”);
FileInfo FilesInDir = MydirInfo.GetFiles();
foreach (FileInfo file in FilesInDir)
{
Console.WriteLine (“File Name: {0}”; file.Name);
}
b. DirectoryInfo MydirInfo = new DirectoryInfo(@”c:\WINDOWS”);
FileInfo[] FilesInDir = MydirInfo.GetFiles();
foreach (FileInfo file in FilesInDir)
{
Console.WriteLine (“File Name: {0}”; file.Name);
}
c. DirectoryInfo MydirInfo = new DirectoryInfo(@”c:\WINDOWS”);
FileInfo[] FilesInDir = MydirInfo.GetFiles();
foreach (FileInfo file in MydirInfo)
{
Console.WriteLine (“File Name: {0}”; file.Name);
}
d. DirectoryInfo MydirInfo = new DirectoryInfo(@”c:\WINDOWS”);
FileInfo FilesInDir = DirectoryInfo.GetFiles();
foreach (FileInfo file in FilesInDir)
{
Console.WriteLine (“File Name: {0}”; file.Name);
}
252) Consider the following code snippet:
using System;

namespace ex
{
class exc_demo
{
int x = 0;
public void div(int a, int b)
{
try
{

x = a / b;
}
catch (DivideByZeroException e)
{
Console.WriteLine("exception {0}",e);
}
}
static void Main(string[] args)
{
exc_demo obj = new exc_demo();
obj.div(0, 10);
Console.ReadLine();
}
}
}
Identify the output of the preceding code snippet.
a. Will handle the exception occurred and display the result
b. Will not be able to handle the exception generated
c. Will display result = 0
d. It will compile but will not display any result
253) With regard to the FileInfo class, match the following properties with their
respective purpose

Column A Column B

Attributes Gets a Boolean value indicating whether


the file exists or not.

Exists Gets or sets attributes associated with the


current file. This property is inherited from
FileSystemInfo.

Directory Gets a string containing the full path of the


file. This property is inherited from
FileSystemInfo.

FullNam Gets an instance of the directory, to which


the file belongs

5.13
254) Which of the following class should be inherited to create a user-defined
exception?
a. System.ApplicationException
b. SystemException
c. System.InvalidCasException
d. System.IO.IOException
255) Identify the type of error –“division by zero”?
a. Syntax error
b. Run-time error
c. Logical error
d. Compile-time error
256) Identify the method of the StreamReader class that allows the read/write
position to be moved to any position within the file.
a. Seek
b. Peek
c. Read
d. ReadLine
257) Sam has created a program. It is running properly but is not giving the results
accordingly. Which type of error could there be in the program?
a. Compilation error
b. Run-time error
c. Logical error
d. Syntax error
258) Sam wants certain lines of code to be executed whether an error occurs or not.
Which of the following block should he use to write the code?
a. try
b. catch
c. finally
d. both catch and finally
259) System.NullReferenceException exception class handles:
a. IO errors.
b. Errors generated when method refers to an array element.
c. Errors generated during the process of dereferencing a null object.
d. Memory allocation to the application errors.
260) Which of the following is the method of the StreamWriter class?
a. Flush
b. Seek
c. Peek
d. Read
261) System.IndexOutOfRangeException comes under the category:
a. Systax error
b. Run-time error
c. Logical error
d. Compile-time error
262) The following code has an error:
FileStream fs = new FileStream(“c:\Myfile.txt”, FileMode.Open, FileAccess.Read);
Identify the correct code.
a. FileStream fs = new FileStream(“c:\\Myfile.txt”, FileMode.Open,
FileAccess.Read);
b. FileStream fs = new FileStream(“c:\Myfile.txt”, FileMode.Read.
FileAccess.Open);
c. FileStream fs = new FileStream(“c:\Myfile.txt”, FileMode.Open,
FileAccess.Write);
d. FileStream fs = new FileStream(“c:\Myfile.txt”, FileMode.Write,
FileAccess.Read);
263) Identify the correct statement regarding exception handling.
a. A try block must be followed by a catch block and a finally block.
b. A program can have only catch block and a finally block.
c. A program can have only a catch block.
d. A Try block must have at least one catch block
6.10
264) Choose the correct code to define the event named ehello that invokes a
delegate named hello.
a. Pulic delegate hello(); private event delegate ehello();
b. Pulic delegate void hello(); private event delegate ehello();
c. Pulic delegate hello(); private event ehello hello;
d. Pulic delegate void hello(); private event hello ehello();
265) Which of the following code snippet will be used to initialize the delegate object
where a delegate, PrintData, is defined in a class and WiteConsole and WriteFile are
two methods defined to print a string to the console and print a string to the file
respectively?
a. Public static void Main(){ PrintData p = new PrintData(WriteConsole);PrintData
p1 = new PrintData(WriteFile);}
b. Public static void Main(){WriteConsole p = new WriteConsole(PrintData);
WriteFile p1 = new WriteFile(PrintData);}
c. Public static void Main(){WriteConsole p = new WriteConsole(); WriteFile p1 =
new WriteFile();}
d. Public static void Main(){PrintData WriteConsole = new
PrintData(WriteConsole); PrintData WriteFile = new PrintData(WriteConsole);
}
266) Identify the output of the following code:
using System;
using System.IO;
namespace dele
{
public class dele_demo
{
public delegate void PData(String s);
public static void WC(String str)
{
Console.WriteLine("{0} Console", str);
}
public static void DData(PData PMethod)
{
PMethod("This shoud go to the");
}
public static void Main()
{
WC MlDelegate = new WC(PData);
DData(MlDelegate);
}
}
}
a. Will compile successfully bit generate a runtime error
b. Will display “This should go to the”
c. Will display “This should go to the console”
d. Will give compilation error
267) Match the states of a theread in column A with their corresponding explanation
in column B.

Column A Column B

Ustarted Thread is sleepin, waiting, or blocked

Statements of the thread’s method are


Runnable
complete

Start() method of the Thread class is


Not Runnable
called

Dead Instance of the Thread class is creater


6.12
268) Which method forces a thread into dead state?
a. Pulse()
b. Wait()
c. About()
d. Exit()
269) Which of the following code snippet sets the priority of a thread, Thread1, to the
hightest priority?
a. Thread1.Priority = ThreadPriority.Highest
b. Priority = threadPriority.Higest(Thread1)
c. Thread1.Priority = Highest
d. Thread1.ThreadPriority = Priority.Highest
270) Which of the following is NOT true relating to the synchronization of threads?
a. Synchronization of thread ensures that a shared resource can be used by only
one thread at a time.
b. Synchronization of threads can be achieved by using the synchronized keyword
c. You can invoke multiple synchronized methods for an object at any given time.
d. Synchronization is based on the concept of monitoring.
271) Which class enables you to serialize access to the blocks of code by means of
locks and signals
a. AppDomailManager
b. Monitor
c. Thread
d. AppDonain
272) Which state does a thread enter when it is set to the sleeping mode?
a. Runnable
b. Not runnable
c. Unstarted
d. Deard
273) Which does a thread enter when the Start() method is invoked ?
a. Runnable
b. Not runnable
c. Unstarted
d. Deard
274) Which of the following is the correct syntax for declaring a delegate?
a. Delegate <delegate-name><parameter list >
b. Delegate <return type><delegate-name>
c. Delegate <return type><delegate-name><parameter list >
d. <return type> Delegate <delegate-name><parameter list >
275) Which of the following is NOT true for a delegate?
a. A single-cast derives from the System.Delegate class.
b. Single-cast can call multiple methods at a time
c. A delegate is a refenrencectype type variable
d. Delegates are used for implementing events and the call-back methods
276) Which of the following is NOT true for a publisher?
a. Publisher contains the definition of the event.
b. Publisher does not contain the definition of the delegate
c. Publisher contains the association of the event with the delegate
d. Publisher fires the event. Which is notified to the other objects
277) is the process in which a single event is executed at a time.
a. Polling
b. Mutual Exclusion
c. Covariance
d. Contravariance
(7.11)
278) John wants to display the value of all the variables while debugging a code
written in C#. Which type of attribute should John use to accomplish his task?
a. Obsolete
b. WebMethod
c. DllImport
d. Conditional
279) Henry has developed a Web application in C#.He wants to expose some
business functions that he has developed, to other applications. Which type of
attribute should Henry use to accomplish this task?
a. Obsolete
b. WebMethod
c. DllImport
d. Conditional
280) Mary has developed a code in C# to display a list of first n natural numbers.The
total number of natural numbers to be displayed needs to be accepted from the user at
run time.If the user enters a value other than a numerical value, a beep sound should
be generated. However, to generate the beep sound, Mary needs to use the beep()
function present in a library developed in C language.Which attribute should Mary
use to this beep() function?
a. Obsolete
b. WebMethod
c. DllImport
d. Conditional
281) Sam is assigned a task to develop code in C# to display the names of all the files
of a particular directory.To accomplish this task, he has written a function,
printData().However, he is asked to modify printData() so that the file names are
displayed along with their respective extension.To do so, Sam writes a new function,
printDataNew(), which will now be used in the program.However, he also wants to
retain the printData() function.Which attribute should Sam user to retain the
printData() function?
a. Obsolete
b. WebMethod
c. DllImport
d. Conditional
(7.12)
282) Which of the following does NOT hold true for an attribute?
a. The values of attributes describe an object
b. Attributes convey information to runtime about the behavior of programmatic
elements, such as class and structure
c. The declarative tag of an attribute is depicted by curly braces({})
d. Attributes are used for adding metadata
283) Which of the following is the correct syntax to specify an attribute?
a. [attribute(positional_parameters, name_parameter=value,…)]element
b. [(positional_parameters, name_parameter=value,…)attribute]Element
c. {(positional_parameters, name_parameter=value,…)attribute}Element
d. { attributes (positional_parameters, name_parameter=value,…)}Element
284) How many arguments does AttributeUsage attribute allow?
a. 1
b. 2
c. 3
d. 4
285) Which of following is NOT true about reflection?
a. Used to view metadata
b. Used to perform type discovery
c. Used for static binding of methods and properties
d. Used for Reflection emit
286) Which object is used to view metadata using reflection?
a. MemberInfo
b. Attribute
c. type
d. Member
287) What is the purpose of using the DllImport attribute?
a. it is used for calling an unmanaged code in programs developed outside the .NET
environment
b. It is used expose method in a Web service
c. It is used for conditional compilation of method calls, depending on the specified
value.
d. It is used to inform the compiler to discard a piece of target element such as a
method of a class.
288) What is the purpose of Reflection emit?
a. It is used to view attribute information form the code at runtime.
b. It is used to create new types at runtime
c. It is used to call properties and methods on dynamically instantiated objects
d. It is used to examine various types in an assembly and instantiate those types
289) Which attribute enables you to discard a piece of target element such as a method
of a class?
a. Conditional
b. WebMethod
c. DllImport
d. Obsolete
290) Which attribute anebles you to configure the behavior of an exposed method in a
Web service?
a. Conditional
b. WebMethod
c. DllImport
d. Obsolete
291) Which of the following is NOT a member of the AttributeTargets enumerator?
a. Enum
b. WebMethod
c. Event
d. Variable

You might also like