Deck 4 Flashcards
Your application requests FileIOPermission to open a file. The permission is denied. Which type of exception will be thrown?
SecurityException
An event declaration is shown in the following code segment. Public event NewProduccEventHandlerNewProduct; What is NewProductEventHandler in the event declaration?
The name of the delegate that will dispatch the event.
Which two types of actions can trigger an event? (Each correct answer presents a complete solution. Choose two.)
User intervention, such as a mouse click.
—–AND—–
Declaring the signature of the delegate.
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?
try { } catch (SqlException) { }
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?
private void DoWork() { try { //Method body } catch (Exception exc) { //Insert code to log exception here throw exc; } }
Connection strings in the web.config file are:
Stored in clear text unless they are encrypted.
In which file does a .NET Windows application store information that has been customized for a particular instance of the application?
User.config
You need to force the position of the cursor on the screen at (15, 10). Which code segment should you use?
Console.SetCursorPosition(15, 10);
Console.ReadKey();
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?
After writing the entry
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.)
Console.Write("Hello\n"); -----AND----- Console.Error.WriteLine ("Hello"); -----AND----- Console.WriteLine("Hello");
Which method will be called when a FileStream is collected by the garbage
Finalize
You create a class that does not explicitly inherit from any base class. Which is the implied base type of the class?
Object
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?
Use a List collection.
Which code segment prevents the class named Final from being inherited?
partial class Final { }
You use code from different companies. You need to avoid naming conflicts within your code. What should you do?
Deploy the classes as two separate files.