Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is true about a static class in C#?
1) It cannot be instantiated.
2) It can only be instantiated once.
3) It can be instantiated multiple times.
4) None of the above
Answer : It cannot be instantiated.
What is the output of Console.WriteLine("C#".IndexOf("#"));?
1) 1
2) 0
3) -1
4) Error
Answer : 1
Which of the following is the correct way to initialize a list in C#?
1) List<int> myList = new List<int>();
2) list<int> myList = new list<int>();
3) int[] myList = new int[];
4) None of the above
Answer : List<int> myList = new List<int>();
Which of the following is the correct way to handle a file in C#?
1) using System.IO;
2) using System.File;
3) using File.IO;
4) None of the above
Answer : using System.IO;
Which of the following is used to get the hash code of an object in C#?
1) GetHashCode()
2) Hash()
3) GenerateHash()
4) None of the above
Answer : GetHashCode()
What is the output of Console.WriteLine(10 != 5);?
1) true
2) false
3) Error
4) None of the above
Answer : true
Which of the following is used to create a deep copy of an object in C#?
1) Clone()
2) Copy()
3) ShallowCopy()
4) None of the above
Answer : Clone()
What is the output of Console.WriteLine(10 >= 5);?
1) true
2) false
3) Error
4) None of the above
Answer : true
Which of the following is true about the static keyword in C#?
1) It belongs to the class, not the instance.
2) It belongs to the instance, not the class.
3) It can be inherited.
4) None of the above
Answer : It belongs to the class, not the instance.
What is the output of Console.WriteLine(10 <= 5);?
1) false
2) true
3) Error
4) None of the above
Answer : false