[QCM] – Gestion du flux de programme.

publicitemcppreparation

 

Nombre de questions disponibles : 20

QUESTION NO: 1 

You have received instructions to create a custom collection. Objects in the collection must be processed via a foreach loop.

Which of the following is TRUE with regards to the required code?

  1. The code should implement the ICollection interface.
  2. The code should implement the IComparer interface.
  3. The code should implement the IEnumerable interface.
  4. The code should implement the IEnumerator interface.

Answer: 3

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/ttw7t8t6.aspx

QUESTION NO: 2 

You are running a training exercise for junior developers. You are currently discussing the ExtensionMethods class.

Which of the following is TRUE with regards to the ExtensionMethods class? (Choose all that apply.)

  1. It allows you to add methods to current types by modifying the original type.
  2. Methods of the class are a special kind of static method that is called as if they were instance methods on the extended type.
  3. It allows you to add methods to current types by recompiling.
  4. Methods of the class are a special kind of instance method that is called as if they were static methods on the extended type.
  5. It allows you to add methods to current types without creating a new derived type.

Answer: 2,5

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/bb383977.aspx

QUESTION NO: 3 

You are running a training exercise for junior developers. You are currently discussing iterators.

Which of the following is TRUE with regards to iterators?

  1. It represents code in a tree-like data structure, where each node is an expression.
  2. It can be used to step through collections such as lists and arrays.
  3. It provides a more flexible way to work with groups of objects.
  4. It is the process of converting an object into a stream of bytes in order to store the object

Answer: 2

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/dscyy5s0.aspx

QUESTION NO: 4

You are in the process of creating a new application. You have written code that includes the Console.Readline method.

Which of the following is TRUE with regards to the Console.Readline method?

  1. It reads the next line of characters from the standard input stream.
  2. It reads the next character from the standard input stream.
  3. It reads the next line of characters from the customized input stream.
  4. It reads the next character from the customized input stream.

Answer: 1

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/system.console.readline(v=vs.110).aspx

QUESTION NO: 5 

You are running a training exercise for junior developers. You are discussing the use of the Task methods. You are currently dealing with the ContinueWith method.

Which of the following is TRUE with regards to the ContinueWith method?

  1. It creates a Task that will complete after a time delay.
  2. It creates a continuation that executes asynchronously when the target Task completes.
  3. It releases all resources used by the current instance of the Task class.
  4. It runs the Task synchronously on the current TaskScheduler.
  5. It creates a continuation that executes synchronously when the target Task completes.

Answer: 2

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/dd321405(v=vs.110).aspx

QUESTION NO: 6 

You are in the process of creating a new application. You have written code that includes the Throw statement.

Which of the following is TRUE with regards to the Throw statement?

  1. It contains a try block followed by one or more catch clauses
  2. It is beneficial for cleaning up any resources that are allocated in the try block
  3. It is used to signal the occurrence of an atypical situation during the programs execution.
  4. It is used to obtain and use resources in a try block.

Answer: 3

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/1ah5wsex.aspx

QUESTION NO: 7 

You are running a training exercise for junior developers. You are currently discussing the reason for adding the lock Object private object to a class.

Which of the following best describes this reason?

  1. To allow multiple threads access to the object.
  2. To allow only a single thread access to the object at a time.
  3. To make sure that when a single thread attempts to access the object, a deadlock occurs.
  4. To prevent any thread from accessing the object.

Answer: 2

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/c5kehkcz.aspx

QUESTION NO: 8 

You are in the process of creating a new application. You have written code that includes a statement that consists of a try block followed by one or more catch clauses.

Which of the following is the statement being used?

  1. The throw statement.
  2. The try-catch-finally statement.
  3. The try-finally statement.
  4. The try-catch statement.

Answer: 4

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/0yd65esw.aspx

QUESTION NO: 9 

You have been tasked with creating a new application. The code includes a conditional directive that starts with a #if directive.

You want to make sure that the conditional is suitably terminated.

Which of the following actions should you take?

  1. You should consider making use of the #undef directive.
  2. You should consider making use of the #endif directive.
  3. You should consider making use of the #else directive.
  4. You should consider making use of the #elif directive.

Answer: 2

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/5011f09h.aspx

QUESTION NO: 10

You have been tasked with creating an application. You are currently writing code that uses a lambda expression to create an event handler.

Which of the following is TRUE with regards to lambda expressions? (Choose all that apply.)

  1. It is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.
  2. It is a sequence of one or more operands and zero or more operators that can be evaluated to a single value, object, method, or namespace.
  3. It is a program element that is applied to one or more operands in an expression or statement.
  4. It is an expression of actions taken by the program.

Answer: 1

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/bb397687.aspx

QUESTION NO: 11 

You are running a training exercise for junior developers. You are discussing the use of a Task method that creates an awaitable task that asynchronously defers back to the current context when awaited.

Which of the following is the method being discussed?

  1. The Yield method.
  2. The ConfigureAwait method.
  3. The WaitAll method.
  4. The WhenAll method.

Answer: 1

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/system.threading.tasks.task(v=vs.110).aspx

QUESTION NO: 12

You have a lot of items that need to be processed. For each item, you need to perform a complex calculation. Which technique should you use?

  1. You create a Task for each item and then wait until all tasks are finished.
  2. You use Parallel.For to process all items concurrently.
  3. You use async/await to process all items concurrently.
  4. You add all items to a BlockingCollection and process them on a thread created by the Thread class.

Answer: 2

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/system.threading.tasks.parallel.for(v=vs.110).aspx

QUESTION NO: 13

You are creating a complex query that doesn’t require any particular order and you want to run it in parallel. Which method should you use?

  1. AsParallel.
  2. AsSequential.
  3. AsOrdered.
  4. WithDegreeOfParallelism.

Answer: 1

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/system.linq.parallelenumerable.asparallel(v=vs.110).aspx

QUESTION NO: 14

You are working on an ASP.NET application that retrieves some data from another web server and then writes the response to the database. Should you use async/await?

  1. No, both operations depend on external factors. You need to wait before they are finished.
  2. No, in a server application you don’t have to use async/await. It’s only for responsiveness on the client.
  3. Yes, this will free your thread to serve other requests while waiting for the I/O to complete.
  4. Yes, this put your thread to sleep while waiting for I/O so that it doesn’t use any CPU.

Answer: 3

Plus d’informations :  https://msdn.microsoft.com/fr-fr/library/hh191443.aspx

QUESTION NO: 15

You want to synchronize access by using a lock statement. On which member do you lock?

  1. this.
  2. string _lock = “mylock”.
  3. int _lock = 42;
  4. object _lock = new object();

Answer: 4

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/c5kehkcz.aspx

QUESTION NO: 16

You need to implement cancellation for a long running task. Which object do you pass to the task?

  1. CancellationTokenSource.
  2. CancellationToken.
  3. Boolean isCancelled variable.
  4. Volatile.

Answer: 2

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/jj155759.aspx

QUESTION NO: 17

You are implementing a state machine in a multithreaded class. You need to check what the current state is and change it to the new one on each step. Which method do you use?

  1. Volatile.Write(ref currentState).
  2. Interlocked.CompareExchange(ref currentState, ref newState, expectedState).
  3. Interlocked.Exchange(ref currentState, newState).
  4. Interlocked.Decrement(ref newState).

Answer: 2

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/system.threading.interlocked.compareexchange(v=vs.110).aspx

QUESTION NO: 18

You need to iterate over a collection in which you know the number of items. You need to remove certain items from the collection. Which statement do you use?

  1. switch.
  2. foreach.
  3. for.
  4. goto.

Answer: 3

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/ch45axte.aspx

QUESTION NO: 19

You have a lot of checks in your application for null values. If a value is not null, you want to call a method on it. You want to simplify your code. Which technique do you use?

  1. for.
  2. Conditional operator.
  3. Null-coalescing operator.
  4. The short-circuiting behavior of the and operator.

Answer: 4

Plus d’informations :

 QUESTION NO: 20

You are processing some data from over the network. You use a HasNext and Read method to retrieve the data. You need to run some code on each item. What do you use?

  1. for.
  2. foreach.
  3. while.
  4. do-while.

Answer: 3

Plus d’informations : https://msdn.microsoft.com/fr-fr/library/2aeyhxcd.aspx