1. To create a custom exception, which class is required to be inherited?
A) SystemException
B) System.Exception
C) System.Attribute
D) Enumerable
Ans. B
2. How do you throw an exception so the stack trace preserves the information?
A) throw;
B) throw new Exception();
C) throw ex;
D) return new Exception();
Ans. A
3. You need to reference a method which returns a Boolean value and accepts two int parameters. Which of the following delegates would you use?
A) Func<int, int, bool> func;
B) Action<int, int, bool> act;
C) Func<bool, int, int> func;
D) Action<bool, int, int> act;
Ans. A
4. Which of the following keywords is useful for ignoring the remaining code execution and quickly jumping to the next iteration of the loop?
A) break;
B) yield;
C) jump;
D) continue;
Ans. D
5. Which of the following loops is faster?
A) for
B) do
C) Parallel.for
D) foreach
Ans. C
6. await keyword can only be written with a method whose method signature has:
A) static keyword
B) async keyword
C) lock keyword
D) sealed keyword
Ans. B
7. Which keyword is used to prevent a class from inheriting?
A) sealed
B) lock
C) const
D) static
Ans. A
8. When handling an exception, which block is useful to release resources?
A) try
B) catch
C) finally
D) lock
Ans. A
9. Which of following methods is accurate for holding the execution of a running task for a specific time?
A) Thread.Sleep()
B) Task.Delay()
C) Task.Wait()
D) Task.WaitAll()
Ans. B
10. Which of the following methods is useful for holding the execution of a main thread until all background tasks are executing?
A) Thread.Sleep()
B) Task.WaitAll()
C) Task.Wait()
D) Thread.Join()
Ans. B
11. How would you chain the execution of a task so that every next task runs when the previous task finishes its execution? Which method you would use?
A) task.ContinueWith()
B) Task.Wait()
C) Task.Run()
D) Thread.Join()
Ans. A
12. In a switch statement, which keyword would you use to write a code when no case value satisfies?
A) else
B) default
C) return
D) yield
Ans. B
13. Foreach loop can only run on:
A) anything
B) collection
C) const values
D) static values
Ans. B
14. Which keyword is useful for returning a single value from a method to the calling code?
A) yield
B) return
C) break
D) continue
Ans. B
15. Which of the following collections is a thread-safe?
A) Dictionary<K,V>
B) Stack<T>
C) ConcurrentDictionary<K,V>
D) Queue
Ans. C
16. When running a long-running asynchronous operation that returns a value, which keyword is used to wait and get the result?
A) await
B) yield
C) return
D) async
Ans. A
17. Which of the following is the right syntax for using an asynchronous lambda expression?
A) Task task = async () => { ... };
B) Task<Task> task = async () => { ... };
C) Func<Task> task = async () => { ... };
D) Action<Task> task = async (t) => { ... };
Ans. C
18. Which property or method of task can be used as an alternative of the await keyword?
A) Result
B) Wait()
C) WaitAll()
D) Delay()
Ans. A
19. Suppose you’re creating an application that needs a delegate that can hold a reference of a method that can return bool and accept an integer parameter. How would you define that delegate?
A) delegate bool myDelegate(int i, int j);
B) delegate bool (int i, int j);
C) delegate myDelegate(int i, int j);
D) delegate bool myDelegate(int i);
Ans. A
No comments:
Post a Comment
Please keep your comments relevant.
Comments with external links and adult words will be filtered.