1. What is the extension of a C# source code file?
• .cs
• .exe
• .dll
• .txt
Correct Answer: .cs
2. Which keyword is used to define a class in C#?
• struct
• interface
• class
• namespace
Correct Answer: class
3. What is the default access modifier for class members in C#?
• public
• private
• protected
• internal
Correct Answer: private
4. Which method is the entry point of a C# console application?
• Start()
• Main()
• Run()
• Init()
Correct Answer: Main()
5. Which of the following is a value type in C#?
• string
• int
• object
• class
Correct Answer: int
6. Which operator is used for string concatenation in C#?
• &
• .
• %
Correct Answer: +
7. Which data type is used to store true/false values in C#?
• boolean
• bit
• bool
• flag
Correct Answer: bool
8. What does IDE stand for?
• Internal Development Environment
• Integrated Design Environment
• Integrated Development Environment
• Intelligent Debug Environment
Correct Answer: Integrated Development Environment
9. Which of the following is a reference type?
• int
• float
• string
• bool
Correct Answer: string
10. Which keyword is used to inherit a class in C#?
• base
• extends
• :
• implements
Correct Answer: :
11. Which keyword is used to declare a constant variable in C#?
• const
• final
• readonly
• static
Correct Answer: const
12. Which C# keyword is used to handle exceptions?
• try
• catch
• finally
• All of the above
Correct Answer: All of the above
13. What is the size of an int data type in C#?
• 2 bytes
• 4 bytes
• 8 bytes
• Depends on the system
Correct Answer: 4 bytes
14. Which of these is NOT a C# access modifier?
• public
• private
• protected
• transient
Correct Answer: transient
15. How do you create a new object of a class in C#?
• new ClassName()
• create ClassName()
• [Link]()
• ClassName()
Correct Answer: new ClassName()
16. Which namespace contains fundamental classes in C#?
• System
• Microsoft
• CSharp
• Base
Correct Answer: System
17. What is the default value of a bool variable in C#?
• true
• false
• null
• 0
Correct Answer: false
18. Which keyword is used to define a method in C#?
• func
• method
• void
• def
Correct Answer: void
19. Which of the following loops is NOT present in C#?
• for
• while
• do-while
• foreach
Correct Answer: None, all are present
20. Which of these is used to define an interface in C#?
• interface
• class
• struct
• enum
Correct Answer: interface
21. What is boxing in C#?
• Converting a value type to reference type
• Converting reference type to value type
• Storing value types in heap
• All of the above
Correct Answer: Converting a value type to reference type
22. What is the keyword used to prevent a class from being inherited?
• sealed
• static
• abstract
• private
Correct Answer: sealed
23. Which operator is used for null-coalescing in C#?
• ??
• ??=
• ?:
• ::
Correct Answer: ??
24. Which method is used to start a thread in C#?
• Begin()
• Start()
• Run()
• Execute()
Correct Answer: Start()
25. Which keyword is used for asynchronous programming in C#?
• async
• await
• defer
• Both async and await
Correct Answer: Both async and await
26. Which of the following represents a nullable type in C#?
• int?
• int
• int!
• nullable<int>
Correct Answer: int?
27. What will happen if you try to divide an integer by zero in C#?
• Returns 0
• Throws DivideByZeroException
• Returns infinity
• Compilation error
Correct Answer: Throws DivideByZeroException
28. Which of the following is NOT a valid C# identifier?
• _myVar
• 2ndValue
• value1
• firstName
Correct Answer: 2ndValue
29. Which collection type stores key-value pairs?
• List
• Dictionary
• Array
• Queue
Correct Answer: Dictionary
30. Which statement is used to exit a loop or switch statement?
• exit
• break
• continue
• return
Correct Answer: break
31. What is the output of the expression: 5 + "5" in C#?
• 10
• 55
• Error
• 55
Correct Answer: 55
32. Which method is used to convert a string to an integer in C#?
• ToInt()
• Convert.ToInt32()
• ParseInt()
• [Link]()
Correct Answer: Both Convert.ToInt32() and [Link]()
33. Which attribute is used to mark a method as obsolete?
• [Deprecated]
• [Obsolete]
• [Ignore]
• [Hide]
Correct Answer: [Obsolete]
34. What does the 'using' statement do in C#?
• Imports namespaces
• Defines a block for resource disposal
• Declares variables
• Both imports namespaces and resource disposal
Correct Answer: Both imports namespaces and resource disposal
35. Which of these can NOT be overloaded in C#?
• Constructors
• Operators
• Properties
• Destructors
Correct Answer: Destructors
36. What is the base class for all exceptions in C#?
• [Link]
• [Link]
• [Link]
• [Link]
Correct Answer: [Link]
37. Which of these is used to declare an anonymous method?
• delegate
• func
• lambda
• anonymous
Correct Answer: delegate
38. What is the purpose of the 'var' keyword in C#?
• Defines a variable with explicit type
• Enables implicit typing
• Defines a constant
• Defines a pointer
Correct Answer: Enables implicit typing
39. What is a delegate in C#?
• A reference type to methods
• A value type
• A pointer
• An exception handler
Correct Answer: A reference type to methods
40. What keyword is used to define a constant field that is evaluated at runtime?
• const
• readonly
• static
• sealed
Correct Answer: readonly
41. Which method in C# is called when an object is destroyed by the garbage collector?
• Finalize()
• Dispose()
• Destructor()
• Cleanup()
Correct Answer: Finalize()
42. Which of these access modifiers allow access within the same assembly but not from other
assemblies?
• private
• protected
• internal
• public
Correct Answer: internal
43. What is the output of the following code?
int x = 5;
[Link](++x);
• 5
• 6
• Error
• Undefined
Correct Answer: 6
44. Which operator can be overloaded in C#?
• ++
• &&
• ||
• ?:
Correct Answer: ++
45. Which LINQ keyword is used to filter a sequence?
• select
• where
• order by
• from
Correct Answer: where
46. What is the default access modifier of an interface member in C#?
• public
• private
• protected
• internal
Correct Answer: public
47. What keyword is used to inherit from a base class in C#?
• inherits
• extends
• :
• base
Correct Answer: :
48. Which of the following is NOT a valid C# data type?
• int
• char
• float
• real
Correct Answer: real
49. Which of these is used to handle multiple exceptions in a single catch block?
• catch (Exception ex)
• catch (IOException | NullReferenceException ex)
• catch (Exception1 & Exception2 ex)
• None of the above
Correct Answer: catch (Exception ex)
50. How do you comment a single line in C#?
• // comment
• /* comment */
• comment
• <!-- comment -->
Correct Answer: // comment