44
Test Engine Q3 Soft 1. What is the purpose of public access specifier? (1đ) A. The public access specifier allows a class to hide its member variables and member functions from other class objects and functions. B. The public access specifier allows a class to expose its member variables and member functions to other function and objects. C. The public access specifier allows a class to show its member variables and member functions to the containing class, derived classes, or to classes within the same application. D. The public access specifier allows a class to hide its member variables and member functions from other class objects and functions, except the child class. 2. What is realistic modeling? (1đ) A. Realistic modeling is the approach to model the real world more accurately. B. Realistic modeling is the approach to exist in different forms. C. Realistic modeling is the approach to allow systems to evolve. D. Realistic modeling is the approach of using existing classes or objects from other applications. 3. John has written a program in C# to store a list of random numbers in an array of size 10. During program execution, John tries to enter an 11 th element in the array. Identify the type of exception the system would have thrown. (2đ) A. System.IndexOutOfRangeException

Test Engine

Embed Size (px)

Citation preview

Page 1: Test Engine

Test Engine Q3 Soft

1. What is the purpose of public access specifier? (1đ)A. The public access specifier allows a class to hide its member variables

and member functions from other class objects and functions.

B.The public access specifier allows a class to expose its member variables and member functions to other function and objects.

C. The public access specifier allows a class to show its member variables and member functions to the containing class, derived classes, or to classes within the same application.

D. The public access specifier allows a class to hide its member variables and member functions from other class objects and functions, except the child class.

2. What is realistic modeling? (1đ)

A.Realistic modeling is the approach to model the real world more accurately.

B. Realistic modeling is the approach to exist in different forms.C. Realistic modeling is the approach to allow systems to evolve.D. Realistic modeling is the approach of using existing classes or objects

from other applications.

3. John has written a program in C# to store a list of random numbers in an array of size 10. During program execution, John tries to enter an 11th element in the array. Identify the type of exception the system would have thrown. (2đ)

A.System.IndexOutOfRangeExceptionB. System.DividedByZeroExceptionC. System.NullReferenceExceptionD. System.OutOfMemoryException

4. What is the purpose of the member, Appentd, in the FileMode enumerator? (1đ)

A. It always creates a new file.

Page 2: Test Engine

B.It opens the file if it exists and places the cursor at the end of file, or creates a new file.

C. It opens only existing file.D. It opens the file if it exists and places the cursor at the beginning of

file.

5. Which of the following does NOT hold true for a delegate? (1đ)A. The methods that can be referenced by a delegate are determined by the

delegate declaration.

B.A multicast delegate derives from the System.MulticastDelegate class.

C. A delegate is a reference type variable, which holds the reference to a method.

D. A single-cast delegate contains an invocation list of multiple methods.

6. Consider the following code snippet: (4đ)

public class Test { public delegate void myDelegate(String s); public static void accept(string str) { Console.WriteLine("{0} accept() function", str); //Implementation } public static void show() { //Implementation } public static void display(myDelegate PMethod) { PMethod("This is in the"); } public static void Main() { myDelegate d1 = new myDelegate(accept); myDelegate d2 = new myDelegate(show); display(d1); display(d2); } }

There is some problem in the preceding code snippet. Identify the problem and provide the correct code snippet.

Page 3: Test Engine

A. public class Test

{ public delegate void myDelegate(String s); public static string accept(string str) { Console.WriteLine("{0} accept() function", str); return str; } public static string show(string str) { Console.WriteLine("{0} display() function", str); return str; } public static void display(myDelegate PMethod) { PMethod("This is in the"); } public static void Main() { myDelegate d1 = new myDelegate(accept); myDelegate d2 = new myDelegate(show); display(d1); display(d2); } }

B. public class Test { public delegate void myDelegate(); public static void accept(string str) { Console.WriteLine("{0} accept() function", str); //Implementation } public static void show(string str) { Console.WriteLine("{0} display() function", str); //Implementation } public static void display(myDelegate PMethod) { PMethod("This is in the"); } public static void Main() { myDelegate d1 = new myDelegate(accept); myDelegate d2 = new myDelegate(show); display(d1); display(d2); } }

C.public class Test

Page 4: Test Engine

{ public delegate void myDelegate(String s); public static void accept(string str) { Console.WriteLine("{0} accept() function", str); //Implementation } public static void show(string str) { Console.WriteLine("{0} display() function", str); //Implementation } public static void display(myDelegate PMethod) { PMethod("This is in the"); } public static void Main() { myDelegate d1 = new myDelegate(accept); myDelegate d2 = new myDelegate(show); display(d1); display(d2); } }

D. public class Test { public delegate void myDelegate(String s); public static void accept() { //Implementation } public static void show() { //Implementation } public static void display(myDelegate PMethod) { PMethod("This is in the"); } public static void Main() { myDelegate d1 = new myDelegate(accept);

Page 5: Test Engine

myDelegate d2 = new myDelegate(show); display(d1); display(d2); } }

7. Which of the following does NOT hold true for constructor? (1đ)A. Instance constructors are used to initialize data members of the class

B.Static constructors are used to initialize non-static variables of a class

C. Static constructors have an implicit private access.D. Instance constructor is called whenever an instance of a class is

created

8. Consider the following code: (4đ)

class Test { public Test() { } public Test(string name) { Console.WriteLine("Hello" + name); } } class myClass : Test { public myClass(int age) : base("Sam") { Console.WriteLine("Your age is " + age); } public myClass(string book) { Console.WriteLine("Your favourite book is " + book); } public static void Main() { myClass obj1 = new myClass(17); myClass obj2 = new myClass("The trail of years"); } }

Identify the output of the preceding code.

Hello Sam

Your age is 17

Page 6: Test Engine

Your favorite book is The trail of years

Your age is 17

Your favorite book is The trail of years

Hello Sam

Your age is 17

Your favorite book is The trail of years

Hello Sam

9. John has to create an application in which he needs to create a user-defined exception class CustomerRecordNotFoundException. In the CustomerRecordNotFoundException class, he has to declare two constructors with different parameters. Which of the following code snippet he should use for this purpose? (4đ)

using System;

public class CustomerRecordNotFoundException : Exception{ public CustomerRecordFoundException() { } public CustomerRecordNotFoundException(string message) : base(message) { }}

public CustomerRecordNotFoundException : ApplicationException{ public CustomerRecordNotFound() { }

Page 7: Test Engine

public CustomerRecordNotFound(string message) : base(message) { }}

public class CustomerRecordNotFoundException : ApplicationException{ public CustomerRecordNotFoundException() { } public CustomerRecordNotFoundException(string message) : Exception(message) { }}

public class CustomerRecordNotFoundException : ApplicationException{ public CustomerRecordNotFoundException() { } public CustomerRecordNotFoundException(string message) : Exception(message) { }}

10. Mary has to write a program in which she wants all the variables of a class to be accessible only within that class and its sub classes. Which of the following access specifier should Mary use to accomplish this task? (2đ)

A. Public B. Internal

C. Private

D.Protected

11. Anna needs to write code in C# to work with a file named Test.txt. According to the requirement, the Test.txt file should get opened as soon as the program starts executing. If Test.txt does not already exist, a new file with the same name should get created. However, if the file exists, she needs to ensure that

Page 8: Test Engine

the pointer is at the beginning of the file. Identify the correct code snippet that would enable Anna to accomplish this task. (3đ)

FileStream fs = new FileStream("Test.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);StreamReader sr = new StreamReader(fs);sr.BaseStream.Seek(0, SeekOrigin.End);string struct = sr.ReadLine();

FileStream fs = new FileStream("Test.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);StreamReader sr = new StreamReader(fs);sr.BaseStream.Seek(0, SeekOrigin.Begin);string struct = sr.ReadLine();

FileStream fs = new FileStream("Test.txt", FileMode.Open, FileAccess.ReadWrite);StreamReader sr = new StreamReader(fs);sr.BaseStream.Seek(0, SeekOrigin.Begin);string struct = sr.ReadLine();

FileStream fs = new FileStream("Test.txt", FileMode.CreateNew, FileAccess.ReadWrite);StreamReader sr = new StreamReader(fs);sr.BaseStream.Seek(0, SeekOrigin.Begin);string struct = sr.ReadLine();

12. Which of the following is a logical operator? (1đ)

A.&B. ++C. ==D. /=

13. John wants to write a program in C# to display a list of first n natural numbers. The total numbers of natural numbers to be displayed needs to be accepted from the user. Identify the correct code that would enable John to accomplish his task. (3đ)

A. class Numbers { public int range; public void Accept() { Console.WriteLine("Enter the range: "); range = Convert.ToInt32(Console.ReadLine()); } public void Display() { for (int i = 1; i <= range; i++)

Page 9: Test Engine

{ Console.Write(i + "\t"); } } public static void Main(string[] args) { Numbers obj = new Numbers(); Numbers.Accept(); Numbers.Display(); } }

B.class Numbers { public int range; public void Accept() { Console.WriteLine("Enter the range: "); range = Convert.ToInt32(Console.ReadLine()); } public void Display() { for (int i = 1; i <= range; i++) { Console.Write(i + "\t"); } } public static void Main(string[] args) { Numbers obj = new Numbers(); obj.Accept(); obj.Display(); } }

C. class Numbers { public int range; public void Accept() { Console.WriteLine("Enter the range: "); range = Convert.ToInt32(Console.ReadLine()); }

Page 10: Test Engine

public void Display() { for (int i = 1; i <= range; i++) { Console.Write(i + "\t"); } } public static void Main(string[] args) { Accept(); Display(); } }

D. class Numbers { public int range; public void Accept() { Console.WriteLine("Enter the range: "); range = Convert.ToInt32(Console.ReadLine()); } public void Display() { for (int i = 1; i <= range; i++) { Console.Write(i + "\t"); } } public static void Main(string[] args) { Numbers obj = new Numbers(); Accept(); Display(); } }

14. Consider the following code snippet: (2đ)

class Medicine { public static void Main(string[] args) { string lMedicine_Name; double Medicine_Price; Console.WriteLine("Enter the name of the medicine: "); lMedicine_Name = Console.ReadLine(); Console.WriteLine("The price of the medicine is Rs.50"); Console.ReadLine(); } }

Page 11: Test Engine

When the preceding code is executed, it show error. Identify the error in the preceding code.

A. The data type used with the variable Medicine_Price is invalidB. The variable lMedicine_Name is invalid

C.The variable Medicine_Price is invalidD. The data type used with the variable lMedicine_Name is invalid

15.Which data type can be used for a variable that stores the grade of a student in a particular exam, where the grades can be A, B,

or C? (1đ)A. intB. char[]

C.charD. float

16. Which of the section handlers, used by the .NET Framework, return a hash table containing name/value settings ? (1đ)

A. SingleTagSectionHandlerB. IgnoreSectionHandler

C.DictionarySectionHandlerD. NameValueSectionHandler

17. You are creating a deployment project. You want to add a registry to the deployment project by using Registry Editor. Which of the following option provides the correct setps to add a registry key to the deployment project ? (3đ)10.20

1.Select View Editor Registry to open the Registry Editor.

2.Select one of the top-level key nodes in the Registry Editor.

3.Select Action New Key to create a New Key node in the selected top-level key node.

4. Specify the name of the key by setting the Name property in the Properties window.

Page 12: Test Engine

1.Select View File System Registry to open the Registry Editor.

2.Select one of the top-level key nodes in the Registry Editor.

3.Select Action New Key to create a New Key node in the selected top-level key node.

4.Specify the name of the key by setting the KeyName property in the Properties window.

1.Select View File System Registry to open the Registry Editor.

2.Select one of the top-level key nodes in the Registry Editor.

3.Select Action New Key to create a New Key node in the selected top-level key node.

4.Specify the name of the key by setting the Name property in the Properties window.

1.Select View File System Registry to open the Registry Editor.

2.Select one of the top-level key nodes in the Registry Editor.

3.Select Action New Key to create a New Key node in the selected top-level key node.

4.Specify the name of the key by setting the Name property in the Properties window.

18. Consider the following two statements: (2đ)

A.Major version number of an assembly gets changed while adding a new class or a new project.

B.Minor version number of an assembly gets changed when a module or function is added to the project.

Which of the following option is correct with regard to the above mentioned statements ?

A.Both A and B are True.B. Both A and B are False.

Page 13: Test Engine

C. A False and B True.D. A True and B False.

19. ________ template is used to create a single package containing all the files, resources, registry entries, and the setup logic necessary for deploying a component. (1đ)

A. Cab ProjectB. Setup Project

C.Merge Module ProjectD. Web Setup Project

20. Consider the following code which is written to overload a unary operator: (3đ)

using System;namespace p{ class opr { public int a, b; public opr(int x, int y) { a = x; b = y; } public static opr operator -(opr o) { o.a- = o.a; o.b- = o.b; return o; } public void display() { Console.WriteLine("a=" + a); Console.WriteLine("b=" + b; Console.ReadLine(); } }

class opr.override { static void Main() { opr obj = new opr(2, -5); obj = -obj; obj.display(); }

Page 14: Test Engine

}}

When the code is executed, it displays the result 0,0. It should display the result -2.5. Which of the following code will solve this problem?

public static opr operator -(opr o){ o.a = -o.a; o.b = -o.b; return o; }

public static opr operator --(opr o){ o.a-- = o.a; o.b-- = o.b; return o; }

public static opr operator -(opr o){ o.a = -o.a; o.b = -o.b; return a,b; }

public static opr operator --(opr o){ o.a = --o.a; o.b = --o.b; return o; }

21. A form has a button cmdCommand1, which when clicked must display another form named frmNext. Which of the following statements will you write in the Click event of the cmdCommand1 button? (3đ)

frmNext frmObj;fmrObj.Show()

frmNext.Show();

show(frmNext);

Page 15: Test Engine

frmNext frmObj = new frmNext();frmObj.Show();

22. Sam is creating an application. He wants to convert a source data from the character array, named charData, to a byte array by using code Page 1253 format. He writes the following code to perform this activity. (4đ)

using System.Text;......bype[] ByteData;Encoding myEncoding;myEncoding = Encoding.GetEncoding(1253);ByteData = myEncoding.GetBytesArray(charData);

On building the application, he receives an compile time error in the above mentioned code. How this error can be corrected?

A. Error can be corrected by modifying the given code as:

using System.Text;......bype[] ByteData;Encoding myEncoding;myEncoding = Encoding.Convert(1253);ByteData = myEncoding.GetBytesArray(charData);

B. Error can be corrected by modifying the given code as:

using System.Text;......bype[] ByteData;Encoding myEncoding;myEncoding = new Encoding(1253);ByteData = myEncoding.GetBytesArray(charData);

C.Error can be corrected by modifying the given code as:

using System.Text;......bype[] ByteData;Encoding myEncoding;myEncoding = Encoding.GetEncoding(1253);ByteData = myEncoding.GetBytes(charData);

Page 16: Test Engine

D. Error can be corrected by modifying the given code as:

using System.Text;......bype[] ByteData;Encoding myEncoding;myEncoding = new Encoding(1253);ByteData = myEncoding.GetBytes(charData);

23. Consider the following statements: (2đ)

A: Output file of a custom control is created in the <Application Folder>\Debug\bin folder

B: Output file of a custim control will be a DLL file.

Which of the following option is true with regard to above mentioned statements?

A. Both A and B True.B. Both A and B False.C. A True and B False.

D.A False and B True.

24. Which assembly is responsible for exposing the ActiveX control as a .NET control? (1đ)

A. Axinterop.msacalB. MASCAL

C.Axinterop.MSACALD. Axinterop.Mascal

25. You created a form named frmMainMenu. You also added a ContexMenuStrip control named cmMenu1 to frmMainMenu. When a user right-clicks frmMainMenu, the context menu must be displayed. When a user selects the View option from the context menu, another form named frmView must be displayed as the child form of frmMainMenu. Which of the following options will help you achieve this? (4đ)

Page 17: Test Engine

A.Set the IsMdiContainer property of frmMainMenu to True. Set the ContextMenuStrip property of frmMainMenu to cmMenu1. Add the following code to the event handler for the Click event of the View menu option:

frmView frmObj = new frmView();frmObj.MdiParent = this;frmObj.Show();

B. Set the IsMdiContainer property of frmMainMenu to True. Set the ContextMenuStrip property of frmView to cmMenu1. Add the following code to the event handler for the Click event of the View menu option:

frmView frmObj = new frmView();frmObj.MdiParent = this;

C. Set the IsMdiContainer property of frmView to True. Set the ContextMenuStrip property of frmView to True. Add the following code to the event handler for the Click event of the View menu option:

frmView frmObj = new frmView();frmObj.MdiParent = this;frmObj.Show();

D. Set the IsMdiContainer property of frmMainMenu to True. Set the ContextMenuStrip property of frmMainMenu to True. Add the following code to the event handler for the Click event of the View menu option:

frmView frmObj = new frmView();frmObj.MdiParent = this;frmObj.Show();

26. Sam is developing an application. He wants to write code to play a wave file on the Click event of a Button control, named btnPlay. The name of the wave file to be played is already stored in a string variable, named MusicFile. Due to large size of the wave file, he wants that the file should be loaded asynchronously in the background. Which of the following options gives the correct code to perform this activity? (3đ)

using System.Media;.......private void btnPlay_Click(object sender, EventArgs e){

Page 18: Test Engine

SoundPlayer sp = new SoundPlayer(); sp.LoadAysnc(MusicFile); sp.Play();}

using System.Media;.......private void btnPlay_Click(object sender, EventArgs e){ SoundPlayer sp = new SoundPlayer(MusicFile); sp.Play();}

using System.Media;.......private void btnPlay_Click(object sender, EventArgs e){ SoundPlayer sp = SoundPlayer.LaodAsync(MusicFile); sp.Play();}

using System.Media;.......private void btnPlay_Click(object sender, EventArgs e){ SoundPlayer sp = new SoundPlayer(); sp.LoadAysnc(MusicFile); sp.PlayAsync();}

27. Which of the following method of the Process control will stop the execution of a process for specified number of seconds? (1đ)

A. Sleep()B. SleepForExit()

C.WaitForExit()D. Wait()

28. John is creating an MDI application. The application contains an MDI parent form named depDetails and an MDI child

Page 19: Test Engine

form frmSales. Now he wants that when a user click the menuSales menu iten on the deptDetails form than the frmSales form should be displayed. Which of the following code option will perform the desired operation? (3đ)

private void menuSales_Click(object sender, EventArgs e){ frmSales objSales = new frmSales(); objSales.MdiParent = this; objSales.Show();}

private void menuSales_Click(object sender, EventArgs e){ frmSales objSales = new frmSales(); objSales.MdiParent = this; frmSales.Show();}

private void menuSales_Click(object sender, EventArgs e){ Form objSales = new Form(frmSales); objSales.MdiParent = this; objSales.Show();}

private void menuSales_Click(object sender, EventArgs e){ frmSales objSales = new frmSales(); objSales.MdiParent = deptDetails; objSales.Show();}

29. Mary needs to write a program to divide two numbers. She needs to ensure that the program does not terminate abruptly in the event of any exception. Write a code that would enable Mary to accomplish her task. (3đ)

Page 20: Test Engine

using System;

class Test{ public static void calculate(int number1, int number2) { try { int res = number1 / number2; Console.WriteLine(res); } catch(DivideByZeroException e) { Console.WriteLine(e.ToString()); } } public static void Main() { Test.calculate(8, 0); Console.ReadLine(); }}

using System;

class Test{ public static void calculate(int number1, int number2) { try { int res = number1 / number2; Console.WriteLine(res); } Throw DivideByZeroException e){} } public static void Main() { Test.calculate(8, 0); Console.ReadLine(); }}

Page 21: Test Engine

using System;

class Test{ public static void calculate(int number1, int number2) { try { int res = number1 / number2; Console.WriteLine(res); catch(DivideByZeroException e) Console.WriteLine(e.ToString()); } } public static void Main() { Test.calculate(8, 0); Console.ReadLine(); }}

using System;

class Test{ public static void calculate(int number1, int number2) { try { int res = number1 / number2; Console.WriteLine(res); } catch(IndexOutOfRangeException e) { Console.WriteLine(e.ToString()); } } public static void Main() { Test.calculate(8, 0); Console.ReadLine(); }}

30. Which of the following controls you need to add to the form to invoke the default Print dialog box? (1đ)

A. PageSetupDialog and PrintPreviewDialog

Page 22: Test Engine

B. PrintDialog and PrintDocumentC. PrintDocument and PrinPreviewDialog

D.PrintDialog and PrintPreviewDialog

31. Which of the following option will convert an integer variable, named MuCurrency, to the culture specific currency formating? (2đ)

A.MyCurrency.ToString("C", Thread.CurrentThead.CurrentCulture);

B. Thead.CurrentThread.CurrentUlCulture.MyCurrency.ToString("C");C. Thread.CurrentThread.CurrentCulture.MyCurrency.ToString("C");D. MyCurrency.ToString("C", Thread.CurrentThread.CurrentUlCulture);

32. Which of the following value of SelectionMode property of ListBox control allows the user to select multiple items and use the Shift, Ctrl, and arrow keys to make selections from the ListBox control? (2đ)

A. MultipleExtendedB. MultiSimple

C.MultiExtendedD. MultiSelection

33. Ivan is creating a Windows form named form1 for an application. He wants to add a Button control named button1 in the form at the run time. He also wants to add a click event for the button1, which should display a message box with the message “Button Clicked” when the user clicks the button. He adds the following code in the form1 class to perform this activity. (4đ)

private void Form1_Load(object sender, EventArgs e) { button1.Text = "Click me"; this.Controls.Add(button1); } public Form1() { InitializeComponent(); }

Page 23: Test Engine

private void button1_Click(object sender, EventArgs e) { MessageBox.Show("Button Clicked"); }

When Ivan runs the applications and clicks the button1, no message box is displayed. How this error can be corrected?

A. Use Form.Controls.Add(button1); code line in place of this.Controls.Add(button1); code line in the Form1_Load event.

B.Add the following code beneath the InitializeComponent() line of button1.Click += new EventHandler(button1_Click);

C. Use Message.Show() method in place of MessageBox.Show() method in the button1_Click() event.

D. Create the instance of the Button control inside the Form1_Load method in place of outside the Form1_Load method.

34. Sam is creating a Windows form for a GUI application. In addition to other controls, he adds an ErrorProvider control named errorProvider1 to the form and use the SetError method to display error messages for various controls. In case of any error. Now he wants that error icon of the errorProvider1 should not blink while notifying the error for any control. Which of the following code snippet will change the blinking property of the error icon accordingly? (3đ)

A. errorProvider1.BlinkStyle = ErrorBlinkStyle.DoNotBlink;

B.errorProvider1.BlinkStyle = ErrorBlinkStyle.NeverBlink;

C. errorProvider1.BlinkRate = ErrorBlinkStyle.NeverBlink;D. errorProvider1.BlinkRate = ErrorBlinkStyle.DoNotBlink;

35. Which of the following statements correctly describes the DragOver event of the drag-and-drop operation? (2đ)

Page 24: Test Engine

A.DragOver event is triggered when a user drags an item while the moise pointer is within the limits of the control’s boundaries.

B. DragOver event is triggered on the completion of the drag-and-drop operation.

C. DragOver event is triggered when a user drags an item onto the control’s boundaries.

D. DragOver event is triggered when a user drags an item out of the control’s boundaries.

36. A cross-platform, hardware and software independent markup language that enables you to store data in a structured form at by using meaningful tags that can be interpreted by any computer system is ________ (1đ)

A. JavaScript

B.XMLC. HTMLD. DHTML

37. John has developed a function, tmpConvert(), in C# to convert temperature from Fahreheit to Celsius. He asked to modify this function so as to display the result to the user. Therefore, John creates a new function, tmpConvert_New(). However, he wants to retain the previous function, tmpConvert(), which he had created earlier. Which attribute should John user accomplish this task? (2đ)

A. DllimportB. ConditionalC. WebMethod

D.Obsolete

38. Consider the following code snippet: (4đ)

class abc {

Page 25: Test Engine

public void a(string s) { lock (this) { Console.WriteLine("start"); for (int i = 0; i < 50; i++) { Console.Write(s); } Console.WriteLine("end"); } } }

What does the lock statements refer to?

A. It refers to Synchronization.B. It will generate an error.C. It refers to Lock starvation.

D.It refers to monitor locks.

39. Which predefined attribute enables you to inform the compiler to discard a piece of target element? (1đ)

A. WebMethod

B.ObsoleteC. DllimportD. Conditional

40. Which of the following options is not the valid value for Right To Left property of the form? (2đ)

A. YesB. No

C.TrueD. Inherit

1. You created a form containing a LinkLabel control, llConnect. When a user clicks the LinkLabel control, a browser window should open with the www.yahoo.com page. Which of the following statements can you use to perform the above task? (2đ)

Page 26: Test Engine

A. Process.Diagnostics.Start(“http://www.yahoo.com”)B. System.Diagnostics.Start(“http://www.yahoo.com”)C. System.Start(“http://www.yahoo.com”)

D.System.Diagnostics.Process.Start(“http://www.yahoo.com”)

2. Sam is creating an application. He wants that formatting of elements in the application should be done according to the “en-US” culture, but the data separator, string used to separate the date information, should be used as “-“ in spite of date separator used by “en-US” (4đ)

using System.Globalization;using System.Threading;....CultureInfo AppCulture = new CultureInfo("en-US");AppCulture.DateTimeFormat.DateSeparetor = "-";CurrentThread.CurrentCulture = AppCulture;

On building this application he finds compile time error in the above mentioned code. How this error can be corrected?

A.The error can be corrected by modifying the given code as:

using System.Globalization;using System.Threading;....CultureInfo AppCulture = new CultureInfo("en-US");AppCulture.DateTimeFormat.DateSeparetor = "-";Thread.CurrentThread.CurrentCulture = AppCulture;

B. The error can be corrected by modifying the given code as:

using System.Globalization;using System.Threading;....CultureInfo AppCulture = CultureInfo.GetCulture("en-US");AppCulture.DateTimeFormat.DateSeparetor = "-";CurrentThread.CurrentCulture = AppCulture;

C. The error can be corrected by modifying the given code as:

using System.Globalization;using System.Threading;....CultureInfo AppCulture = new CultureInfo("en-US");

Page 27: Test Engine

AppCulture.DateTimeFormat.DateSeparetor = "-";Thread.CurrentThread.Culture = AppCulture;

D. The error can be corrected by modifying the given code as:

using System.Globalization;using System.Threading;....CultureInfo AppCulture = new CultureInfo("en-US");AppCulture.DateFormat.DateSeparetor = "-";CurrentThread.CurrentCulture = AppCulture;

3. Which of the following statement correctly describes the CurrentCulture property of the CultureInfo class? (2đ)

A. CurrentCultere property returns an instance of the CultureInfo class that represents the culture for culture-specific resources.

B. CurrentCulture property returns the name of the culture in the <Language code>-<Country/Region code> format.

C. CurrentCulture property returns the full name of the culture in the <Language code>-<Country/Region code> format.

D.CurrentCulture property returns an instance of the CultureInfo class that represents the culture for the current thread.

4. Which property of the ToolTip con trol is used to set the time period for which the moise pointer remains stationary in the tooltip region before the tooltip appears? (1đ)

A. AutopopDelayB. ReshowDelayC. AutomaticDelay

D.InitialDelay

5. You added a ContextMenuStrip control named cmContext1 to a form. The control has two options, Product Master and Salas Data Entry. How will you ensure that the menu items of cmContext1 are displayed when a user right-clicks the form? (4đ)

A. By setting the ContextMenuStrip property of the form to TrueB. By setting the ControlBox property of the form to cmContext1

C.By setting the ContextMenuStrip property of the form to cmContext1

D. By setting the IsMdiContainer property of the ContextMenuStrip control to the name of the form

6. Which of the following action cannot be performed on a text by using a dialog box created by the FontDialog class? (1đ)

A. Change the size of the text

Page 28: Test Engine

B. Change the font style of the textC. Underline the text

D.Change the color the text

7. You are creating MDI application. You want to add a menu to the MDI parent form that holds the ame of all the opened child windows and also allows a user to switch between the opened MDI child windows. Which of the following option gives the correct steps to perform this activity? (3đ)

A.1.Create a menu named Window2.Select the Window menu from the properties window and the property named MDIList to True

B. 1.Create a menu named Window2.Select the Window menu from the properties window and the property named ActiveMDIChild to True

C. 1.Create a menu named Window2.Select the Window menu from the properties window and the property named MDILayout to TileVertical

D. 1.Create a menu named Window2.Select the Window menu from the properties window and set the property named WindowList to True

8. Sam is asigned a task to write a program that displas a list of all the files present in a particular directory. He needs to display the name of the file, size of that file, and the extension of that file. Write the code that would enable Sam to accomplish his task. (3đ)

A. DirectoryInfo MydirInfo = new DirectoryInfo(@"C:\myDirectory");FileInfo FilesInDir = MydirInfo.GetFiles();foreach (FileInfo file in MydirInfo){

Console.WriteLine("File Name: {0} Size: {1} bytes Extension: {2} ", file.Name, file.Length, file.Extension); }Console.ReadLine();

B. DirectoryInfo MydirInfo = new DirectoryInfo(@"C:\myDirectory");FileInfo FilesInDir = MydirInfo.GetFiles();foreach (FileInfo file in MydirInfo){

Console.WriteLine("File Name: {0} Size: {1} bytes Extension: {2} ", MydirInfo.Name, MydirInfo.Length, MydirInfo.Extension); }Console.ReadLine();

C.DirectoryInfo MydirInfo = new DirectoryInfo(@"C:\myDirectory");

FileInfo FilesInDir = MydirInfo.GetFiles();

Page 29: Test Engine

foreach (FileInfo file in FileInDir){

Console.WriteLine("File Name: {0} Size: {1} bytes Extension: {2} ", file.Name, file.Length, file.Extension); }Console.ReadLine();

D. DirectoryInfo MydirInfo = new DirectoryInfo(@"C:\myDirectory");FileInfo FilesInDir = FilesInDir.GetFiles();foreach (FileInfo file in FileInDir){

Console.WriteLine("File Name: {0} Size: {1} bytes Extension: {2} ", file.Name, file.Length, file.Extension); }Console.ReadLine();

9. Which of the following property of a Windows form is set to true to create an MDI Parent form? (1đ)

A. ActiveMdiChildB. MdiLayout

C.IsMDIContainerD. MdiParent

10. Which type of project is created by selecting the Class Library template in Microsoft Visual Studio? (2đ)

A. Class Library template creates an application with a Windows user interface.

B. Class Library template creates a console application that can run from the command prompt.

C. Class Library template creates a class or a reusable component (.dell or .exe) that exposes some functionality to be used in various projects.

D. Class Library template creates a custom control that can be added to the user interface.

11. Ivan is writing code to display a message box on the click event of button. The message box will display a warning message to the user with Yes, No, Cancel button. He writes the following code to display the message box. (4đ)

private void button1_Click(object sender, EventArgs e){

MessageBox.Show("Do You want to continue", "File Save", MessageBoxIcon.Warning, MessageBoxButtons.YesNoCancel);}

Page 30: Test Engine

When Ivan run this code, compile time error has occurred. How this error can be corrected.

Ivan should modìy the given code as:private void button1_Click(object sender, EventArgs e){

MessageBox.ShowMessage("Do You want to continue", "File Save", MessageBoxButtons.YesNoCancel, , MessageBoxIcon.Warning);}

Ivan should modify the given code as:private void button1_Click(object sender, EventArgs e){

MessageBox.ShowMessage("Do You want to continue", "File Save", MessageBoxIcon.Warning, MessageBoxButtons.YesNoCancel);}

_____________________________________________________________________________________________________

12. John is creating a Windows form named form1 for a .NET application. He wants to add a Label control named label1 in form1 at run time and wants to set the text property of the label1 equals to “Welcome User”. John also wants that label1 should be displayed in red color. Which of the following option will correctly perform this task? (3đ)

A. Add the following code in the form1_Load eventLabel label1 = new Label();Form1.Controls.Add(label1);label1.Text = "Welcome User";label1.ForeColor = Color.Red;

B. Add the following code in the form1_Load eventLabel label1 = new Label();this.AddControls(label1);label1.Text = "Welcome User";label1.TextColor = Color.Red;

C. Add the following code in the form1_Load eventLabel label1 = new Label();this.Controls.Add(label1);label1.Text = "Welcome User";label1.TextColor = Color.Red;

D.Add the following code in the form1_Load eventLabel label1 = new Label();this.Controls.Add(label1);label1.Text = "Welcome User";label1.ForeColor = Color.Red;

Page 31: Test Engine

13. Which of the following statements correctly describes the system modal dialog box? (2đ)

A.A system modal dialog box does not allow a user to switch focus to another area of the application, which has invoked the dialog box. However, user can switch to other windows application.

B. A system modal dialog box allows a user to switch focus to another area of the application, which has invoked the dialog box. However, the user can not switch to other windows application.

C. A system modal dialog box allows a user to switch focus to another area of the application, which has invoked the dialog box. User can also switch to another Windows application.

D. A system modal dialog box takes control of the entire Windows environment. User is not allowed to switch to, or interact with, any other Windows application.

14. Which of the following are the features of the Windows environment? (1đ)1.10

A.Dynamic linkingB.Event-drivenC.Command Line Interface (CLI)

A. C and BB. A and C

C.A and BD. A,B and C

15. Consider a scenario in which there are currently two threads, T1 and T2, running on a single processor system. Now T2 has to perform some I/O related task. Therefore, T2 blocks T1 for some time. Which state is thread T1 currently in? (2đ)

A.Not RunnableB. RunnableC. UnstartedD. Dead

16. Consider the following class definition: (4đ)using System;using System.Threading;class sleep_demo{ public static void ChildThreadCall() { Console.WriteLine("Child thread started"); int SleepTime = 5000; Console.WriteLine("Sleeping for {0} seconds", SleepTime /1000); Thread.Sleep(SleepTime);

Page 32: Test Engine

Console.WriteLine("Wakeing Up"); }}Choose the correct definition for Main() to execute it.

public static void Main() { ThreadState ChildRef = new ThreadState(ChildThreadCall); Console.WriteLine("Main - Creating Child thread"); ChildThread.Start(); Console.WriteLine("Main - Have requested the start of child thread"); Console.ReadLine(); }

_____________________________________________________________

17. Which predifined attribute enables you to inform the compiler to discard a piece of target element? (1đ)

A.ObsoleteB. WebMethodC. DllimportD. Conditional

18. Consider the following statements: (2đ)Statement A: Crystal Reports support two models, pull and push, to access data from a data source.Statement B: In the push model, the database driver directly retrieves the data from the data source.Which of the following is true, with respect to the above statements?

A. Both A and B are TrueB. Both A and B are False

C.A is True and B is FalseD. A is False and B is True

19. Which of the following holds true for encapsulation? (2đ)

A. Encapsulation is defined as the process of looking for what you want in an object or a class.

B. Encapsulation is defined as the process of allowing access to nonessential details.

C.Encapsulation is defined as the process of enclosing one or more items within a physical or logical package.

D. Encapsulation is defined as the process of viewing the relevant information to the user.

20. Which class acts as the base class for all the predefined system exceptions? (1đ)

Page 33: Test Engine

A.System.ExceptionB. System.AppDomainUnloadedExceptionC. System.SystemExceptionD. System.ApplicationException

21. Which of the following is the correct syntax for declaring a delegate? (1đ)

A.delegate <return type> <delegate-name> <parameter list>

B. <return type> <delegate-name> <parameter list>C. <return type> delegate <delegate-name> <parameter list>D. Delegate <delegate-name> <return type> <parameter list>

22. Which is an instance constructor? (1đ)

A. An instance constructor is a class that is called whenever an instance of that class is created.

B.An instance constructor is a method that is called whenever and instance of a class is created.

C. An instance constructor is an event that called whenever an instance of a class is created.

D. An instance constructor is a static method that is called whenever an instance of a class is created.

23. Mary has written a program in which she needs to accept the values of two integer variables, number1 and number2, from the user. After accepting two integer values from the user, she needs to perform some modification on these integer values as shown in the following code snippet: (4đ)

public class Test { void modify(ref int a, int b) { int temp; temp = a; a = b; b = temp; } static void Main(string[] args) { Test classobj = new Test(); classobj.modify(ref Number1, Number2); //The value of Number1 and Number2 has already been accepted from the user Console.ReadLine(); } }

Page 34: Test Engine

On executing the preceding code snippet, the user enters the value of Number1 as 2 and Number2 as 4. What will be the final values stored in Number1 and Number 2 once the execution of the preceding code snippet finishes?

A. Value of Number1 = 2Value of Number2 = 2

B. Value of Number1 = 4Value of Number2 = 2

C. Value of Number1 = 2Value of Number2 = 4

D.Value of Number1 = 4Value of Number2 = 4

24. Predict the output of the following: (4đ)

using System;using System.IO;class classmain{ public static void Main() { int i = 0; cnt = 1; char ch; FileStream fs = new FileStream("C:\\Myfile.txt", FileMode.OpenOrCreate, FileAccess.Read); StreamReader sr = new StreamReader(fs); sr.BaseStream.Seek(0, SeekOrigin.Begin); while ((i = sr.Read()) != -1) { ch = Convert.ToChar(i); if (ch == ' ' || ch == '\n' || ch == '\t') cnt++; } Console.Write(cnt); Console.Read(); }}

A. It will count the number of pages in a file.B. It will count the number of words in a file.C. It will count the number of characters in a file.

D.It will count the number of lines in a file.

25. John has to write a program in which he wants to all the variables of a class to be accessible only within the functions of that class. Which of the following access specifier should John use to accomplish this task? (2đ)

A. Protected

Page 35: Test Engine

B. InternalC. PublicD. Private

26. How may bytes are requited to store a variable of type char? (1đ)

A. 4B. 3

C.2D. 1

27. Henry wants to develop a code to calculate the sum of two numbers. These numbers should be accepted from the user. Identify the correct code that would enable Henry to accomplish his task (3đ)

class Test{ public void Calculate() { Console.WriteLine("Enter first number: "); int num1 = Console.ReadLine(); Console.WriteLine("Enter second number: "); int num2 = Console.ReadLine(); int result = (num1 + num2); Console.WriteLine(result); } public static void Main(string[] args) { Test obj = new Test(); obj.Calculate(); }}

____________________________________________

28. David Smith is a technical support in an international call center. David is working on software, which tells him about the ratings on his calls given by the customer. The software gives the following messages, if the customer rating is in: (2đ)

Range 1-4: The customer is overall dissatisfied with your support.Range 5-7: The customer is some what satisfied with your work.Range 8-9: The customer is very satisfied and happy with your work.Identify the programming construct implemented in the preceding software.

A. do while loop constructB. while loop constructC. switch case construct

D.nested if else construct

Page 36: Test Engine

29. Which data type can be used for a varuable that stores the grade of a student in a particular exam, where the grades can be A, B or C? (1đ)

A. FloatB. Char[]C. CharD. Int

30. Which of the following option of the gacutil command is used to register the assembly to the GAC? (1đ)10.6 .net 2 đáp án /I

A. /lB. /uC. /fD. /r

31. You are configuring an application by using the application configuration file. In this process you want to enable the concurrent garbage collection by the CLR. Which of the following code snippet will correctly specify the required settings? (3đ)

A. <configuration><runtime>

<gcConcurrent enabed=”true”/></runtime>

</configuration>

B. <configuration><startup>

<gcConcurrent enabed=”true”/></startup>

</configuration>

32. You need to create a database during installation. Which editor would you use? (2đ)

A. Custom Actions Editor

B.Launch Conditions EditorC. File Types EditorD. User Interface Editor

Page 37: Test Engine