Sei sulla pagina 1di 53

1-

A ____ block enclose the code that could throw an exception. (1) AException BTry CError DCatch A local varicable (1) AIs declared with keyword [local] before BCan be used anywhere in the program CMust accept a class DIs declared within a method A(n) ____ is a group of one or # (1) Aproperty Bclass Csolution Dproject

2-

3-

4A 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) Ahours = CalcPay(pay); Bhours = CalcPay(); Cpay = CalcPay(hoursWorked); Dpay = CalcPay(hours); A static method can only invoke other ____. (1) Aintance object Bstatic method Cmethod Dobject A ____ allows the user to interact with # (1) Acontrols BWindows Forms Ccomponent DGUI A delegate defines (1) Aa substitue for an inherited method

5-

6-

7-

BCD-

a means of passing arrays into methods a Wahsington representative a class that encapsulates methods

8-

A Panel is used to: (1) Agroup or store components Badd style to a form Ccreate a border around components Ddisplay text A Constructor (1) Amust have the same name as the class it is declared within Ball of the other answers Cmaybe overloaded Dis used to created objects A GroupBox can be used to ____. (1) Adisplay Bsort Corganize Dgroup

9-

10-

1-

A (an) ____ can contain objects# (1) AArrayList BEnumerators CCollection DArray

2A 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) Ahours = CalcPay(pay); Bhours = CalcPay(); Cpay = CalcPay(hoursWorked); Dpay = CalcPay(hours); A Collection is a method to use if (1) AThe contents of your list will change by adding or removing member BYour data items are not related CThe contents of your list are static DYou have a large volume of data items A collection is a group of individual data items or # (1) Aproperties BObjects Cstrings Dmethods

3-

4-

5A(n) ____ is a group of one or more projects that collectively form a Visual C# program. (1) Aproperty Bclass CProject Dsolution A variable declared inside a method is called a ____ variable (1) APrivate BLocal CStatic DSerial A variable of a reference type contains: (1)

6-

7-

ABCD-

information about the type and its data the address of the location in memory where data is stored data of the type None of the above

8-

A delegate in C# is similar to: (1) Aa pointer Bobject CCOM Da function pointer

9A 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) ADecimal BBollean Cint Dstring

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

1After 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) Athe left mouse button make button clicked Bthe form control that contain button was clicked Cthe control that was clicked Dthe value on the button All class have ____ method. (1) AToInt32() BToLower() CToString() DToUper() All types in C# implicitly derive from ____. (1) ASystem.Csharp class BSystem All class CSystem class DSystem.Object class An instance method (1) ARepresents the instance of an object BRepresents another class CRepresents the attribute of an object DRepresents the behavior of an object An instance variable ____. (1) Arepresents an attribute of an object Bis an object of a class Cis a method of a class Drepresents an property of an object An Event is ___. (1) Aresult of a party Ba eunning of a method Ccode to force users action Dthe result of a users action

2-

3-

4-

5-

6-

7-

An instance method in C# is invked obly by an ____. (1) Aobject Binstant object Cclass DNone of the above

8An array is a group of ____ (called elements) containing values that all have the same ____. (1) Avariables, type Belement, size Cvariables, size Delements, type An object is a(n) ____ of a class (1) AInstantiation BInstitution CRelative DChild An array that uses two indices is referred to as a(n) ____ array. (1) Amulti dimensional BNone of the above Ctwo-dimensional Dthree dimensional

9-

10-

1-

An assembly can be used in ____ application at a time. (1) Amore than one B1 C0 D2 ____ are typically used to display used to display hyperlinks (1) ARich TextBox BTextBox CLabel DLinkLabels ____ are components that are # (1) ACheckBoxes BLinkLabels CRadioButtons DButtons Array can store ____ types of values at the same time. (1) A3 Bmany different C2 D1 ArrayLists store ____ to object # (1) Astrings Breferences Cvalues Dobjects

2-

3-

4-

5-

6Array 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) AThe prefix operator is not allowed in the iteration part of a for statement BThe variable var cannot br declared in the initiazation part of a for statement

Cstatement D-

It is illegal to have a break and continue statements within the same for There is nothing wrong with the statement

7-

Assumes that you want to change the # (1) AMyForm.BackColor(Color.Red); BMyForm.BackColor = System.Drawing.Color.Red; CMyForm.BackColor = Red; DMyForm.BackColor = "Red";

8Assuming 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) AOne constructor takes arguments of the type int BOne constructor take an argument of type i CThere is only a default constructor DAll over above Boolean data type in C# is: (1) Abinary type Blogical type Ca value type Da reference type

9-

10Basic input and output operations are performed in C# using the methods of the ____ class in the ____ namespace. (1) AInputOutput, Class BConsole, System CInputOuput, System DSytem, Console

1-

By default the compiler opens ____ assembly. (1) Asystem.dll Bnamespace.dll Cmscorlib.dll DCdefault.dll C# us case-sensitive. (1) ATrue BFalse CDepend on setting options from Visual Studio.NET DDepend on Operating System C# applications begin execution at method ____. (1) Aother Bload Cvoid Dmain C# is one of the languages you can use to # (1) AGAC Bonly MS Windows Cassembly DJNET CLR

2-

3-

4-

5char 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) AThe code will compile and run nothing will be return on the standard output BThe code will compile and run and the letter "A" will be written to the standard ouput CThe code will not compile because the switch statement does not have legal expression DThe code will compile and run and the word "Default" will be written to the standard output Choose the right statement. (1)

6-

AThe 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 BThe 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 CThe 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 DThe 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 C# code can be classified into types: (1) ASafe code BAll over above CUnsafe code DManaged code Class String and the Char structure found in the: (1) ASystem.Text namespace BSystem namespace CSytem.Chars namespace DSystem.Strings namespace class Test: Form { } (1) ACreates the class form that inherits the class Test BCreates a new form with the name is Text CCreates the class Test: Form DCreates the class Test that inherits the class Form

7-

8-

9-

101. 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) AThe code will generate a compile time error at lines 7 and 8 as the arrasy can have only one type of data

BThe 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 CNone of the above DThe code will compile successfully

1class 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) A3 B1 C0 D2

2class 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) ADir[ ^ S^ ]=^ SMITH^ ; Dir[ ^ M^ ]=^ MARTIN^ ; BDirectory[ ^ SMITH^ ]=^ S^ ; Directory[MARTIN]= ^ M^ ; CDirectory[ ^ S^ ]=^ SMITH^ ; Directory[ ^ M^ ]=^ MARTIN^ ; DDir[ ^ SMITH^ ]; Dir[ ^ MARTIN^ ];

3Consider 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++)

{ if ( a[ i ] > 30) result += a[ i ]; } //end for Console.WriteLine( "Result is: ", result ); } } The ouput of this C# program will be: (1) AResult is: 332 BResult is: 286 CResult is: 280 DResult is: 154 Within the namspace we can declare following: (1) AClass BDelegates CAll the options mentioned DInterface Concatenating with strings are done with: (1) Amethod calls Boperator overloading Creserved words Doperator overloading and method calls

4-

5-

6class 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);

} } } What will be the output of above code? (1) AThe code will compile successfully and output will be; WELCOME BAll over above CCode will generate a run time error D#

7Consider this example: Class Example { Void firstMethod( ) { in myVar; ... Void anotherMethod( ) { myVar = 42; ... } } (1) AThis code OK. Another variable myVar is automatically create, and set to 42 BThis code would fail to compile because anotherMethod is trying to use the variable myVar, which is not scope CThis code would fail to compile because anotherMethod is trying to use the variable myVar, which is not get memory with new() keyword DThis code OK. myVar is set to 42

8Consider 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) A0, 2, 4, 6, 12 B0, 2, 12, 6, 8 C0, 2, 4, 6, 5 D0, 2, 5, 6, 12

9-

Contructors can not have ____. (1) Aname Boverloaded constructors Creturn values DArgument

10(1)

Defining two methods with the same name but with different parameters is called. ABCDLoading Duplexing Multiplexing Overloading

1-

Delegates act as: (1) Aa way to call many methods at once Ba go between for objects raising events and the method# Cmasks for methods that handle events Dways of sorting events

Even KeyPress: (1) AOccurs when a key is pressed while the control has focus. This event always occurs after KeyDown and KeyUp BOccurs when a key is pressed while the control has focus. This event always occurs after KeyUp and before KeyDown COccurs when a key is pressed while the control has focus. This event always occurs before KeyDown and KeyUp DOccurs when a key is pressed while the control has focus. This event always occurs after KeyDown and before KeyUp 2Event Keydown: (1) AOccurs when a key is pressed while the control has focus. This event always occurs after KeyUp and before KeyPress BOccurs when a key is pressed while the control has focus. This event always occurs before KeyPreess and KeyUp COccurs when a key is pressed while the control has focus. This event always occurs after KeyPress and before KeyUp DOccurs when a key is pressed while the control has focus. This event always occurs after KeyPress and KeyUp 3Events in C# can be: (1) Agenerate by keyboard input Bstarted with a click on a button, or other control Cgenerated within the code of the program DAll of the above Event in C# are impltemented using: (1) ADelegates BPointers CVariable DSpecialized DLLs Event class directly or indirectly extends the ____ class. (1) AObject BConsole

4-

5-

6-

CD-

Drawing System

7-

Every method that handles the same event# (1) Aname Bsignature Creturn type Dnumber of parameters

8-

Focus events occur in the following order: (1) AGotFocus 2. Enter 3. Leave 4. Validating 5. Validated 6. LostFocus B1. Enter 2. GotFocus 3. Leave 4. Validated 5. Validating 6. LostFocus C1. Enter 2. Leave 3. GotFocus 4. Validating 5. Validated 6. LostFocus D1. Enter 2. GotFocus 3. Leave 4. Validating 5. Validated 6. LostFocus

9Every class declaration contains keyword ____ followed immediately by the classs name. (1) Acreate Binit Cnew DNone of the above

10-

Exception objects are derived from the class. (1) AException BCatch CEvent DSystem

1Find any errors in the following BankAccout contructor: Public int BankAccount ( ) { Balance = 0; } (1) ANo errors BName CReturn type DFormat parameters For decimal, the default calue is ____. (1) A0.0m B0.0d C0 DNonr of the above

2-

3for(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) Ai=2 j=3 Bi=0 j=0 Ci=1 j=0 Di=0 j=1

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

5Given 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) Ax = y.Substring(6, 3) Bx = y.Substring(5) Cx = y.IndexOf("ALL") Dx = y.Substring(5, 3)

6Giving the following example Static void DoWork(out int param) { // Do nothing } (1) Athe example does not compile because C# have no out keyword Bthe example compile OK Cthe example does not compile DoWork do nothing Dthe example does not compile because DoWork does not assign a value to param

7Here is an example of one class: Class Example { void firstMethod( ) { myField = 42; ... } void anotherMethod( ) { myField++; ... } Int myField = 0; } (1) AThis class is OK. But we have 3 difference variable name myField in contexts BThis class is Failed. You must declare myField variable with public keyword CThis class is Failed. You must declsre a variable before tou can use it DThis 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 How many main( ) function can be in a # (1) A2 Bonly 1 Cmore than 1 D3 How do you disable the default context menu of a textbox using code? (1) AtextBox1.ContextMenu = new ContextMenu();

8-

9-

BCD-

textBox1.ContextMenu = NULL; textBox1.ContextMenu = Nothing; textBox1.ContextMenu = false;

10(1)

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

Aprotected void GetAlphabet(){ string strAlpha = ""; for (int i = 65; i<=90;i++) { strAlpha += ((char)i).Tostring() + ""; }} Bprotected void GetAlphabet(){ string strAlpha = ""; for (int i = 65; i<=90;i++) { strAlpha += char(i.Tostring()) + ""; }} Cprotected void GetAlphabet(){ string strAlpha = ""; for (int i = 65; i<=90;i++) { strAlpha += i.Tostring() + ""; }} Dprotected void GetAlphabet(){ string strAlpha = ""; for (int i = 65; i<=90;i++) { strAlpha += i.ToChar() + ""; }}

How can I disable the right-click context menu in my textboc? (1) AYou can set the DisableMenu property of the TextBox to true BYou can set the ContextMenu property of the TextBox to a dummy, empty ContextMenu instance CYou can set the IsMenuContextEnable property of the TextBox to false DYou can set the ContextMenu property of the TextBox to a null string 1How do you set the default button button1 for a form Form1? (1) AForm1.ButtonDefault = button1; BForm1. DefaultButton = button1; CForm1. IsDefaultButton = Form1; DForm1.AcceptButton = button1;

2-

3How 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) Aet the comboboxs DropDownStyle property to DropDownList Bet the comboboxs Edit property to false Cet the comboboxs Enabled property to false Det the comboboxs DropDownStyle property to NoneEdit How can I trigger a button (button1) click event from a sub/function? (1) Abutton1.Click(); Bbutton1_Click(); Cbutton1.PerformClick(); DExec button1.Click();

4-

How can you use a TextBox to enter a password with * character? (1) ASet the TextBox.PasswordChar property for the textbox to * BSet the TextBox.IsPassword property for the textbox to true. Set the TextBox.PasswordChar property for the textbox to * CSet the TextBox.Password property for the textbox to true. Set the TextBox.PasswordChar property for the textbox to * DTextBox can not use to enter password 5How do you change the mouse cursor for a control? (1) AChange the MousePointer property BChange the Cursor property CChange the MouseCursor property DChange the MouseIcon property

6-

7(1)

How can you have a form with no title bar, but yet keep the resizing borders?

ASet your forms Title and Resize properties; myForm.Title = Titlt.None; myForm.Resize = true; BSet your forms BorderStyle and ControlBox properties; myForm.BorderStyle = BorderStyle.NoTitle; myForm.ControlBox = false; CSet your forms Title and ControlBox properties; myForm.Title = false; myForm.ControlBox = false; DSet your forms Text and ControlBox properties; myForm.Tetx = ""; myForm.ControlBox = false; How do you set several lines into a multiline textbox? (1) AAll are correct BtextBox1.Text = "This is line 1." + Enviroment.newLine + "This is line2"; CtextBox1.Text = "This is line 1.\r\n This is line 2"; DtextBox1.Text = stringvar1 + "\r\n" + stringvar2;

8-

9How can I enable the mnemonics (underline) to show when my application is launched on Window XP? Choose the best answer? (1) ARepair in Registry BOpen Control Panl. Choose Effects Button and uncheck the checkbox "Hide Underlined letters for keyboard navigation until I press the ALT Key". CRight 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". DOpen 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".

10How do you make your textbox textBox1 use all upper (or lower) case characters when user input? Select best answer? (1) AWrite code at Key_Press event and convert; textBox1.text=textBox1.Text.ToUpper(); BWrite code at Text_Changed event and convert; textBox1.text=textBox1.Text.ToUpper(); CUse the Format property of the TextBox to "#C" DUse the CharacterCasing property of the TextBox to CharacterCasing.Upper

How do you prevent users from resizing a form? (1) ASetting the Resize to false and setting the MaximizeBox property to false BSetting the FormBorderStyle to FixeDialog CSetting the FormStyle to Dialog DSetting the FormBorderStyle to FixeDialog and setting the MaximizeBox property to false 1-

2(1)

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

ARandom randNum = new Random(); randNum.Next(1. 108); BRandom randNum; randNum.Next(1. 108); CRandom randNum = new Random(); randNum.Next(108) + 1; DRandom randNum = new Random(); randNum.Next(0. 108); How can you prevent a form from being shown in the taskbar? (1) Athis.ShowIn Taskbar = false; Bthis.Show Tray = false; Cthis.ShowIn Taskbar = Taskbar.None; Dthis.TaskbarVisible = false;

3-

4-

How do I set the font for button button1? (1) Abutton1.Name = "Courier"; button1.FontSize = 10; button1.FontBold = FontStyle.bold; Bbutton1.Font = Fonr("Courier". 10. FontStyle.Bold); Cbutton1.Font = new Font("Courier". 10. FontStyle.Bold); Dbutton1.Font = new Courier (10. FontStyle.Bold);

5How to get result value of Number1 * Number2 from 2 textbox input and display on txtResult? Select best answer? (1) AtxtResult.Text = (ToDouble(txtNumber1.Text) * ToDouble(txtNumber1.Text)).ToString; BtxtResult.Text = (ToDouble(txtNumber1.Text) * ToDouble(txtNumber1.Text). CtxtResult.Text = Convert.ToDouble(txtNumber1.Text) * Convert.ToDouble (txtNumber1.Text); DtxtResult.Text = Convert.ToString(Convert.ToDouble(txtNumber1.Text) * Convert.ToDouble(txtNumber1.Text));

6-

How can you initialize an array of three bool values? (1) Abool b=true,true,true}; BbooL[3] b=new bool[3]={true,true,true}; Cbool[3] b={true,true,true}; Dbool [] b=new bool[3];

7How 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) A0 B21 C19 D20 If two StringBuilder objects contain the # (1) Athe are two different objects Bif one changes, so will the other Cthey represent the same meory location DNone of the above

8-

9(1)

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

Aprotected void GetAlphabet() { string strAlpha = " "; for (int i = 65; i < = 90; i++) { strAlpha + = i.ToChar() + " "; } } Bprotected void GetAlphabet() { string strAlpha = " "; for (int i = 65; i < = 90; i++) { strAlpha + = i.char(i.ToString()) + " "; } } Cprotected void GetAlphabet()

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

10If you do not indicate a return type for a method, its return type is ____ by default. (1) Avoid BPrivate CInt DPublic

1-

If an IndexofAny method is passed an # (1) Afinds the first occurrence of each letter in the string Bgenerates an error Cwill search for the first occurrence of the sequence of characters # Dsearches for the first occurrence of any of the characters #

2If a programmer inserts "using System"# System.Console.out.WriteLine("Hello");? (1) AConsole.WriteLine("Hello"); BConsole.Out("Hello"); CWriteLine("Hello"); DSystem("Hello");

3If you want to use the Book class for store 500 books, write a segment to how use to declare and create your instantiations. (1) ABook[] store = new Book[500]: for (int i = 0; i < store.Lenght; i++) store[i] = new Book(); BBook[] store = new Book[500]: for (int i = 0; i < store.Lenght; i++) store[i] = Book(i); CBook store = new Book: for (int i = 0; i < store.Lenght; i++) store[i] = new Book(); Dstore[] Book = new Book[500]: for (int i = 0; i < store.Lenght; i++) store[i] = new Book();

4If programmer write a following segment, how to translate to it in term of for statement. foreach (int count in homwwork) homework[count] = 100; (1) Afor (int count = 1; count<=homework.Lenght; count++) homework[count]=100; Bfor (int count = 0; count<=homework.Lenght; count++) homework[count]=100; Cfor (int count = 0; count homework[count]=100; Dfor (int count = 0; count<=homework.Lenght; count++) 100=homework[count]; IL code compiles to ____. (1) APlatform-specific Executable code

5-

BCD-

Byte Code other .NET Code

6If 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) AThe program fails to compile B010 C100 D110 In C#, the name of a method I defined ____. (1) Alower Bproper Ccapitalized Dother To output the value of multidimensional array, # (1) AmyArray{1}{3}; BmyArray[1.3]: CmyArray[1][3]: DmyArray(1).(3): In C# Thread.Sleep (time) measures time in: (1) AAll of the above Bseconds

7-

8-

9-

CD-

nanoseconds miliseconds

10____ in simple terms is nothing but conversion of a value type into a reference type. (1) ABoxing BOverriding CUnboxing DCasting

1-

In the body of a method, C# uses # (1) Acall Bdo Cthat Dthis In C# datatypes are divided into two fundamental categories: (1) AClass and Non-Class type BValue types and reference types CPointers and values DPointers and Non-Pointers In order to add or remove an event from # (1) Aevent can only be added with the += and not removed# Bthe Add anad Subtract methods Cthe Add and Remove methods Dthe += and the -= operators

2-

3-

4int 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) AOther B>2 CNo ouput D<3 ____ is all about conveting a reference type into a value type. (1) AOverloading BBoxing CUnboxing DCasting ____ is a unit of class deployment. (1) AUnit BA Manifest CAn Assembly

5-

6-

D-

An Executable file

7-

Machine languages ____. (1) Aneed to be translated in order for the machine to under # Bconsists of numbers and letters Care machine dependent Dare universal between all machines Mehtod ____ of class Process can # (1) ABegin BInit CStart DRun

8-

9____ method of form displays the form as a model # any other form can receive the focus. (1) AShowDialog BDialog CDisplay D# Method ____ is used removes all the elements from # (1) AClearAll BClear CDelete DRemoveAll

10-

1namespace Spacel{ namespace Space2{ class MyClass{ } } } The fully qualified name of class MyClass is: (1) ASpace2.Space1.MyClass() BSpace1.Space2.MyClass() CSpace1.MyClass() DSpace2.MyClass()

2namespace College.Library{ namespace Shelf{ class Book{ } } } The fully qualified name of class Book is: (1) ACollege.Library.Book() BLibrary.Shelf.Book() CShelf.Book() DCollege.library.Shelf.Book()

3namespace 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) AThe ouput of code will be: The type of objA is : Space1 .A BThe code will generate a compile time error as class reference is required for the GetType() method. CThe ouput of code will be: The type of objA is : System.Space1 .A DThe ouput of code will be: The type of objA is : class .A

4-

object objectValue = "Hello,";

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) AHello, abcdef BabcdefHello CThe code will generate an error DNone of the other answers Panel have the abbility to have scrollbars # (1) ATrue BFalse CDepend on setting theme form Operating System DDepend on setting from Visual Studio.Net

5-

6Private 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) AThe code delete one items in Listbox if proper if(strItem.Substring (strItem.LastIndexOf(" ") + 1).Equals( strName)) BThe code will generate an error at if (strItem.Substring (strItem.LastIndexOf(" ") +1).Equals( strName)) CThe code delete all items in Listbox if proper if(strItem.Substring (strItem.LastIndexOf(" ") + 1).Equals( strName)) DThe code will loop in while Properties can contain ____. (1) Aget and set accessors Ba get accessor, a set accessor or both

7-

CD-

a get accessor a set accessor

8Select 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) AObject Bproperty CConstructor DClass Programs that translate high-level # (1) Aprocess Bexecute Cbuilt Dcompilers

9-

10Statement I: The sealed modifiers are not permitted in an enum declaration. Statement II: Delegate types are implicitly sealed (1) AOnly statement I is true BOnly statement II is true CBoth the stattements are true DBoth the statements are false

1StreamWriter 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) AWrite contain text txtNoidung to file Data.txt BThe code will generate an error CWrite contain text in txtNoidung to file chose in SaveFileDialog sDlg DAll way save text in txtNoidung to file Data.txt String indexers treat strings as: (1) A1 to string Lenght Barrays of chareacters Cbinary code Da character String mystring; Creates a(n) ____. (1) AObject Bproperty CConstructor DClass

2-

3-

4StringBuilder 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) AThe code will generate an error BHello, how are you? Thang CHello, how are you?Thang DNone of the others answers

5StringBuilder 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) AHello, how are you? Today! BThe code will generate an error CHello, Today! DNone of the other answers

6StringBuilder buffer = new StringBuilder("Hello, how are you?"); buffer.Insert(5, 123); What will be the fragment of above code assign to buffer variable? (1) AHello123, how are you? BThe code will generate an error CHello123o, how are you? DNone of the other answers

7StringBuilder 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) AHello Thang BNone ofther other answers CThe code will generate an error DHello Thang, how are you?

8Suppose 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 ( ); }

} catch (Exeption ex) { MessageBox.Show(ex.Tostring( )); } (1) Aj In 2008, "Clint" will be 78 BIn 2008, "Clint" will be 78 Cj Clint,1930 Dj In 2008, Clint will be 2008-1930

9The 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) Aexample does not compile by error syntax BWrite a random value Cwrites 42 Dexample does not compile by error because arg is initialized System namespace is used in the C# programs to: (1) Acapture program ouputs Binteract with other classes in the namespcae Cinteract with the system enviroment Dinteract with the operating system

10-

1-

The acive control is said to have the # (1) Atab Bpointer Cfocus Dselected The proper way to convert a string # (1) Astring.ToLower(): BString = string.ToLower(string): Cstring.ToLower(string): DToLower(string):

2-

3____ statement, when executed in a repetition structure, causes immediate exit from repetition structure. (1) Abreak Bcontinue Cend Dexit

4The ____ property of TabControl determines whether tabs can fill more than one row or not. (1) ATabPages BItemSize CTabCount DMultiLine

5The code public class B : A { } (1) ADefines a class that inherits all the methods of A BDefines a class A inherits all the methods of B CErrors DDefines a class that inherits the public methods of A only The statement: Private Button print = new Button ( ); (1) ADo nothing Bcreates and instantiates a button control Ccreates a button control Dinitializes a button control The properties window: (1)

6-

7-

ABCD-

allows you to change project properties allows you to write code allows you to change solution properties allows you to modify controls properties without writing any #

8The ____ event of Form object is fired # event is raised the first time that Form. Show or # (1) ANew BActivated CLoad DConstructor ____ is portable to non-window platform. (1) A.Net Framework BVB CVisual studio DC#

9-

10The 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) Aexample does not compile BWrite a random value Cwrites 42 Dwrites 43

1-

The statement: Private Button print = new Button(); (1) Acreates and instantiates a button control Binitializes a button control CDo nothing Dcreates a button control

2The 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) Aexample does not compile by error Bwrites 42 Cwrites 43 Dwrite a random value The joining of two strings together to form a new string is called ____. (1) Aaddition Bcompaction Cconcatenation Dsubstrings

3-

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

5The ____ statement allows you to iterate through the elements in an array without using a counter. (1) Afor Bwhile Cdo while Dforeach

6-

The base class Array belongs to the ____ namspace. (1) AArrays BSystem.Collection CGlobal.Type DSystem

7The methods which can be called without instantiating an object first are called ____. (1) Aprivate Bstatic Cdynamic Dprimary The constructor without parameters is called ____. (1) Anon-parameterized constructor Bdefault constructor Czero valued constructor Dmain constructor The extension of an assembly is ____. (1) A.dll B.cs C.exe D.ddl The ____ property specifies how text is aligned within a Labels boundaries. ABCDLeft Top Anchor TextAlign

8-

9-

10(1)

1-

To create a string literal exclude escap # (1) A!string B#string C@string D$string To allocate memory for an object instantiation, you must use the ____ (1) Aalloc Binstant Cnew Dmem To change the value of a variable while debugging, ____ window is used. (1) ALocal BDebug CWatch DImmediate

2-

3-

4try{ intX=Convert.ToInt32(lngX); intY=intX/intZero; } Write a catch clause usingfewest codes: (1) Acatch(OverflowException ex){} Bcatch(ArithmeticException ex){} Ccatch(OverflowException ex){} catch(DivideByZeroException ex){} catch(Exception ex){} Dcatch(DivideByZeroException ex){} Typical mouse events include ____ (1) Amouse clicks, mouse presses, mouse moves Bmouse double clicks, mouse presses, mouse moves Cmouse clicks, mouse presses, mouse down Dmouse clicks, mouse presses, mouse up Unboxing require an ____ cast. (1) Aexplicit Bimplicit CNone of the above Dimplicit or explicit

5-

6-

7-

Unlike C++, C# does not have ____. (1) Aattribute Btructure Cinterface Dpointer Using code, how to add a Separator in a menu named mnu1? (1) Amnu1.MemuItems.Add("-"); Bmnu1.MemuItems.Add("&"); Cmnu1.MemuItems.Add("_"); Dmnu1.MemuItems.Add(Menu.Separator);

8-

Value types differ from reference types as ____. (1) Adata in the value type variable is easily accessible BVariables of the value directly contain their data, whereas variables of the reference types store references to objects. Cvariables of the reference types directly contain their data, whereas variables of the value store references to objects. DNone of the above 9-

10using 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) AThe code does not compile because local variable is not initialized correctly BThe code does not compile because Var2 is not initialized C0 D4

1using 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) AThe output of above code will be: 99953 1.3433E35 BThe output of above code will be: 9953 1.3433E+35 CThe output of above code will be: 9953 1.3433 DThe code will generate compile time error

2using System; class Test { static void Main() { int @Main; int[] Static = new int[3] @Main = 100*Static[1]; Console.WriteLine(@Main); } } (1) AThe code cannot compile BThe code will display 0 CThe code will display 100 DThe code will return an error

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

} static void Display1(Array pArray) { foreach(int t in pArray){ } } } What will be the ouput of above code? (1) AThe ouput of code will be: 3 2 1 1 2 3 BThe code will generate an error compile time since the Sort() function of Array returns an integer number CThe ouput of the code will be: 321123 D#

4Using 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) AThe code will compile successfully and output of code will be: AMERICA BThe code will generate a compile time error

CD-

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

5-

We invoke method ____ to determine # local variable index. (1) AIndexOf BPosition CIndexOfString DIndex

6We use operator ____ when it makes an application clearner than accomplishing the same operations with explicit method calls. (1) Aconstructor Boverriding Coverloading DNone of the above

7Using 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) A5 8 B4 5 C8 5

D-

8-

What setting of the Dock peoperty wll # (1) ANone, you should use the Anchor property BTop CTop, Left, Right, Bottom DFill

9What does the following code segment display? for (t=0;t<3;++ t) Console.Write(t); (1) A012 B0123 C0 D01 What setting of the Anchor property # (1) ARight, Left BTop CNone DTop, Botton

10-

1What 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) AHE W BTHE WHOLE C4 DE WH What is an assembly? (1) ANone of the above B.NET debugger CA collection of C# compilers DA logical unit containing complited code

2-

3What is the output of the following code segment? int a=3, b=4; if (a= =b) Console.Write("Black"); Console.Write("Write"); (1) ABlackWhite BNothing CWhite DBlack What is CLS? (1) ACode Location Specification BCommon Language Specification CCsharp Language Specification DCommon Library System What is the shortcut way of creating an event # (1) ABy right-click in the control and select View Code BBy double-click the control in the Windows Forms Designer CBy writing an event handler and adding it to the control DBy double-click the name of the event in the Properties windows

4-

5-

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

while(s<4) ++s; Console.Write(s); (1) A4 B234 C1234 D1 What is automatic memory management in .NET known as: (1) AManaged automatic BManaged Code CGarbage Collection DSmart Caching

7-

8What 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) ANo output BFound it CSyntax error DThe new word was found What is the method of ArrayList, which used to remove # (1) ANone of the above BRemove CRemoveAt DRemoveRange What is Boxing? (1) AEncap sulating a base class BConversion of reference types to value types CConversion of integer value string value

9-

10-

D-

Conversion of value types to reference types

1What is stored in the variable strResult after the following statement executes? String strResult; strResult = "Michael" & "Ekedahl"; (1) AMichaelEkedahl Bsyntax error CNone of the other answers DMichael Ekedahl What method of the String class returns a # (1) AThe same method BEqualTo method CSame method DEquals method

2-

3What value stored in the variable str2 after the following statements have executed? string str1= "OneTwoThreee"; string str2; str2 = str1.Substring(1, 10); (1) ANone of the other answers BThe statements will cause a syntax error CneTwo Three DOneTwoThre

4What is the name of the method to convert a Number data type to a string data type? (1) ANone of the other answers BConvert.ToSByte(Number); CConvert.ToString(Number); DConvert.FormatNumber(Number); What method of the String class remove # (1) ATrim BLRTrim CTrimLeftRight DOutSpace What functionality does the AutoScroll property provides # (1) AThe AutoScroll property aitomatically provides scroll bars on a form when BForm have no AutoScroll property

5-

6#

CD-

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

7What is the correct syxtax for displaying value of the String variable myString in a TextBox txtBox? (1) AtxtBox.Text = "myString"; BtxtBox.Text = myString; CtxtBox.Text = Str(myString); DtxtBox.Text.myString;

8What method of the String class returns # specifed character or string in a String object? (1) ALastIndexOf BLastOfString CLastLocationOf DLastPositionOf

9What 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) Atrue B0 Cfalse D1

10What is the name of the method to convert a String data type to a DateTime data type? (1) AConvert.ToDateTime(stringDate); BConvert.ToDate(stringDate); CFormatToDateTime(stringDate); DNone of the other answers

Potrebbero piacerti anche