c sharp

66
1- A ____ block enclose the code that could throw an exception. (1đ) A- Exception B- Try C- Error D- Catch 2- A local varicable (1đ) A- Is declared with keyword [local] before B- Can be used anywhere in the program C- Must accept a class D- Is declared within a method 3- A(n) ____ is a group of one or # (1đ) A- property B- class C- solution D- project 4- A method is declared as double CalcPay(int hoursWorked). Suppose you write a method containing int hours=35; and double pay; Which of the following represents the correct way to use the CalcPay method? (1đ) A- hours = CalcPay(pay); B- hours = CalcPay(); C- pay = CalcPay(hoursWorked); D- pay = CalcPay(hours); 5- A static method can only invoke other ____. (1đ) A- intance object B- static method C- method D- object

Upload: le-xuan-nguyen

Post on 28-Oct-2014

86 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: C Sharp

1- A ____ block enclose the code that could throw an exception. (1đ) A- Exception B- Try C- Error D- Catch

2- A local varicable (1đ) A- Is declared with keyword [local] before B- Can be used anywhere in the program C- Must accept a class D- Is declared within a method

3- A(n) ____ is a group of one or # (1đ) A- property B- class C- solution D- project

4- A method is declared as double CalcPay(int hoursWorked). Suppose you write a method containing int hours=35; and double pay; Which of the following represents the correct way to use the CalcPay method? (1đ)

A- hours = CalcPay(pay); B- hours = CalcPay(); C- pay = CalcPay(hoursWorked); D- pay = CalcPay(hours);

5- A static method can only invoke other ____. (1đ) A- intance object B- static method C- method D- object

6- A ____ allows the user to interact with # (1đ) A- controls B- Windows Forms C- component D- GUI

7- A delegate defines (1đ) A- a substitue for an inherited method

Page 2: C Sharp

B- a means of passing arrays into methods C- a Wahsington representative D- a class that encapsulates methods

8- A Panel is used to: (1đ) A- group or store components B- add style to a form C- create a border around components D- display text

9- A Constructor (1đ) A- must have the same name as the class it is declared within B- all of the other answers C- maybe overloaded D- is used to created objects

10- A GroupBox can be used to ____. (1đ) A- display B- sort C- organize D- group

Page 3: C Sharp

1- A (an) ____ can contain objects# (1đ) A- ArrayList B- Enumerators C- Collection D- Array

2- A method is declared as double CalcPay(int hoursWorked). Suppose you write a method containing int hours=35; and double pay; Which of the following represents the correct way to use the CalcPay method? (1đ)

A- hours = CalcPay(pay); B- hours = CalcPay(); C- pay = CalcPay(hoursWorked); D- pay = CalcPay(hours);

3- A Collection is a method to use if (1đ) A- The contents of your list will change by adding or removing member B- Your data items are not related C- The contents of your list are static D- You have a large volume of data items

4- A collection is a group of individual data items or # (1đ) A- properties B- Objects C- strings D- methods

5- A(n) ____ is a group of one or more projects that collectively form a Visual C# program. (1đ)

A- property B- class C- Project D- solution

6- A variable declared inside a method is called a ____ variable (1đ) A- Private B- Local C- Static D- Serial

7- A variable of a reference type contains: (1đ)

Page 4: C Sharp

A- information about the type and its data B- the address of the location in memory where data is stored C- data of the type D- None of the above

8- A delegate in C# is similar to: (1đ) A- a pointer B- object C- COM D- a function pointer

9- A positive a negative whole number between -2, 147, 483, 648, 345 and 2, 147, 483, 648, 345 would be best stored into a variable having which one of the following data types? (1đ)

A- Decimal B- Bollean C- int D- string

10- A TextBox can use the ____ property, meaning that the user do not see anything when they type in the textbox. (1đ)

A- Lock B- PasswordChar C- Pass D- NotVisible

Page 5: C Sharp

1- After double – clicking the English button, add the following code to the event handler: Private void buttonEnglish_Click(object sender, EventArgs e) { This. Text = "Do you speak English?"; } For the Click event, the first parameter, object sender, holds ____. (1đ)

A- the left mouse button make button clicked B- the form control that contain button was clicked C- the control that was clicked D- the value on the button

2- All class have ____ method. (1đ) A- ToInt32() B- ToLower() C- ToString() D- ToUper()

3- All types in C# implicitly derive from ____. (1đ) A- System.Csharp class B- System All class C- System class D- System.Object class

4- An instance method (1đ) A- Represents the instance of an object B- Represents another class C- Represents the attribute of an object D- Represents the behavior of an object

5- An instance variable ____. (1đ) A- represents an attribute of an object B- is an object of a class C- is a method of a class D- represents an property of an object

6- An Event is ___. (1đ) A- result of a party B- a eunning of a method C- code to force users action D- the result of a users action

Page 6: C Sharp

7- An instance method in C# is invked obly by an ____. (1đ) A- object B- instant object C- class D- None of the above

8- An array is a group of ____ (called elements) containing values that all have the same ____. (1đ)

A- variables, type B- element, size C- variables, size D- elements, type

9- An object is a(n) ____ of a class (1đ) A- Instantiation B- Institution C- Relative D- Child

10- An array that uses two indices is referred to as a(n) ____ array. (1đ) A- multi dimensional B- None of the above C- two-dimensional D- three dimensional

Page 7: C Sharp

1- An assembly can be used in ____ application at a time. (1đ) A- more than one B- 1 C- 0 D- 2

2- ____ are typically used to display used to display hyperlinks (1đ) A- Rich TextBox B- TextBox C- Label D- LinkLabels

3- ____ are components that are # (1đ) A- CheckBoxes B- LinkLabels C- RadioButtons D- Buttons

4- Array can store ____ types of values at the same time. (1đ) A- 3 B- many different C- 2 D- 1

5- ArrayLists store ____ to object # (1đ) A- strings B- references C- values D- objects

6- Array X and Y have integer data types. If these arrays are initialized properly, what is wrong with the following statement? for (int var = 0; var<0; ++ var){ if(x[var] > 100) break; if(x[var] < 0) continue; x[var+1] = x[var] + y[var]; } (1đ)

A- The prefix operator is not allowed in the iteration part of a for statement B- The variable var cannot br declared in the initiazation part of a for

statement

Page 8: C Sharp

C- It is illegal to have a break and continue statements within the same for statement

D- There is nothing wrong with the statement

7- Assumes that you want to change the # (1đ) A- MyForm.BackColor(Color.Red); B- MyForm.BackColor = System.Drawing.Color.Red; C- MyForm.BackColor = Red; D- MyForm.BackColor = "Red";

8- Assuming that public class B : A { public B (int i) :base(i) { } } compiles and runs correctly, what can we conclude about the constructors in the class A? (1đ)

A- One constructor takes arguments of the type int B- One constructor take an argument of type i C- There is only a default constructor D- All over above

9- Boolean data type in C# is: (1đ) A- binary type B- logical type C- a value type D- a reference type

10- Basic input and output operations are performed in C# using the methods of the ____ class in the ____ namespace. (1đ)

A- InputOutput, Class B- Console, System C- InputOuput, System D- Sytem, Console

Page 9: C Sharp

1- By default the compiler opens ____ assembly. (1đ) A- system.dll B- namespace.dll C- mscorlib.dll D- Cdefault.dll

2- C# us case-sensitive. (1đ) A- True B- False C- Depend on setting options from Visual Studio.NET D- Depend on Operating System

3- C# applications begin execution at method ____. (1đ) A- other B- load C- void D- main

4- C# is one of the languages you can use to # (1đ) A- GAC B- only MS Windows C- assembly D- JNET CLR

5- char c=’a’; switch(c){ case ’a’ : Console.WriteLine("A") ;break; default : Console.WtiteLine("Default"); } What will happen if you attempt to compile and run code that includes this snippet? (1đ)

A- The code will compile and run nothing will be return on the standard output

B- The code will compile and run and the letter "A" will be written to the standard ouput

C- The code will not compile because the switch statement does not have legal expression

D- The code will compile and run and the word "Default" will be written to the standard output

6- Choose the right statement. (1đ)

Page 10: C Sharp

A- The ComboBox control allows you to enter a vakue in the control, the ListBox control allows you to select only a single item from a list of predefined values

B- The ComboBox control allows you to enter a vakue in the control, the ListBox control allows you to select multiple item from a list of predefined values

C- The ComboBox control not allows you to enter a vakue in the control, the ListBox control allows you to select multiple item from a list of predefined values

D- The ComboBox control allows you to enter a vakue in the control, the ComboBox control allows you to select only a single item from a list of predefined values

7- C# code can be classified into types: (1đ) A- Safe code B- All over above C- Unsafe code D- Managed code

8- Class String and the Char structure found in the: (1đ) A- System.Text namespace B- System namespace C- Sytem.Chars namespace D- System.Strings namespace

9- class Test: Form { } (1đ) A- Creates the class form that inherits the class Test B- Creates a new form with the name is Text C- Creates the class Test: Form D- Creates the class Test that inherits the class Form

10- 1. class Test{ 2 public static void Main(){ 3. int i=0; 4. char c= ’s’; 5. object [ ] objArray=new object[3]; 6. objArray[0] = new object(); 7. objArray[0] = I; 8. objArray[0] = c; //new char(); 9. } 10. } The above code is compiled and run . The possible error is: (1đ)

A- The code will generate a compile time error at lines 7 and 8 as the arrasy can have only one type of data

Page 11: C Sharp

B- The code will generate a compile time error at lines 7 and 8 as the implicit conversion of int and char to a object type is not possible

C- None of the above D- The code will compile successfully

Page 12: C Sharp

1- class Test{ Static void Main() { int [] Array1 = {3,2,1); int i = Array.IndexOf(Array1,3); Console.WriteLine(i) } } What will be the output of above code? (1đ)

A- 3 B- 1 C- 0 D- 2

2- class Question( public Hashtable Directory = new Hashtable(); public string this[string Person] { get { return (string) Directory[Person]; } set { Directory[Person] = value; } } } Class Test { static void Main() { Question Dir = new Question(); // Add code here ………………. } } Two persons named SMITH and MARTIN are to be added in the directory created above. To achieve this which of the following are the valid statements that can be added in the sace specified in the .code above? (1đ)

A- Dir[ ^ S^ ]=^ SMITH^ ; Dir[ ^ M^ ]=^ MARTIN^ ; B- Directory[ ^ SMITH^ ]=^ S^ ; Directory[MARTIN]= ^ M^ ; C- Directory[ ^ S^ ]=^ SMITH^ ; Directory[ ^ M^ ]=^ MARTIN^ ; D- Dir[ ^ SMITH^ ]; Dir[ ^ MARTIN^ ];

3- Consider the class below: Public class Test { Public static void Main( ) { int [ ] a = { 99, 22, 11, 55, 44, 88, 2, -3 }; int result = 0; for ( int I = 0; i < a.Lenght; i++)

Page 13: C Sharp

{ if ( a[ i ] > 30) result += a[ i ]; } //end for Console.WriteLine( "Result is: ", result ); } } The ouput of this C# program will be: (1đ)

A- Result is: 332 B- Result is: 286 C- Result is: 280 D- Result is: 154

4- Within the namspace we can declare following: (1đ) A- Class B- Delegates C- All the options mentioned D- Interface

5- Concatenating with strings are done with: (1đ) A- method calls B- operator overloading C- reserved words D- operator overloading and method calls

6- class IndexExample{ String Message; Public static void Main() { IndexExample obj=new IndexExample("WELCOME"); for(int i=0; i < 7; i++) { System.Comsole.Write(obj[i]); } } Public IndexExample (string s) { Message=s } Public string this[int 1] { get { if(i >= 0 && i < Message.Length) return Message.Substring(i, 1: ; else return ""; set { if(i >= 0 && i < Message.Length) Message=Message.Substring(0,i: +value + Message.Substring(i+1);

Page 14: C Sharp

} } }What will be the output of above code? (1đ)

A- The code will compile successfully and output will be; WELCOME

B- All over above C- Code will generate a run time error D- #

7- Consider this example: Class Example { Void firstMethod( ) { in myVar; . . . Void anotherMethod( ) { myVar = 42; . . . } } (1đ)

A- This code OK. Another variable myVar is automatically create, and set to 42

B- This code would fail to compile because anotherMethod is trying to use the variable myVar, which is not scope

C- This code would fail to compile because anotherMethod is trying to use the variable myVar, which is not get memory with new() keyword

D- This code OK. myVar is set to 42

8- Consider array items, which contains the values 0, 2, 4, 6 and 8. If method changeArray is called with the method call changeArray( item, items[ 2 ] ), what values are stored in items after the method has finished executing? Public static void ChangeArray( int[ ] passeArray, int value ) { passedArray[ value ] = 12; value = 5; } // end method ChangeArray (1đ)

A- 0, 2, 4, 6, 12 B- 0, 2, 12, 6, 8 C- 0, 2, 4, 6, 5 D- 0, 2, 5, 6, 12

Page 15: C Sharp

9- Contructors can not have ____. (1đ) A- name B- overloaded constructors C- return values D- Argument

10- Defining two methods with the same name but with different parameters is called. (1đ)

A- Loading B- Duplexing C- Multiplexing D- Overloading

Page 16: C Sharp

1- Delegates act as: (1đ) A- a way to call many methods at once B- a go between for objects raising events and the method# C- masks for methods that handle events D- ways of sorting events

2- Even KeyPress: (1đ) A- Occurs when a key is pressed while the control has focus. This event

always occurs after KeyDown and KeyUp B- Occurs when a key is pressed while the control has focus. This event

always occurs after KeyUp and before KeyDown C- Occurs when a key is pressed while the control has focus. This event

always occurs before KeyDown and KeyUp D- Occurs when a key is pressed while the control has focus. This event

always occurs after KeyDown and before KeyUp

3- Event Keydown: (1đ) A- Occurs when a key is pressed while the control has focus. This event

always occurs after KeyUp and before KeyPress B- Occurs when a key is pressed while the control has focus. This event

always occurs before KeyPreess and KeyUp C- Occurs when a key is pressed while the control has focus. This event

always occurs after KeyPress and before KeyUp D- Occurs when a key is pressed while the control has focus. This event

always occurs after KeyPress and KeyUp

4- Events in C# can be: (1đ) A- generate by keyboard input B- started with a click on a button, or other control C- generated within the code of the program D- All of the above

5- Event in C# are impltemented using: (1đ) A- Delegates B- Pointers C- Variable D- Specialized DLLs

6- Event class directly or indirectly extends the ____ class. (1đ) A- Object B- Console

Page 17: C Sharp

C- Drawing D- System

7- Every method that handles the same event# (1đ) A- name B- signature C- return type D- number of parameters

8- Focus events occur in the following order: (1đ) A- GotFocus

2. Enter 3. Leave 4. Validating 5. Validated 6. LostFocus

B- 1. Enter 2. GotFocus 3. Leave 4. Validated 5. Validating 6. LostFocus

C- 1. Enter 2. Leave 3. GotFocus 4. Validating 5. Validated 6. LostFocus

D- 1. Enter 2. GotFocus 3. Leave 4. Validating 5. Validated 6. LostFocus

9- Every class declaration contains keyword ____ followed immediately by the class’s name. (1đ)

A- create B- init C- new D- None of the above

Page 18: C Sharp

10- Exception objects are derived from the class. (1đ) A- Exception B- Catch C- Event D- System

Page 19: C Sharp

1- Find any errors in the following BankAccout contructor: Public int BankAccount ( ) { Balance = 0; } (1đ)

A- No errors B- Name C- Return type D- Format parameters

2- For decimal, the default calue is ____. (1đ) A- 0.0m B- 0.0d C- 0 D- Nonr of the above

3- for(int i = 0; i<2; i++) for(int j = 0; j<3; j++ if (i= =j) continue; Console.WriteLine ("i={0} j={1}, i, j); Which lines would be the part of output? (1đ)

A- i=2 j=3 B- i=0 j=0 C- i=1 j=0 D- i=0 j=1

4- Give the method header for each of the following methods: Method Smallest, which takes three integers x, y and z returns an integer. (1đ)

A- void Smallest(int x, int y, int z) B- int Smallest(x, y, z) C- int Smallest(int x, int y, int z) D- Smallest(int x, int y, int z)

5- Given the data assigned to the string variable y shown below, which of the following statements will assign the value ALL to the string variable x? y = "WHEN ALL ELSE FALLS, READ THE DIRECTIONS" (1đ)

A- x = y.Substring(6, 3) B- x = y.Substring(5) C- x = y.IndexOf("ALL") D- x = y.Substring(5, 3)

Page 20: C Sharp

6- Giving the following example Static void DoWork(out int param) { // Do nothing } (1đ)

A- the example does not compile because C# have no out keyword B- the example compile OK C- the example does not compile DoWork do nothing D- the example does not compile because DoWork does not assign a value to

param

7- Here is an example of one class: Class Example { void firstMethod( ) { myField = 42; . . . } void anotherMethod( ) { myField++; . . . } Int myField = 0; } (1đ)

A- This class is OK. But we have 3 difference variable name myField in contexts

B- This class is Failed. You must declare myField variable with public keyword

C- This class is Failed. You must declsre a variable before tou can use it D- This class is OK. The variable myField is defined in the class but outside

the methods firsMethod and anotherMethod. Therefore, myField has class scope and is available for use by all methods in the class

8- How many main( ) function can be in a # (1đ) A- 2 B- only 1 C- more than 1 D- 3

9- How do you disable the default context menu of a textbox using code? (1đ) A- textBox1.ContextMenu = new ContextMenu();

Page 21: C Sharp

B- textBox1.ContextMenu = NULL; C- textBox1.ContextMenu = Nothing; D- textBox1.ContextMenu = false;

10- How to get the alphabet in uppercase A (ASCII = 65) through Z (ASCII = 90)? (1đ)

A- protected void GetAlphabet(){ string strAlpha = ""; for (int i = 65; i<=90;i++) { strAlpha += ((char)i).Tostring() + ""; }}

B- protected void GetAlphabet(){ string strAlpha = ""; for (int i = 65; i<=90;i++) { strAlpha += char(i.Tostring()) + ""; }}

C- protected void GetAlphabet(){ string strAlpha = ""; for (int i = 65; i<=90;i++) { strAlpha += i.Tostring() + ""; }}

D- protected void GetAlphabet(){ string strAlpha = ""; for (int i = 65; i<=90;i++) { strAlpha += i.ToChar() + ""; }}

Page 22: C Sharp

1- How can I disable the right-click context menu in my textboc? (1đ) A- You can set the DisableMenu property of the TextBox to true B- You can set the ContextMenu property of the TextBox to a dummy, empty

ContextMenu instance C- You can set the IsMenuContextEnable property of the TextBox to false D- You can set the ContextMenu property of the TextBox to a null string

2- How do you set the default button button1 for a form Form1? (1đ) A- Form1.ButtonDefault = button1; B- Form1. DefaultButton = button1; C- Form1. IsDefaultButton = Form1; D- Form1.AcceptButton = button1;

3- How can I turn off editing in the textbox portion of a ComboBox, restricting the user to selecting only those options in the drop list? (1đ)

A- et the combobox’s DropDownStyle property to DropDownList B- et the combobox’s Edit property to false C- et the combobox’s Enabled property to false D- et the combobox’s DropDownStyle property to NoneEdit

4- How can I trigger a button (button1) click event from a sub/function? (1đ) A- button1.Click(); B- button1_Click(); C- button1.PerformClick(); D- Exec button1.Click();

5- How can you use a TextBox to enter a password with * character? (1đ) A- Set the TextBox.PasswordChar property for the textbox to * B- Set the TextBox.IsPassword property for the textbox to true. Set the

TextBox.PasswordChar property for the textbox to * C- Set the TextBox.Password property for the textbox to true. Set the

TextBox.PasswordChar property for the textbox to * D- TextBox can not use to enter password

6- How do you change the mouse cursor for a control? (1đ) A- Change the MousePointer property B- Change the Cursor property C- Change the MouseCursor property D- Change the MouseIcon property

Page 23: C Sharp

7- How can you have a form with no title bar, but yet keep the resizing borders? (1đ)

A- Set your form’s Title and Resize properties; myForm.Title = Titlt.None; myForm.Resize = true;

B- Set your form’s BorderStyle and ControlBox properties; myForm.BorderStyle = BorderStyle.NoTitle; myForm.ControlBox = false;

C- Set your form’s Title and ControlBox properties; myForm.Title = false; myForm.ControlBox = false;

D- Set your form’s Text and ControlBox properties; myForm.Tetx = ""; myForm.ControlBox = false;

8- How do you set several lines into a multiline textbox? (1đ) A- All are correct B- textBox1.Text = "This is line 1." + Enviroment.newLine + "This is line2"; C- textBox1.Text = "This is line 1.\r\n This is line 2"; D- textBox1.Text = stringvar1 + "\r\n" + stringvar2;

9- How can I enable the mnemonics (underline) to show when my application is launched on Window XP? Choose the best answer? (1đ)

A- Repair in Registry B- Open Control Panl. Choose Effects Button and uncheck the checkbox

"Hide Underlined letters for keyboard navigation until I press the ALT Key". C- Right Click Desktop to bring up the Display Properties Dialof and then

choose Appearance tab and then the Effects Button and uncheck the checkbox "Hide Underlined letters for keyboard navigation until I press the ALT Key".

D- Open Control Panel, choose Appearance tab and then the Effects Button and uncheck the checkbox "Hide Underlined letters for keyboard vavigation until I press the ALT Key".

10- How do you make your textbox textBox1 use all upper (or lower) case characters when user input? Select best answer? (1đ)

A- Write code at Key_Press event and convert; textBox1.text=textBox1.Text.ToUpper();

B- Write code at Text_Changed event and convert; textBox1.text=textBox1.Text.ToUpper();

C- Use the Format property of the TextBox to "#C" D- Use the CharacterCasing property of the TextBox to

CharacterCasing.Upper

Page 24: C Sharp
Page 25: C Sharp

1- How do you prevent users from resizing a form? (1đ) A- Setting the Resize to false and setting the MaximizeBox property to false B- Setting the FormBorderStyle to FixeDialog C- Setting the FormStyle to Dialog D- Setting the FormBorderStyle to FixeDialog and setting the MaximizeBox

property to false

2- How to get a random number, no larger than 108, no smaller than 1? (in[1...108]) (1đ)

A- Random randNum = new Random(); randNum.Next(1. 108);

B- Random randNum; randNum.Next(1. 108);

C- Random randNum = new Random(); randNum.Next(108) + 1;

D- Random randNum = new Random(); randNum.Next(0. 108);

3- How can you prevent a form from being shown in the taskbar? (1đ) A- this.ShowIn Taskbar = false; B- this.Show Tray = false; C- this.ShowIn Taskbar = Taskbar.None; D- this.TaskbarVisible = false;

4- How do I set the font for button button1? (1đ) A- button1.Name = "Courier";

button1.FontSize = 10; button1.FontBold = FontStyle.bold;

B- button1.Font = Fonr("Courier". 10. FontStyle.Bold); C- button1.Font = new Font("Courier". 10. FontStyle.Bold); D- button1.Font = new Courier (10. FontStyle.Bold);

5- How to get result value of Number1 * Number2 from 2 textbox input and display on txtResult? Select best answer? (1đ)

A- txtResult.Text = (ToDouble(txtNumber1.Text) * ToDouble(txtNumber1.Text)).ToString;

B- txtResult.Text = (ToDouble(txtNumber1.Text) * ToDouble(txtNumber1.Text).

C- txtResult.Text = Convert.ToDouble(txtNumber1.Text) * Convert.ToDouble (txtNumber1.Text);

D- txtResult.Text = Convert.ToString(Convert.ToDouble(txtNumber1.Text) * Convert.ToDouble(txtNumber1.Text));

Page 26: C Sharp

6- How can you initialize an array of three bool values? (1đ) A- bool b=true,true,true}; B- booL[3] b=new bool[3]={true,true,true}; C- bool[3] b={true,true,true}; D- bool [] b=new bool[3];

7- How many times is the body of the loop below executed? Int counter; Counter = 1; While ( counter > 20 ) ( // body of look Counter = counter + 1; ) // end while (1đ)

A- 0 B- 21 C- 19 D- 20

8- If two StringBuilder objects contain the # (1đ) A- the are two different objects B- if one changes, so will the other C- they represent the same meory location D- None of the above

9- How to get the alphabet in uppercase A (ASCII = 65) through Z (ASCII = 90)? (1đ)

A- protected void GetAlphabet() { string strAlpha = " "; for (int i = 65; i < = 90; i++) { strAlpha + = i.ToChar() + " "; } }

B- protected void GetAlphabet() { string strAlpha = " "; for (int i = 65; i < = 90; i++) { strAlpha + = i.char(i.ToString()) + " "; } }

C- protected void GetAlphabet()

Page 27: C Sharp

{ string strAlpha = " "; for (int i = 65; i < = 90; i++) { strAlpha + = ((char)i) .ToString() + " "; } }

D- #

10- If you do not indicate a return type for a method, its return type is ____ by default. (1đ)

A- void B- Private C- Int D- Public

Page 28: C Sharp

1- If an IndexofAny method is passed an # (1đ) A- finds the first occurrence of each letter in the string B- generates an error C- will search for the first occurrence of the sequence of characters # D- searches for the first occurrence of any of the characters #

2- If a programmer inserts "using System"# System.Console.out.WriteLine("Hello");? (1đ)

A- Console.WriteLine("Hello"); B- Console.Out("Hello"); C- WriteLine("Hello"); D- System("Hello");

3- If you want to use the Book class for store 500 books, write a segment to how use to declare and create your instantiations. (1đ)

A- Book[] store = new Book[500]: for (int i = 0; i < store.Lenght; i++) store[i] = new Book();

B- Book[] store = new Book[500]: for (int i = 0; i < store.Lenght; i++) store[i] = Book(i);

C- Book store = new Book: for (int i = 0; i < store.Lenght; i++) store[i] = new Book();

D- store[] Book = new Book[500]: for (int i = 0; i < store.Lenght; i++) store[i] = new Book();

4- If programmer write a following segment, how to translate to it in term of for statement. foreach (int count in homwwork) homework[count] = 100; (1đ)

A- for (int count = 1; count<=homework.Lenght; count++) homework[count]=100;

B- for (int count = 0; count<=homework.Lenght; count++) homework[count]=100;

C- for (int count = 0; count homework[count]=100; D- for (int count = 0; count<=homework.Lenght; count++)

100=homework[count];

5- IL code compiles to ____. (1đ) A- Platform-specific Executable code

Page 29: C Sharp

B- Byte Code C- other D- .NET Code

6- If you run the following program that lines would be included in its output? class A { public static void Main ( ) { int i = 0; switch (i) { default: System.Console.Write (i); break; case 1: System.console.Write ("{0}", 1); goto default; case 0: System.Console.Write ("{0}", 0); goto case 1; } } } (1đ)

A- The program fails to compile B- 010 C- 100 D- 110

7- In C#, the name of a method I defined ____. (1đ) A- lower B- proper C- capitalized D- other

8- To output the value of multidimensional array, # (1đ) A- myArray{1}{3}; B- myArray[1.3]: C- myArray[1][3]: D- myArray(1).(3):

9- In C# Thread.Sleep (time) measures time in: (1đ) A- All of the above B- seconds

Page 30: C Sharp

C- nanoseconds D- miliseconds

10- ____ in simple terms is nothing but conversion of a value type into a reference type. (1đ)

A- Boxing B- Overriding C- Unboxing D- Casting

Page 31: C Sharp

1- In the body of a method, C# uses # (1đ) A- call B- do C- that D- this

2- In C# datatypes are divided into two fundamental categories: (1đ) A- Class and Non-Class type B- Value types and reference types C- Pointers and values D- Pointers and Non-Pointers

3- In order to add or remove an event from # (1đ) A- event can only be added with the += and not removed# B- the Add anad Subtract methods C- the Add and Remove methods D- the += and the -= operators

4- int myVar = 3; if (myVar<5) if (myVar<3) Console.WriteLine("3"); else if (myVar>2) Console.WriteLine(">2">; else Console.WriteLine("Other"); What will appear on the standard ouput? (1đ)

A- Other B- > 2 C- No ouput D- < 3

5- ____ is all about conveting a reference type into a value type. (1đ) A- Overloading B- Boxing C- Unboxing D- Casting

6- ____ is a unit of class deployment. (1đ) A- Unit B- A Manifest C- An Assembly

Page 32: C Sharp

D- An Executable file

7- Machine languages ____. (1đ) A- need to be translated in order for the machine to under # B- consists of numbers and letters C- are machine dependent D- are universal between all machines

8- Mehtod ____ of class Process can # (1đ) A- Begin B- Init C- Start D- Run

9- ____ method of form displays the form as a model # any other form can receive the focus. (1đ)

A- ShowDialog B- Dialog C- Display D- #

10- Method ____ is used removes all the elements from # (1đ) A- ClearAll B- Clear C- Delete D- RemoveAll

Page 33: C Sharp

1- namespace Spacel{ namespace Space2{ class MyClass{ } } } The fully qualified name of class MyClass is: (1đ)

A- Space2.Space1.MyClass() B- Space1.Space2.MyClass() C- Space1.MyClass() D- Space2.MyClass()

2- namespace College.Library{ namespace Shelf{ class Book{ } } } The fully qualified name of class Book is: (1đ)

A- College.Library.Book() B- Library.Shelf.Book() C- Shelf.Book() D- College.library.Shelf.Book()

3- namespace Spacel { using System; public class A{ public static void Main( ) { A objiA=new A( ) ; Type t1 = objA.GetType( ); Console.WriteLine("The type of objA is : {0} ", t1); } } } What will be the output of above code whrn compiled/run? (1đ)

A- The ouput of code will be: The type of objA is : Space1 .A

B- The code will generate a compile time error as class reference is required for the GetType() method.

C- The ouput of code will be: The type of objA is : System.Space1 .A

D- The ouput of code will be: The type of objA is : class .A

4- object objectValue = "Hello,";

Page 34: C Sharp

char [ ] characterArray = { ’a’, ’f’, ’d’, ’c’, ’e’, ’b’ }; StringBuilder buffer = new StringBuilder( ); buffer.Append(characTerArray); buffer.Sort( ); buffer.Insert(0, objectValue); What will be the fragment of a bove code assign to buffer variable? (1đ)

A- Hello, abcdef B- abcdefHello C- The code will generate an error D- None of the other answers

5- Panel have the abbility to have scrollbars # (1đ) A- True B- False C- Depend on setting theme form Operating System D- Depend on setting from Visual Studio.Net

6- Private void DeleteItem(ListBox lst) { int i = 0; string strItem; string strName; strName = "Long"; while (i < lst.Item.Count) { strItem = lst.Items[i].ToString( ); is (strItem.Substring(strItem.LastIndexOf(" ")+1) .Equals( strName)) lst.Items.RemoveAt(i); else i++; } } Purpose fragment of the code below? (1đ)

A- The code delete one items in Listbox if proper if(strItem.Substring (strItem.LastIndexOf(" ") + 1).Equals( strName))

B- The code will generate an error at if (strItem.Substring (strItem.LastIndexOf(" ") +1).Equals( strName))

C- The code delete all items in Listbox if proper if(strItem.Substring (strItem.LastIndexOf(" ") + 1).Equals( strName))

D- The code will loop in while

7- Properties can contain ____. (1đ) A- get and set accessors B- a get accessor, a set accessor or both

Page 35: C Sharp

C- a get accessor D- a set accessor

8- Select code to use OpenFileDialog. It choose from C:\ folder as default, with filetype is *.XML, title is Open XML/UML File". After user choosing a file it will display the selected filename? (1đ)

A- Object B- property C- Constructor D- Class

9- Programs that translate high-level # (1đ) A- process B- execute C- built D- compilers

10- Statement I: The sealed modifiers are not permitted in an enum declaration. Statement II: Delegate types are implicitly sealed (1đ)

A- Only statement I is true B- Only statement II is true C- Both the stattements are true D- Both the statements are false

Page 36: C Sharp

1- StreamWriter viet = null; try { SaveFileDialog sDlg = new SaveFileDialog( ); sDlg.Filter = "Text File(*.txt) | *.txt | All Files(*.*) | *.*"; if (sDlg.ShowDialog( ) = = DialogResult.OK) { viet = new StreamWriter(sDlg.FileName); viet.Write(txtNoidung.Text); } } catch (Exception ex) { MessageBox.Show(ex.ToString( )) ; } finally { viet.Close( ); } What will be the fragment of above code? (1đ)

A- Write contain text txtNoidung to file Data.txt B- The code will generate an error C- Write contain text in txtNoidung to file chose in SaveFileDialog sDlg D- All way save text in txtNoidung to file Data.txt

2- String indexers treat strings as: (1đ) A- 1 to string Lenght B- arrays of chareacters C- binary code D- a character

3- String mystring; Creates a(n) ____. (1đ) A- Object B- property C- Constructor D- Class

4- StringBuilder buffer = new StringBuilder("Hello, how are you?"); buffer = buffer + buffer.Append("Thang"); What will be the fragment of above code assign to buffer variable? (1đ)

A- The code will generate an error B- Hello, how are you?

Thang C- Hello, how are you?Thang D- None of the others answers

Page 37: C Sharp

5- StringBuilder buffer = new StringBuilder("Hello, how are you?"); buffer.Lenght = 6; buffer.Append("To day!"); What will be the fragment of above code assign to buffer variable? (1đ)

A- Hello, how are you? Today! B- The code will generate an error C- Hello, Today! D- None of the other answers

6- StringBuilder buffer = new StringBuilder("Hello, how are you?"); buffer.Insert(5, 123); What will be the fragment of above code assign to buffer variable? (1đ)

A- Hello123, how are you? B- The code will generate an error C- Hello123o, how are you? D- None of the other answers

7- StringBuilder buffer = new StringBuilder("Hello, how are you?"); buffer = buffer + buffer.Replace("Hello", "Hello Thang"); What will be the fragment of above code assign to buffer variable? (1đ)

A- Hello Thang B- None ofther other answers C- The code will generate an error D- Hello Thang, how are you?

8- Suppose the first two lines of the file DATA.TXT contain the strings "Clint" and "1930". What is Displayed by the following lines of code? try { OpenFileDialog dlg = new OpenFileDialog( ); dlg.Filter = "Text File(*.txt) | *.txt | All Files(*.*) | *.*}; dlg.FilterIndex = 1; dlg.Multiselect = false; if (dlg.ShowDialog( ) = =DialogResult.OK) { StreamReader doc = new StreamReader (dlg.FileName); string nd1 = doc.ReadLine( ); int nd2 = Convert.ToInt32 ( doc.ReadLine( )); txtNoidung.Text = "In 2008, " + nd1 + " will be " + (2008 – nd2); doc.Close ( ); }

Page 38: C Sharp

} catch (Exeption ex) { MessageBox.Show(ex.Tostring( )); } (1đ)

A- j In 2008, "Clint" will be 78 B- In 2008, "Clint" will be 78 C- j Clint,1930 D- j In 2008, Clint will be 2008-1930

9- The DoWork method increments a the argument: static void DoWork(out int param) { param = 42; } stattic void Main( ) { int arg; DoWork(out arg); Console.WriteLien(arg); } The result on the screen is: (1đ)

A- example does not compile by error syntax B- Write a random value C- writes 42 D- example does not compile by error because arg is initialized

10- System namespace is used in the C# programs to: (1đ) A- capture program ouputs B- interact with other classes in the namespcae C- interact with the system enviroment D- interact with the operating system

Page 39: C Sharp

1- The acive control is said to have the # (1đ) A- tab B- pointer C- focus D- selected

2- The proper way to convert a string # (1đ) A- string.ToLower(): B- String = string.ToLower(string): C- string.ToLower(string): D- ToLower(string):

3- ____ statement, when executed in a repetition structure, causes immediate exit from repetition structure. (1đ)

A- break B- continue C- end D- exit

4- The ____ property of TabControl determines whether tabs can fill more than one row or not. (1đ)

A- TabPages B- ItemSize C- TabCount D- MultiLine

5- The code public class B : A { } (1đ)

A- Defines a class that inherits all the methods of A B- Defines a class A inherits all the methods of B C- Errors D- Defines a class that inherits the public methods of A only

6- The statement: Private Button print = new Button ( ); (1đ) A- Do nothing B- creates and instantiates a button control C- creates a button control D- initializes a button control

7- The properties window: (1đ)

Page 40: C Sharp

A- allows you to change project properties B- allows you to write code C- allows you to change solution properties D- allows you to modify control’s properties without writing any #

8- The ____ event of Form object is fired # event is raised the first time that Form. Show or # (1đ)

A- New B- Activated C- Load D- Constructor

9- ____ is portable to non-window platform. (1đ) A- .Net Framework B- VB C- Visual studio D- C#

10- The DoWork method increments a the argument: static void DoWork(ref int param) { param ++; } stattic void Main( ) { int arg = 42; DoWork(arg); Console.WriteLien(arg); } The result on the screen is: (1đ)

A- example does not compile B- Write a random value C- writes 42 D- writes 43

Page 41: C Sharp

1- The statement: Private Button print = new Button(); (1đ) A- creates and instantiates a button control B- initializes a button control C- Do nothing D- creates a button control

2- The DoWork method increments a the argument: static void DoWork(int param) { param ++; } stattic void Main( ) { int arg = 42; DoWork(arg); Console.WriteLien(arg); } The result on the screen is: (1đ)

A- example does not compile by error B- writes 42 C- writes 43 D- write a random value

3- The joining of two strings together to form a new string is called ____. (1đ) A- addition B- compaction C- concatenation D- substrings

4- The ____ control creates tabbed windows, this allows you to specify more information in the same on a Form. (1đ)

A- TabPage B- Table C- TabControl D- Group

5- The ____ statement allows you to iterate through the elements in an array without using a counter. (1đ)

A- for B- while C- do while D- foreach

Page 42: C Sharp

6- The base class Array belongs to the ____ namspace. (1đ) A- Arrays B- System.Collection C- Global.Type D- System

7- The methods which can be called without instantiating an object first are called ____. (1đ)

A- private B- static C- dynamic D- primary

8- The constructor without parameters is called ____. (1đ) A- non-parameterized constructor B- default constructor C- zero valued constructor D- main constructor

9- The extension of an assembly is ____. (1đ) A- .dll B- .cs C- .exe D- .ddl

10- The ____ property specifies how text is aligned within a Label’s boundaries. (1đ)

A- Left B- Top C- Anchor D- TextAlign

Page 43: C Sharp

1- To create a string literal exclude escap # (1đ) A- !string B- #string C- @string D- $string

2- To allocate memory for an object instantiation, you must use the ____ (1đ) A- alloc B- instant C- new D- mem

3- To change the value of a variable while debugging, ____ window is used. (1đ) A- Local B- Debug C- Watch D- Immediate

4- try{ intX=Convert.ToInt32(lngX); intY=intX/intZero; } Write a catch clause usingfewest codes: (1đ)

A- catch(OverflowException ex){} B- catch(ArithmeticException ex){} C- catch(OverflowException ex){}

catch(DivideByZeroException ex){} catch(Exception ex){}

D- catch(DivideByZeroException ex){}

5- Typical mouse events include ____ (1đ) A- mouse clicks, mouse presses, mouse moves B- mouse double clicks, mouse presses, mouse moves C- mouse clicks, mouse presses, mouse down D- mouse clicks, mouse presses, mouse up

6- Unboxing require an ____ cast. (1đ) A- explicit B- implicit C- None of the above D- implicit or explicit

Page 44: C Sharp

7- Unlike C++, C# does not have ____. (1đ) A- attribute B- tructure C- interface D- pointer

8- Using code, how to add a Separator in a menu named mnu1? (1đ) A- mnu1.MemuItems.Add("-"); B- mnu1.MemuItems.Add("&"); C- mnu1.MemuItems.Add("_"); D- mnu1.MemuItems.Add(Menu.Separator);

9- Value types differ from reference types as ____. (1đ) A- data in the value type variable is easily accessible B- Variables of the value directly contain their data, whereas variables of the

reference types store references to objects. C- variables of the reference types directly contain their data, whereas

variables of the value store references to objects. D- None of the above

10- using System; class Myclass { int Var1=1; int Var2; public static void Main(){ int LocalVar=3; MyClass m1=new MyClass(); Console.WriteLine(m1.Var1.m1.Var2+LocalVar); } } The output of above code will be: (1đ)

A- The code does not compile because local variable is not initialized correctly

B- The code does not compile because Var2 is not initialized C- 0 D- 4

Page 45: C Sharp

1- using System; class Test{ public static void Main() { int value = Int32.Parse("99953"); double dval=Double.Parse("1.3433E+35"); Console.WriteLine(value); Console.WriteLine(dval); } }; What will be the ouput of above code when compiled/run? (1đ)

A- The output of above code will be: 99953 1.3433E35

B- The output of above code will be: 9953 1.3433E+35

C- The output of above code will be: 9953 1.3433

D- The code will generate compile time error

2- using System; class Test { static void Main() { int @Main; int[] Static = new int[3] @Main = 100*Static[1]; Console.WriteLine(@Main); } } (1đ)

A- The code cannot compile B- The code will display 0 C- The code will display 100 D- The code will return an error

3- using System; class Test{ public static void Main() { int[] Array1 = {3, 2, 1}; Display1(Array1); Array.Sort(Array1); Display1(Array1);

Page 46: C Sharp

} static void Display1(Array pArray) { foreach(int t in pArray){ } } } What will be the ouput of above code? (1đ)

A- The ouput of code will be: 3 2 1 1 2 3

B- The code will generate an error compile time since the Sort() function of Array returns an integer number

C- The ouput of the code will be: 321123

D- #

4- Using System.Collections; class Indexing{ public Hashtable Dictionary = new Hashtable(); public string this[string Name] get { return (string) Directionary[Name]; } set { Dictionary[Name] = value; } } } class Test { static void Main() { Indexing Index1 = new Indexing(); Index1["CA"] = "CALIFORNIA; Index1["AM"] = "AMERICA"; Systen.Console.WriteLine(Index1["AMERICA"]); } } What will be the output of above code when compiled/run? (1đ)

A- The code will compile successfully and output of code will be: AMERICA

B- The code will generate a compile time error

Page 47: C Sharp

C- The code will compile successfully and output of code will be:AM D- The code will compile successfully but does not display any output

5- We invoke method ____ to determine # local variable index. (1đ) A- IndexOf B- Position C- IndexOfString D- Index

6- We use operator ____ when it makes an application clearner than accomplishing the same operations with explicit method calls. (1đ)

A- constructor B- overriding C- overloading D- None of the above

7- Using System; class Question{ public static void Main() { for (int i=0;i<10;i++) { try{ if(%3==0) throw.new Exception("EO"); try{ if(i%3= =11) throw new Exception("E1"); Console.WriteLine(i); } catch (Exception inner) { i+=3; finally (++i;) //try2 catch (Exception outer) { i+=3; }finally (++I;) } } } Which of the following lines does the above program display? (1đ)

A- 5 8

B- 4 5

C- 8 5

Page 48: C Sharp

D- #

8- What setting of the Dock peoperty wll # (1đ) A- None, you should use the Anchor property B- Top C- Top, Left, Right, Bottom D- Fill

9- What does the following code segment display? for (t=0;t<3;++ t) Console.Write(t); (1đ)

A- 012 B- 0123 C- 0 D- 01

10- What setting of the Anchor property # (1đ) A- Right, Left B- Top C- None D- Top, Botton

Page 49: C Sharp

1- What will be displayed in txtBox when the following fragment are executed? string a, b, c; a = "THE WHOLE"; b = "PART"; c = a.Substring(Convert.ToInt16(Math.Sqrt(4)), b.Length); txtBox.Text = c; (1đ)

A- HE W B- THE WHOLE C- 4 D- E WH

2- What is an assembly? (1đ) A- None of the above B- .NET debugger C- A collection of C# compilers D- A logical unit containing complited code

3- What is the output of the following code segment? int a=3, b=4; if (a= =b) Console.Write("Black"); Console.Write("Write"); (1đ)

A- BlackWhite B- Nothing C- White D- Black

4- What is CLS? (1đ) A- Code Location Specification B- Common Language Specification C- Csharp Language Specification D- Common Library System

5- What is the shortcut way of creating an event # (1đ) A- By right-click in the control and select View Code B- By double-click the control in the Windows Forms Designer C- By writing an event handler and adding it to the control D- By double-click the name of the event in the Properties windows

6- What is the output of the following code segment? s = 1;

Page 50: C Sharp

while(s<4) ++s; Console.Write(s); (1đ)

A- 4 B- 234 C- 1234 D- 1

7- What is automatic memory management in .NET known as: (1đ) A- Managed automatic B- Managed Code C- Garbage Collection D- Smart Caching

8- What will be the output in txtxBox of the following program when the button is clicked? private void btnDisplay_Click(object sender, EventArgs e) { String word1, word2, newword; word1 = "shower"; word2 = "about"; newword = word1.Substring(0, 4) + word2.Substring(0, 3); if (newword.StartsWith("how") = = false) txtBox.Text = "The new word was not found."; else txtBox.Text = "Found it."; } (1đ)

A- No output B- Found it C- Syntax error D- The new word was found

9- What is the method of ArrayList, which used to remove # (1đ) A- None of the above B- Remove C- RemoveAt D- RemoveRange

10- What is Boxing? (1đ) A- Encap sulating a base class B- Conversion of reference types to value types C- Conversion of integer value string value

Page 51: C Sharp

D- Conversion of value types to reference types

Page 52: C Sharp

1- What is stored in the variable strResult after the following statement executes? String strResult; strResult = "Michael" & "Ekedahl"; (1đ)

A- MichaelEkedahl B- syntax error C- None of the other answers D- Michael Ekedahl

2- What method of the String class returns a # (1đ) A- The same method B- EqualTo method C- Same method D- Equals method

3- What value stored in the variable str2 after the following statements have executed? string str1= "OneTwoThreee"; string str2; str2 = str1.Substring(1, 10); (1đ)

A- None of the other answers B- The statements will cause a syntax error C- neTwo Three D- OneTwoThre

4- What is the name of the method to convert a Number data type to a string data type? (1đ)

A- None of the other answers B- Convert.ToSByte(Number); C- Convert.ToString(Number); D- Convert.FormatNumber(Number);

5- What method of the String class remove # (1đ) A- Trim B- LRTrim C- TrimLeftRight D- OutSpace

6- What functionality does the AutoScroll property provides # (1đ) A- The AutoScroll property aitomatically provides scroll bars on a form when

# B- Form have no AutoScroll property

Page 53: C Sharp

C- The AutoScroll automatically provides scroll bars on all controls D- The AutoScroll property always provides scroll bars on a form

7- What is the correct syxtax for displaying value of the String variable myString in a TextBox txtBox? (1đ)

A- txtBox.Text = "myString"; B- txtBox.Text = myString; C- txtBox.Text = Str(myString); D- txtBox.Text.myString;

8- What method of the String class returns # specifed character or string in a String object? (1đ)

A- LastIndexOf B- LastOfString C- LastLocationOf D- LastPositionOf

9- What is the value stored in the variable intFound after the following statements have executed? int intFornd; string strData = "Peter Paul Mary"; intFound = strData.IndexOf("P"); (1đ)

A- true B- 0 C- false D- 1

10- What is the name of the method to convert a String data type to a DateTime data type? (1đ)

A- Convert.ToDateTime(stringDate); B- Convert.ToDate(stringDate); C- FormatToDateTime(stringDate); D- None of the other answers