C# Certification Flashcards
70-483 Certification Exam Review
Suppose you are developing an application which stores a user’s browser history. Which collection class will help to retrieve information of the last visited page?
Last visited (LIFO= Stack)
Answer = Stack
The following code is boxed into object o.
double d = 34.5;
object o = d;
You are asked to cast “object o” into “int”.
The object needs to be cast to double
Because it is a decimal value need to cast to float
Finally cast to int
Answer = int i = (int)(float)(double)o;
You are developing a game that allows players to collect from 0 through 1000 coins. You are creating a method that will be used in the game. The method includes the following code. (Line numbers are included for reference only)
01 public string FormatCoins(string name, int coins)
02 {
03
04 }
The method must meet he following requirements:
- Return a string that includes the player name and the number of coins
- Display the number of coins without leading zeros if the number is 1 or greater
- Display the number of coins as a single 0 if the number is zero
You need to ensure that the method meets the requirements. Which code segment should you insert at line 03
Format specifier D formats integer digits with optional negative sign.
Answer = string.Format($”Player {name}, collected {coins:D3} coins”);
How do you encapsulate an array of integers into an indexer?
private int[] array;
public int this[int index] { get {return array[index];} set { array[index] = value;} }
Is the following method “Display” considered to be overloaded?
class Person { public void Display() { }
public int Display()
{
}
}
No
Overloading refers to different parameter types. The display method has different return types.
Suppose you’re creating a class named Player. The class exposes a string property named HitSpeed. Here is the code snippet of player class.
01 class Player 02 { 03 public int HitSpeed 04 { 05 get; 06 set; 07 } 08 }
The HitSpeed property must meet the following requirements:
- The value must be accessed by code within the Player class
- The value must be accessed to derived classes of Player
- The value must be modified only by code within the Player class.
You need to ensure that the implementation of the EmployeeType property meets the requirements. Which code segment you should replace at line 05, and 06?
protected get;
private set;
Suppose you are developing an application. The application has two classes named Player and Person.
The Player class must meet the following requirements
- It must inherit from the Person class
- It must not be inheritable by other classes in the application.
Which code segment should you use?
sealed class Player : Person {
}
Suppose you are developing an application that includes the following code segment.
interface ICricket { void Play(); }
interface IFootball
{
}
You need to implement both Play() methods in a derived class named Player that uses the Play() method of each interface.
class Player : ICricket, IFootball { // Both ICricket and IFootball have play methods // Must be declared explicitly void ICricket.Play() { } void IFootball.Play() { } }
Player player = new Player();
( (ICricket)player ).Play();
( (IFootball)player).Play();
Which type cannot be instantiated? A enum type B static type C class type D System.Object type
B. Static type
Which operator is used to get instance data inside type definition?
this
What is the code segment for defining implicit type conversion for a Person class?
class Person { public string name; public int age;
public static implicit operator Person(string n)
{
Person person = new Person{age=0, name=n};
return person;
}
Which operator is used to compare types?
A) as
B) is
C) this
D) ?
B) is
Suppose you are developing an application that saves age values in integers
int age = 22;
You are asked to provide the right code snippet for defining the extension method for age.
static class Extension { public static void ExtensionMethod(this int i) {
}
}
Which jump statement will you use to start the next iteration while skipping the current iteration of loop?
Continue
You need to use null-coalescing operator to make sue “name” variable must have a value not null.
What is the right way to use null-coalescing operator in C#?
string name = n??”No Name”;
You are developing an application that saves user’s information. The application includes the following code segment (line numbers included for reference).
01 public bool IsNull(string name)
02 {
03 return true;
04 }
You need to evaluate whether a name is null
What code segment should be inserted at line 03.
I would do this….
return string.IsNullOrWhiteSpace(name) ? false: true;
or
return name==null?false: true;
Suppose you are implementing a method name “Show” that will be able to take an unlimited number of int arguments. How are you going to define its method signature.
void Show(params int[] arg)
Which of the following methods help us to convert string type data into integers?
Select any two
A) Convert.toInt32();
B) Convert.Int32();
C) int.parse();
D) parse.int();
A) Convert.toInt32()
C) int.parse()
What collections stores values in Key, Value pairs?
Dictionary
SortedList
HashTable
To control how objects are compared, what interface is implemented
IComparable
Last In, First Out data structures are represented as?
Stack
First In, First Out structures are represented as?
Queue
When are generic collection classes appropriate?
When all objects are of the same type
What namespace is inherited by the following data structures?
Dictionary List Queue Stack SortedList
System.Collections.Generic
What namespace is inherited by the following data structures?
ArrayList HashTable Queue Stack SortedList
System.Collections
Arrays inherit from what namespace?
System.Array
What object used with a DataSet is used to add, update or delete records from a database?
DataAdapter
How is a dataset populated with data?
using the DataAdapter
What is a DataSet
A disconnected resultset that contains one or more data tables
What method returns the data represented as XML
ExecuteXMLReader
What method is used to return a single value from a database such as when a query returns a Sum or Count
ExecuteScalar
What object is a read-only, forward-only cursor connected to the database?
DBDataReader
What method is used to execute non-result returning queries such as Insert, Update or Delete
ExecuteNonQuery
What object is used to call a stored procedure or execute a dynamic SQL statement?
The Command object
What is ADO.Net?
A set of classes used to execute commands on a database
An ORM tool that masks the syntax for using ADO.Net to communicate with a database is referred to as?
Entity Framework
Classes are representative of what within Entity Framework Model
objects in the database
Within the Entity Framework Model, stored procedures are represented as what?
Methods
How are parameters passed by WCF Data Services to query a database?
By passing the parameters within the URL query string
What data formats are returned by WCF Data Services?
OData Adam
JSON
What protocol is used by WCF Data Services?
OData
What purpose does the await command serve?
Kicks off the method and returns processing to the calling method until the method completes
The async keyword must modify what in order to use the await keyword?
The method signature
In C# 5.0 and later, what keywords are used to perform asynchronous operations?
asynch & await
What classes are used to read and write string data
StringWriter
StringReader
Name three methods used by StreamReader to get the contents of a file.
Character by Character
Line by Line
Entire File at once
What is the default character encoding for StreamReader and StreamWriter
UTF-8
What classes are used for reading and writing characters by using an encoded value to convert the characters to and from bytes?
StreamReader
StreamWriter
What classes are used for reading or writing binary values?
BinaryReader
BinaryWriter
What object is used to represent the contents of a file in memory and can be used to write data or read data from a file.
Stream
What objects are used to determine properties of a file and also performs operations on a file
File and FileInfo
In LINQ, what is an outer sequence?
The sequence calling the Join method
A feature of LINQ that uses extension methods on types that implement the IEnumerable or IQueryable interface to query the data is a ..?
Method based query.
LINQ statements executed in a where clause for a query expression is called it’s..?
Predicate
LINQ statements that select a subset of properties from a type that creates a new anonymous type is referred to as ?
Projection
A feautre of LINQ that enables you to query any type that implements the IEnumerable or IQueryable interface is called?
Query expression
A set of features that extends query capabilities to C# is called?
Language Integrated Query
or
LINQ
In LINQ, what is an inner sequence?
When using a method based join, the sequence passed to the join as a parameter.
A variable that has its type determined by the expression on the right side of the initialization statement and using the keyword var is .. .?
Implicitly typed
What operator is the”goes to” or “such that” operator?
=>
Used primarily in lambda expressions
Execution of a LINQ query is deferred until the result is enumerated.
This is referred to as ?
Deferred execution
Define a composite key
Contains multple properties that are needed to complete a join.
A type created with read-only properties without having to write the code to declare the class is referred to as an….?
Anonymous type
What class is used in a LINQ to XML query to return the result of a query in XML?
XElement
What LINQ method allows you to return a distinct list of elements from a sequence?
Distinct
What LINQ method allows you to return a limited number of elements from a sequence.
Take
What LINQ method allows you to skip a specific number of elements in a sequence?
Skip
In LINQ, how are two sequences concatenated?
Concat
When using method based LINQ queries, how are out joins formed?
GroupJoin
In LINQ, what is the purpose of the SelectMany method?
To flatten two sequences into one result, similar to join.
Which LINQ query uses lambda expressions as parameters to methods?
Method based queries
What is the difference between method based queries and query expressions?
Syntax, no functional difference.
In LINQ, a group by clause returns what data type?
IGrouping
How is a LINQ composit key formed?
By specifying an anonymous type in the join clause
In LINQ, how are outer joins formed?
1) Include an INTO clause in your join
2) Call the Default ifEmpty to set properties when no match is found.
What keyword is used to join properties in LINQ?
Equals
Define projection
Creating a custom type in a select clause of a query expression using a limited number of properties from the original object.
What query expression clause is used to sort the results on one or more properties?
OrderBy
How are multiple where clauses implemented using LINQ?
By using the && operator
Define the predicate in LINQ
All code contained within the Where clause
How are joins evaluated in LINQ queries?
Joins are always equivalence based
How is the execution of a LINQ query forced?
By using any of the aggregate functions or populating a list or array using toList() or toArray()
When does execution of a LINQ query occur?
When the result is enumerated
Define a LINQ clause
A query expression containing Select, GroupBy, Where or joins
By convention, the results of a LINQ query are stored where?
To a variable of type var, allowing the result to be implicitly typed.
What object can be queried by LINQ?
Any object that implements IEnumerable or IQueryable
Define the correct order of keywords for a LINQ query expression.
from…
where …
select …
Define a statement that returns the count of all even numbers
var count = myNumbers.Where(i => i %2 == 0) .Count()
Define a statement that groups a sequence by the State property
var states = myStates.GroupBy(s => s.name);
Define a statement that creates an anonymous type
.Select( new {h.city, h.state})
What two keywords must you use in a join clause to create an outer join?
into
DefaultIfEmpty
Define a clause that joins two sequences on the stateId property
on e.stateId equals s.stateId
Define a join clause that uses a composite key
on new {City = e.City, State = e.State}
equals
new {City = h.City, State = h.State}
Define a LINQ clause that orders by state and then by city
Orderby h.state, h.city
Define a WHERE clause that returns all integers between 10 and 20
Where i >= 10 && i <= 20
Define the extension LINQ method used to find the first item in a sequence
First or Take
Define how to find the minimum value in a sequence
(from i in myArray
selecti).Min()
Given:
var result = from i in my Array
order by i
select i;
foreach(int i in result) { // Do something }
Where is the LINQ query executed?
When enumerating the foreach statement
Define a WHERE clause that selects all integers in a myList object that are even number given
from i in myList
Where i % 2 == 0;
Name two methods of performing customized serialization
Attributes (the preferred method)
Implement Iserializable
What class is used to perform binary serialization.
BinaryFormatter
XML serialization is performed by what class?
XMLSerializer
What class is used to perform JSON serialization
DataContractJsonSerializer
What is serialization?
The process of transforming an objects data to persisted storage or to transfer the object from one domain to another
A set of classes in the .NET framework that enables you to convert to a database, retrieve data, execute stored procedures, add, update, or delete records in a table called?
ADO.NET
What is the object relationship mapping tool that provides a graphical interface that generates code to perform operations against a db using ADO?
ADO.NET Entity Framework
The most basic type used to store a set of data is called?
Array
What is the role of the keyword async?
Indicates that the method, lambda expression, or anonymous method is asynchronous
What keyword suspends the execution of a method until the awaited task completes?
await
The process of converting a reference type to a value type is called?
unboxing
What is boxing?
The process of converting a value type to a reference type
What is a collection?
A generic term encompassing lists, dictionaries, queues, stacks, hash tables and other objects that contain sets of data.
The object in ADO.NET that allows you to open and execute commands against a database is called?
A connection object.
What is the IComparable interface?
Implements an interface that can be sorted when used in a collection or array.
A method that is used when referencing an element in an array or collection by using square brackets[] and it’s index is called?
indexer
What is JSON?
JavaScript Object Notation
A lightweight data-interchange format
A computer software term for tools that convert data between type systems using an object oriented programming language is called?
ORM
Object Relational Mapping
The XML representation of data returned from an OData query is called?
OData ATOM
What is OData?
Open Data Protocoal
A web protocol for querying and updating data over the intranet or internet
Creating a new copy of an object that copies all value types and copies object references for reference types is called a ?
shallow copy
The process of converting an object into a stream of bytes that can be stored or transmitted is called?
serialization
Define stream.
An abstract class that provides a generic view of a sequence of bytes.
What is a T4 template?
A file that contains text blocks and control statements that enable you to generate a code file.
What enables you to use OData to expose and consume data over the web or intranet?
WCF Data Services
WCF=(Windows Communication Foundation)
You are working with a large group of family objects. You need to remove all duplicates and then group them by last name.
Which collections should you use?
List to hold the original objects
Dictionary to remove duplicates and create key of last names.
You are using a queue and you want to add a new item.
Which method do you use?
Enqueue
You want to store a group of orders and make sure that a user can easily select an order by it’s order number.
Which collection do you use?
Dictionary
What must be implemented when creating custom collections?
Both IEnumerable and IEnumerable
What collection stores values in memory as a last-in-last-out structure?
Stack, Stack
What collection stores value in memory as a first-in-first-out structure?
Queue, Queue
What collection stores unique items and offer set operations?
HashSet
What is a dictionary?
A collection that stores and accesses items via key/value pairs.
What is the most used collection?
List, List
Define an Array
The most basic collection type which is constrained by a fixed size
When given the opportunity to use the generic or non-generic collection, which is generally preferred?
Always use generic where possible.
You want to serialize some data to XML, and you need to make sure that a certain property is NOT serialized.
Which attribute should you use?
XMLIgnore
You are serializing some sensitive data to a binary format.
What should you use?
BinaryFormatter to put the data in binary format.
ISerializable to protect sensitive data.
JSON text formatted files are created in .NET using what class?
DataContractJsonSerializer
You need to store a large amount of data and you want to do this in the most optimal way.
What serializer should you use?
BinaryFormatter
WCF serialization is performed using what class?
DataContractJsonSerializer
How is binary serialization performed in .NET?
Using the BinaryFormatter class
How is the XMLSerializer configured?
Through the use of attributes.
What class handles XML serializtion?
XMLSerializer
What is deserialization
Takes a series of bytes or a flat file and transforms it to an object
What is serialization?
The process of transforming an object to a flat file or series of bytes
Given query
var query = from p in myContext.Products where p.price < 50 select p; int numberOfItems = query.Count(); var products = query.ToList();
How can you improve performance?
Use paging to limit the number of items retrieved
And
Avoid hitting the database multiple times
You are trying to use a LINQ query but receiving a compile error that the Where method cannot be found.
What steps should you take?
- verify using System.Linq
2. Validate the datatype implements IEnumerable, IEnumerable
You have a list of data you want to filter the dates to the current year and then select the highest date.
Create the query.
DateTime result = dates.Where( d => d.Year ==
DateTime.Now.Year)
.OrderByDescending( d=>d)
.FirstOrDefault();
When are LINQ queries executed?
Not until they are first iterated, known as deferred execution.
What is the primary function of LINQ?
To provide a uniform way of writing queries against multiple data stores.
Which ADO.NET command objects’s property would you use when a query returns the sum of a column in a table?
ExecuteScalar
Which property of an ADO.NET DataAdapter is used to insert records in a database?
InsertCommand
Which method of a DataAdapter is used to populate a DataSet?
Fill
Which ADO.NET object is fully traversable cursor and is disconnected from the database?
DataTable
Which ADO.NET command object’s property would you use when a query returns the sum of a column in a table?
ExecuteScalar
Which ADO.NET object is a forward-only cursor and is connected to the database while the cursor is open?
DBDataReader
using ADO.NET Entity Framework how is a record updated in the database?
Category category = db.Categories.First( c =>
c.CategoryName = “alcohol”);
category. Description = “Happy Please”;
db. SaveCjhanges();
Using ADO.NET Entity Framework, how is a record added to the database?
using(NorthwindsEntitities db = new NorthwindEntities()) { Category category = new Category() { category = "Alcohol", description = "beverage" }
db.Categories.Add(category);
db.SaveChanges();
}
How are stored procedures represented in the ADO.NET Entity Framework?
A method is added to the model that is the same name as the stored procedure.
When using the ADO.NET Entity Framework you create a model that represents the object in the databases.
What class does the model inherit from?
DBContext
Which command object’s method would you use to execute a query that returns only one row and one column?
ExecuteScalar
Which command object’s method would you use to execute a query that does not return any results?
ExecuteNonQuery
Which properties of an ADO.NET command object must you set to execute a stored procedure?
CommandType
CommandText
Parameters
Which ADO.NET object is used to connect to a database?
Connection
Which collection would you use if you need to quickly find an element by its key rather than it’s index?
Dictionary
or
SortedList
Which collection would you use if you need to process the items in the collection on a last-in, first-out order?
Stack, Stack
Which collection would you use if you need to process the items in the collection on first-in, first-out order?
Queue, Queue
If you create a custom class that is going to be used as elements in a List object and you want to use the Sort method of the List object to sort the elements in the array, what steps must you take?
- Inherit from IComparable
2. Implement CompareTo()
Which type should you use to store objects of different types but do no know how many elements you need at the time of creation?
ArrayList
Which object does the variable mySet inherit from?
int[] mySet = new int[5];
System.Array
Custom collections must inherit from which base class?
CollectionBase
What is SSL?
Secure Socket Layer is a cryptographic protocol used for secure communication over the internet.
Define secured hash algorithm
SHA is a family of cryptographic algorithms used to calculate hashes published by NIST
What is the infrastructure required to handle digital certificates?
Public Key Infrastructure (PKI)
A family of cryptographic algorithms used to provide data integrity and authenticity is called?
Message Authentication Code (MAC)
What is the Just In Time (JIT) compiler?
A component of the .NET that transforms the IL into binary code that can be run on the target platform.
The result of compiling a .NET application from source code is called the?
Intermediate Language (IL)
A data array used by the encryption algorithm to encrypt the first data block is referred to as the?
Initialization Vector (IV)
Describe hashing.
Used to map data structures of variable length to fixed size data structures.
A data structure that holds items that share the same hash value is called?
Hash Bucket
What is the Global Assembly Cache?
The GAC is a machine-wide code cache
The process of decoding previously encrypted data so that it can be used by your application is?
Decryption
The process of encoding data so that it cannot be read by an unauthorized person is called?
Encryption
The practice and study of techniques for secure communication is called?
Cryptography
A list of digital certificates that have been revoked for various reasons is referred to as?
Certificate Revocation List (CRL)
Define the CLR
The Common Language Runtime is the component of the .NET Framework responsible for running .NET applications and managing the running environment.
Define Certificate Stores
A special storage location on your computer, used to store encryption certificates
What entity issues digital certificates?
Certificate Authority (CA)
Define asymmetric encryption
A criptographic algorithm that uses two complimentary keys. One for encryption and one for decryption.
What is an assembly?
An assembly is the unit of reuse, deployment, versioning and security.
You need to process a large number of XML files ina scheduled service to extract some data.
Which class should you use?
Because data is only being extracted, use XmlReader
You are planning to build an application that will use an object-oriented design. It will be used by multiple users at a time.
Which technology should you use?
An ORM such as Entity Framework
You want to update a specific row in the database.
What commands are required?
- SqlConnection to establish connection to database
2. SqlCommand to execute the query
Name the four classes used to manipulate XML.
XmlReader
XmlWriter
XPathNavigator
XmlDocument
Why should you use parameterized queries when performing CRUD operations?
To avoid Sql injection
Under ADO.NET, how are connections made to the database?
Using the DBConnection object
What is ADO.NET?
A provider model that enables you to connect to different types of databases.
You are writing an application that will be deployed to western countries. It outputs user activity to a text file.
Which encoding should you use?
UTF-8
You have built a complex calculation algorithm. It takes quite some time to complete and you want to make sure that your application remains responsive, what do you do?
Task.Run()
The process will run on a background thread
You are creating a new file to store some log data. Each time a new log entry is necessary, you write a string to the file.
Which method should you use?
File.AppendText
What namespace supports WebRequest and WebResponse?
System.Net
What classes are used for performing network requests?
WebRequest
WebResponse
What class implementation is used for dealing with files, network operations and other types of IO
Stream
Define streams
An abstract method for working with a series of bytes
What methods are available to create and parse file paths?
static Path class
What methods are provided to work with files?
File
FileInfo
How are folders manipulated programmatically?
Directory
DirectoryInfo
How are drives manipulated programmatically?
Drive
DriveInfo
Write code to decrypt an array called encryptedData that was encrypted by the current user and without using entropy
ProtectedData.Unprotect( encryptedData,
null,
DataProtectionScope.CurrentUser);
What is a strong name assembly?
A signed assembly
How can you deploy a private assembly?
By copying the file to the bin folder
or
Adding a reference to the assembly via Visual Studio
How can you deploy a strong named assembly?
Run gacutil.exe or copy file to bin folder or create an installer
Describe the components of a strong named assembly
Name Version Public Key Token Culture Processing Architecture
Write a code snippet to encrypt an array called userData that can be decrypted by anyone logged in on the current machine without using any entropy.
ProtectedData.Protect(userData,
null,
DataProtectionScope.LocalMachine);
Write a code snippet to calculate the secure hash of a byte array called userData using the SHA algorithm
sha.ComputeHash(userData);
You are a developer at company xyz. You have been asked to implement a method to handle password encryption without offering the possibility to restore the password
What algorithm fits the requirement?
Hashing algorithm
You are a developer at company xyz. You have been asked to implement a method to safely send data to another machine.
What kind of algorithm best fits the requirement?
Asymmetric algorithm
You are a developer at company xyz. You have been asked to implement a method to safely save and restore data on the local machine.
What kind of algorithm best fits the requirements?
Symmetric algorithm.
When is a MAC algorithm recommended?
To ensure both authenticity and integrity is required
When is the hashing algorithm recommended?
When data integrity is the only requirement
When is asymmetric encryption recommended?
If you do not have a way to send data securely
When is symmetric encryption the best option?
IF you need to encrypt data locally or you have a secure way to distribute the encryption key.
How is the encryptor/decryptor used?
Directly, using TransformFinalBlock or sending to CryptoStream
How is symmetric encryption instantiated?
By calling
CreateEncryptor
CreateDecryptor
What is required to perform symmetric encryption?
An initialization vector (IV) used to encryp the first block of data.
Define symmetric encryption
Encryption based on a shared secret
How many keys are used in asymmetric encryption?
Two
- Private key
- Public key
Define asymmetric encryption
Based on a pair of complimentary keys. Data encrypted by one key can be decrypted by the other.
Write a regular expression that matches license plate values that must include
three uppercase letters,
followed by a space and three digits,
or three digits followed by a space and three uppercase letters.
(^d{3} [A-Z] {3}$) | (^[A-Z]{3} \d{3}$)
Write a regular expression that matches a username that must include between 6 and 16 letters, numbers and underscores
^[a-zA-Z0-9_]{6,16}$
Write a regular expression matching the social security number format ###-##-#### where # is any digit.
^\d{3}-\d{2}-\d{4}$
What method returns true if a regular expression matches a string?
Regex.IsMatch
What is the best use of performance counters?
To determine how often a particular operation is occurring on the system as a whole.
True or False
Whan an assertion fails in debug builds, the Debug.Assert method allows you halt, debug the program or continue running?
True
True or False
The program must continue running even if a Debug.Assert method stops the program
True
True or False
The Debug.Assert method is ignored in release builds
True
What builds define the TRACE symbol?
Debug and Release
What builds define the Debug symbol
Debug
How can you prevent Visual Studio from creating a .pdb file?
Setting the value of PDB file type to “None”
What file is required to debug a compiled executable?
.pdb file
What statements are used to trace or log a program’s execution?
DEBUG
and
TRACE
The process of making the program record key events in a log file is referred to as?
logging
The process of instrumenting a program to track what is doing is referred to as ?
Tracing
What method would you use to investigate bottlenecks in a program?
Use an automatic profiler
What statement can be used to validate data as it moves through a program?
Debug.Assert
How are preprocessor symbols disabled?
UNDEF
What processor directives define preprocessor symbols?
DEFINE
How can you determine what code is included in a program?
By using directives #if #elif #else #endif
What is the purpose of the #line directive?
To change the line number or name of file reported as errors
How are custom warnings and/or errors added to the error list?
by using
#warning
or
#error
What is the syntax to create collapsible code regions?
#region .. #endregion
What is the syntax to disable a warning?
pragma warning disable
What is the syntax to restore a warning?
pragma warning restore
Where is the predefined constant TRACE defined?
In the debug and release builds
Where is the predefined constant DEBUG defined?
In the debug builds
Calls to DEBUG and TRACE are ignored if?
Both DEBUG and TRACE are not defined
Useful DEBUG and TRACE methods include?
Assert Fail Flush Indent Unindent Write WriteIf WriteLine WriteLineIf
When adding standard listeners to Debug and Trace objects, where are messages written to?
- Output window
- Event logs
- Text files
What file is used to debug a compiled executable?
.pdb
What directives are used to implement tracing?
DEBUG
and
TRACE
Instrumenting a program to trace it’s progress is known as?
Tracing
Name the methods to support logging
- Writing to a text file
- Using DEBUG and TRACE with a listener to write to a
text file - Writing to an event log
The recording of key events is known as?
logging
What methods are used to support profiling?
- Using a profiler
- Instrumenting code by hand
- Performance counters
Gathering information about a program to study characteristics such as speed and memory usage is referred to as?
Profiling
A test on data ot see if the data makes sense is referred to as a ?
sanity check
What is tracing?
The process of instrumenting a program so that you can track what it is doing
What is a regular expression?
An expression in regular expression language that defines a pattern to match.
What is profiling?
The process of instrumenting a program to study it’s speed, memory, disk usage, or other performance characteristics.
An automated tool that gathers performance data for a program by it’s code or by sampling is referred to as?
a profiler.
What is a performance counter?
A system-wide counter used to track some type of activity on the computer.
A regular expression used for matching parts of a string is called?
a pattern
What is logging?
The process of instrumenting a program so it records key events?
Adding features to a program to study the program itself is called?
instrumenting
Options set in a regular expression using the syntax
(?imasx) are referred to as ?
inline options
A sequence of characters that have special meaning in a regular expression is referred to as a ?
escape sequence
Define data validation
Program code that verifies that a data value makes sense
A predefined symbol created by Visual Studio that you can use with #if, #elif, #else and #endif directives to determine what code is in the program?
Conditional Compilation Constant
A regular expression construction that represents a set of characters to match is?
character class
A piece of code that makes a particular claim about data and throws an exception if that claim is false is called?
An assertion
What method is used to create assertions?
System.Diagnostics.Debug.Assert
Given the following:
MyClass myClass = new MyClass();
MethodInfo myMethod =
typeof(MyClass).GetMethod(“Multiply”);
using reflection, execute the method and pass in two parameters.
myMethod.Invoke(myClass,
new object[]{4,5});
Which method of the MethodInfo class can be used to execute the method using reflection?
Invoke
Assume myClass is an instance of a class.
Create a statement that returns a private instance field called “myPrivateInstance” using reflection.
MyClass.GetType().GetField(“myPrivateField”,
BindingFlags.NonPublic |
BindingFlags.Instance);
Which property of the Type class can you use to determine the number of dimensions in an array?
GetArrayRank
Which class in the System.Reflection namespace is used to represent a field defined in a class?
FieldInfo
Using reflection, how an you determine if a class is public or private?
Create an instance of the Type class using typeof() and then examine the IsPublic propery of the Type variable
Which class would you create if you wanted to determine all properties contained in a class using reflection?
Type
Create an instance of a DataTable using reflection
myAssembly.CreateInstance(“System.Data.DataTable”);
Which method should you call if you want .NET Framework to look in the load-from context?
LoadFrom
Which method should you call if you want the .NET Framework to look in the load-context to load an Assembly?
Load
Define the syntax to load an assembly
- Assembly.Load(“System.Data”,
Version=4.0.0.0,
Culture = neutral,
PublicKeyToken=b77a5c561934e089); - Assembly.LoadFrom(@”c:\myProject\Project1.dll”);
- Assembly.LoadFile(@”c:\myProject\Project1.dll”);
- Assembly.ReflectionOnlyLoad(“System.Data”,
Version=4.0.0.0,
Culture = Neutral,
PublicKeyToken=b77a5c561934e089);
Which method of the Assembly class returns an instance of the current assembly?
GetExecutingAssembly
Which property of the Assembly class returns the name of the assembly?
FullName
Which method of the Assembly class allows you to get all the public types defined in the assembly?
GetExportedTypes
Which class in the System.Reflection namespace would you use if you want to determine all the classes contained in the .dll file?
Assembly
You are asked to create a custom attribute that has a single property, called version, that allows the caller to determine the version of the method.
Which code creates the attribute?
class MyCustomAttribute:System.Attribute { public string Version{get; set;} }
You are a developer for a finance department and are building a method that uses reflection to get a reference to the type of object passed as a parameter.
Which syntax is used to determine object type?
Type myType = myParameter.GetType();
You are consulting for a company called Contoso and are taking over an application that was built by a third party.
How can you figure out which .dll files are being referenced?
- Create an instance of the assembly class
- Load the assembly
- Call the GetReferencedAssemblies method
What code creates a lambda expression returning the squares of an integer?
x => x * x;
You are given an assignment to create a code generator to automate the task of creating repetitive code.
Which namespace contains the types needed to generate code?
System.CodeDom
The process that permits parameter types that are less derived than the delegate type?
Contravariance
The process that enables you to have a method with a more derived return type than the delegate return type is ?
Covariance
The => symbol in a lambda expression is referred to as?
goes to
or
such that
What is a delegate?
A type that references a method
Shorthand syntax for anonymous functions are referred to as?
lambda expressions
What class generates the class file in either C#, VB or JScript?
System.CodeDom.CodeDomProvider
In the codeDom, what class is the top level class?
System.CodeDom.CodeCompileUnit
What is the CodeDom?
Code Document Object Model
As set of classes that enables you to create code generators
Custom attributes inherit from what class?
System.Attribute
How is an attribute declared?
By decorating with square brackets []
What enables you to create metadata for a class, property or method?
Attributes
What method returns a PropertyInfo object and enables you to set or get a property’s value?
Type.GetProperty
What does System.Type represent?
A class, interface, array, value type, enumeration, parameter, generic type definition and open or closed generic types.
What method creates an instance of a type?
Assembly.CreateInstance
What method loads the assembly but does not enable execution?
Assembly.ReflectionOnlyLoad
What method loads an assembly into memory and enables you to execute code?
Assembly.Load
What class is used to examine the types within an .exe or .dll file?
System.Reflection.Assembly
Name the two ways to get a reference to the Type object
typeof()
and
.GetType()
What is a type?
A class, interface, array, value type, enumeration, parameter, generic type definition, open or closed generic type.
The class, porperty or method that contains metadata defined by an attribute is called the…?
Target
A lamdba expression containing more than one statement in the body of the expression is referred to as a …?
statement lambda
What is reflection?
Provides lasses that can be used to read metadata or dynamically invoke behavior from a type?
Describe probing
The process of looking in the GAC, the host assembly store, the folder of the executing assembly, or the private bin folder of the executing assembly to find an assembly
A file, typically a .dll or .exe that composes an assembly is referred to as a ..?
module
When loading an assembly using reflection, what context contains the assemblies located inthe path passed into LoadFrom method.
load-from context
When loading an assembly during reflection, what context contains the assemblies found by probing
load context
Define a lambda expression
Shorthand syntax for an anonymous method that can be associated with a delegate or expression tree.
A variable in a class or structure is referred to as a ..?
field
Code in a tree-like structure where each node is an expression is referred to as a…?
Expression tree
What is an expression lambda?
An expression that contains one statement for the body.
What type is a reference to a method?
delegate
Define covariance
Enables you to have a method with a more derived return type than the delegates return type
Define contravariance
Permits parameter types that are less derived than the delegates parameter types.
When loading an assembly using reflection, where does reflection search for the assembly?
in the context
Define the CodeDOM
Code Document Object Model
Enables the developer to generate code in multiple languages at run time based on single code set.
What enables you to associate metadata with assemblies, types, methods, properties…?
attributes
A compiled piee of code in a .dll or .exe is referred to as a ?
assembly
What method enables you to associate a block of code with a delegate without a method signature?
anonymous methods
If during Garbage Collection a program has no path of references that access the object, the object is ?
unreachable
Resources that are not under the control of the CLR are known as?
unmanaged resources
A base or parent class is also known as?
the superclass
The process of deriving a subclass from a base class through inheritance is referred to as ?
subclassing
What is a subclass?
A derived class
Classes that have the same parent class are referred to?
sibling class
A copy of an object where reference fields refer to the same objects as the original is a ..?
shallow clone
If the program has a path of references that allow access to the object than it is?
reachable
A base, or superclass is known as the?
parent class
Because you cannot direct when the GC will call an objects Finalize method, the process is referred to as ?
Nondeterministic finalization
Allowing a child class to have more than one parent class?
multiple inheritance (not allowed in C#)
Resources that are under the control of the CLR are?
managed resoources
Using an interface to require a class to provide certain features much as inheritance does is referred to as ?
Interface inheritance
What does it mean to inherit?
A derived class inherits the properties, methods, events and other code from the base class.
The process that executes periodically to reclaim memory that is no longer accessible to the program
Garbage Collection (GC)
What is Garbage Collection?
The process of running the Garbage Collector to reclaim memory no longer available to the program
A queue through with object with finalizers must pass before being destroyed is called the ?
finalization queue