C# .Net Quizz

Home C# .Net Quizz

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 is the primary purpose of the async keyword in C#?

2 / 29

2. 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");
}
}

3 / 29

3. What is the purpose of the lock statement in C#?

4 / 29

4. 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);

}

}

5 / 29

5. Which design pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes?

6 / 29

6. What is the primary purpose of the using statement in C#?

7 / 29

7. Which of the following is a deferred execution method in LINQ?

8 / 29

8. What is the purpose of the dynamic keyword in C#?

9 / 29

9. What does the DbContext class represent in Entity Framework?

10 / 29

10. Which design pattern ensures a class has only one instance and provides a global point of access to it?

11 / 29

11. What is the primary purpose of reflection in C#?

12 / 29

12. Which keyword is used in LINQ to create a new anonymous type?

13 / 29

13. Which of the following best describes the await keyword in C#?

14 / 29

14. What is the purpose of the AsParallel method in PLINQ?

15 / 29

15. Which class in the .NET Framework provides a mechanism to schedule and execute background tasks?

16 / 29

16. What keyword is used to allow a derived class to extend or modify the behavior defined in the base class method?

17 / 29

17. What is the purpose of the Monitor class in C#?

18 / 29

18. 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();

}

}

19 / 29

19. Which feature of C# allows the definition of methods that can be overridden in derived classes?

20 / 29

20. What does the Type.GetType method do?

21 / 29

21. 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());

22 / 29

22. What does the ConfigureAwait(false) method do in an asynchronous call?

23 / 29

23. 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);

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);

}

25 / 29

25. Which of the following is a correct way to handle exceptions in asynchronous methods?

26 / 29

26. Which of the following design patterns is used to convert the interface of a class into another interface that clients expect?

27 / 29

27. Which of the following is a use case of reflection in C#?

28 / 29

28. Which of the following is not a valid access modifier in C#?

29 / 29

29. What is the primary benefit of the Dependency Injection pattern?

Your score is

0%