C# mcq(multiple choice) question with answers

C# mcq(multiple choice) question with answers

C# MCQ (Multiple Choice Question) with answers

C# is a modern, object-oriented programming language developed by Microsoft. It is widely used for developing Windows desktop applications, video games, and mobile applications, as well as web applications and services using the .NET framework. C# features strong typing, automatic memory management, and supports both imperative and functional programming paradigms. It also has built-in support for LINQ (Language Integrated Query) and asynchronous programming.

1. What is the correct syntax for declaring a string in C#?
2. What is the correct syntax for declaring an array in C#?
3. What is the default value of a boolean in C#?
4. What is the access modifier for a class member that can only be accessed within the same class?
5. What is the correct syntax for declaring a method in C#?
6. What is the correct syntax for a for loop in C#?
7. What is the purpose of the "using" keyword in C#?
8. What is the value of a nullable int in C# when it has no value assigned to it?
9. What is the difference between a value type and a reference type in C#?
10. What is the purpose of the "var" keyword in C#?
11. What is the difference between the "continue" and "break" keywords in C#?
12. What is the correct syntax for declaring an integer in C#?
13. How do you declare a constant in C#?
14. What is the correct syntax for declaring a while loop in C#?
15. What is the correct syntax for creating an object in C#?
16. What is the correct syntax for declaring a switch statement in C#?
17. How do you access elements of an array in C#?
18. What is the output of the following code?
int x = 10;
int y = x++;
Console.WriteLine(y);
19. What is the output of the following code?
string str1 = "Hello";
string str2 = "Hello";
if (str1 == str2)
{
    Console.WriteLine("Equal");
}
else
{
    Console.WriteLine("Not Equal");
}
20. Which of the following is a valid method to convert a string to an integer in C#?
Quiz TimeTest your knowledge

Test your knowledge with 10+ quizes

Remove adsremove