Deck 4 Flashcards

1
Q

Your application requests FileIOPermission to open a file. The permission is denied. Which type of exception will be thrown?

A

SecurityException

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

An event declaration is shown in the following code segment. Public event NewProduccEventHandlerNewProduct; What is NewProductEventHandler in the event declaration?

A

The name of the delegate that will dispatch the event.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which two types of actions can trigger an event? (Each correct answer presents a complete solution. Choose two.)

A

User intervention, such as a mouse click.
—–AND—–
Declaring the signature of the delegate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

You need to handle only SqlException exceptions. You also need to ensure that any other exception flows back to the calling code. Which code segment should you use?

A
try
   {
   }
catch (SqlException)
   {
   }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

You write a method named DoWork. You need to log all exceptions that occur inside DoWork. You also need to ensure that all exceptions are raised to the calling code. Which code segment should you use?

A
private void DoWork()
{
   try
   {
      //Method body
   }
catch (Exception exc)
   {
      //Insert code to log exception here
      throw exc;
   }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Connection strings in the web.config file are:

A

Stored in clear text unless they are encrypted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In which file does a .NET Windows application store information that has been customized for a particular instance of the application?

A

User.config

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

You need to force the position of the cursor on the screen at (15, 10). Which code segment should you use?

A

Console.SetCursorPosition(15, 10);

Console.ReadKey();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

You create a program that writes a status message to a file every 10 seconds. You need to ensure that all data is written to the file before the file is closed. When should you call the Flush() method?

A

After writing the entry

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

You want to insert a new line on the console. Which three code fragments will display “Hello” followed by a new line? (Each correct answer presents a complete solution. Choose three.)

A
Console.Write("Hello\n");
-----AND-----
Console.Error.WriteLine ("Hello");
-----AND-----
Console.WriteLine("Hello");
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which method will be called when a FileStream is collected by the garbage

A

Finalize

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

You create a class that does not explicitly inherit from any base class. Which is the implied base type of the class?

A

Object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

You create an ArrayList object. You need to ensure that only objects of the System.DateTime type can be added to the collection. What should you do?

A

Use a List collection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which code segment prevents the class named Final from being inherited?

A
partial class Final
{
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

You use code from different companies. You need to avoid naming conflicts within your code. What should you do?

A

Deploy the classes as two separate files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

You need to create a DLL that contains classes that can be reused in other projects. Which type of Microsoft Visual Studio project should you use?

A

Class Library

17
Q

Which two actions are performed by the .NET Version class? (Choose two.)

A

Returns the version number of an assembly.
—–AND—–
Returns the version number of the Common Language Runtime.

18
Q

Which class should you use to perform a search of an XML document?

A

XmlNode

19
Q

You load an XML document named doc1 that has an attribute named EmployeeId. Which code fragment will set the value of EmployeeId to A23?

A

Doc1.CreateElement(“Employeeld”,”A23”);

20
Q

You create a custom exception class named MyCustomException that is derived from ApplicationException. Which code segment should you use to raise MyCustomException?

A

catch (Exception exc)
{
throw new MyCustomException (exc);
}