C# .Net Quizz Dive into our tech quiz zone and put your technical skills to the test! Our quizzes cover a wide array of technical topics, perfect for sharpening your knowledge and challenging your understanding. Compete with others, see your rankings, and boost your technical proficiency. Start quizzing today! 1 / 29 1. What does the ConfigureAwait(false) method do in an asynchronous call? It throws an exception if the task fails It ensures the continuation runs on the same thread It ensures the continuation does not run on the captured context It cancels the asynchronous task 2 / 29 2. Which of the following is not a valid access modifier in C#? private internal external protected 3 / 29 3. Which design pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes? Prototype Abstract Factory Decorator Builder 4 / 29 4. What is the purpose of the AsParallel method in PLINQ? To convert a query into parallel execution To sort a collection in parallel To convert a query into sequential execution To filter elements based on a condition 5 / 29 5. What will be the output of the following code? public class Test { public static void Main(string[] args) { int x = 5; object y = x; y = 10; Console.WriteLine(x); } } 10 5 Runtime error Compilation error 6 / 29 6. Which keyword is used in LINQ to create a new anonymous type? select from var new 7 / 29 7. Which of the following is a correct way to handle exceptions in asynchronous methods? Using Task.Wait with try-catch Using await without try-catch Using Task.Run with try-catch Using try-catch within the async method 8 / 29 8. Which of the following is a use case of reflection in C#? Accessing metadata of assemblies Serializing objects Compiling code dynamically Creating user interfaces 9 / 29 9. What will be the output of the following code? Type type = typeof(string); MethodInfo method = type.GetMethod("Substring", new[] { typeof(int), typeof(int) }); var result = method.Invoke("Hello, World!", new object[] { 7, 5 }); Console.WriteLine(result); llo, , Wor Hello World 10 / 29 10. What is the primary purpose of reflection in C#? To compile code dynamically To handle exceptions To inspect and interact with types at runtime To execute code at runtime 11 / 29 11. What is the purpose of the Monitor class in C#? To create threads To manage thread priorities To abort threads To implement critical sections 12 / 29 12. What is the purpose of the lock statement in C#? To ensure that a block of code runs only once To provide a mechanism for mutual exclusion To prevent a thread from being aborted To create a new thread 13 / 29 13. Which of the following design patterns is used to convert the interface of a class into another interface that clients expect? Adapter Bridge Composite Facade 14 / 29 14. What keyword is used to allow a derived class to extend or modify the behavior defined in the base class method? new abstract virtual override 15 / 29 15. Which feature of C# allows the definition of methods that can be overridden in derived classes? Inheritance Polymorphism Abstraction Encapsulation 16 / 29 16. What does the Type.GetType method do? It retrieves a Type object for a specified type name It returns the type of an object It gets the base type of a class It creates a new instance of a type 17 / 29 17. Which class in the .NET Framework provides a mechanism to schedule and execute background tasks? Task Timer Thread ThreadPool 18 / 29 18. What will be the output of the following code? int[] numbers = { 1, 2, 3, 4, 5 }; var query = from num in numbers where num % 2 == 0 select num; numbers[1] = 0; Console.WriteLine(query.First()); 4 Compilation error 2 0 19 / 29 19. Which of the following is a deferred execution method in LINQ? Where() ToList() First() Count() 20 / 29 20. What is the primary purpose of the async keyword in C#? To declare a thread To mark a method as asynchronous To synchronize threads To define a delegate 21 / 29 21. What is the primary benefit of the Dependency Injection pattern? Reduced code complexity Improved code readability Enhanced code reusability Improved testability and flexibility 22 / 29 22. What does the DbContext class represent in Entity Framework? The database schema The database migrations The session with the database and allows querying and saving data The connection string to the database 23 / 29 23. What is the primary purpose of the using statement in C#? To declare constants To ensure the correct use of IDisposable objects To include namespaces To manage threading 24 / 29 24. What will be the output of the following code? public async Task<int> GetData() { await Task.Delay(1000); return 42; } public async Task PrintData() { int data = await GetData(); Console.WriteLine(data); } 42 after a delay 42 immediately Runtime error Compilation error 25 / 29 25. What will be the output of the following code? public class Singleton { private static Singleton _instance; private Singleton() { } public static Singleton Instance { get { if (_instance == null) { _instance = new Singleton(); } return _instance; } } public void Print() { Console.WriteLine("Singleton instance"); } } public class Program { public static void Main() { Singleton.Instance.Print(); } } Compilation error NullReferenceException Singleton instance Runtime error 26 / 29 26. What will be the output of the following code? public class Program { public static void Main() { Thread t = new Thread(Print); t.Start(); t.Join(); Console.WriteLine("Main thread"); } public static void Print() { Thread.Sleep(1000); Console.WriteLine("Worker thread"); } } Worker thread Main thread Worker threadnMain thread Main threadnWorker thread 27 / 29 27. Which design pattern ensures a class has only one instance and provides a global point of access to it? Adapter Factory Builder Singleton 28 / 29 28. What is the purpose of the dynamic keyword in C#? To define variables that can change type To create anonymous types To handle exceptions dynamically To enable late binding 29 / 29 29. Which of the following best describes the await keyword in C#? It pauses the execution of an asynchronous method until the awaited task completes It runs a task synchronously It creates a new task It starts a new thread Your score is 0%