Session 1 C# and .
NET Framework
1. The .NET Framework allows the integration of codes written in:
a) Only C++
b) Only C#
c) Different programming languages
d) Only Java
Answer: c
2. Before .NET, each programming language required:
a) Separate execution environments
b) The same compiler
c) Java runtime
d) No execution environment
Answer: a
3. The .NET Framework provides a single platform for developing:
a) Android apps only
b) Windows and Web applications
c) Only database applications
d) Gaming apps exclusively
Answer: b
4. Examples of programming languages supported by .NET include:
a) Python and Ruby
b) Visual Basic and Visual C#
c) COBOL and Fortran
d) Swift and Kotlin
Answer: b
5. .NET Framework 4.0 was released in:
a) 2008
b) 2010
c) 2012
d) 2015
Answer: b
6. Which version of .NET was released in 2017?
a) .NET 4.6
b) .NET 4.7
c) .NET 5.0
d) .NET 7.0
Answer: b
7. The latest versions mentioned in the document include:
a) .NET 5.0 and 6.0
b) .NET 6.0 and 7.0
c) .NET Core 1.0 only
d) .NET 3.0 and 3.5
Answer: b
8. The first version of .NET Framework was:
a) 1.0
b) 2.0
c) 3.0
d) 4.0
Answer: a
9. Which feature ensures code written in one language can be reused in another?
a) Deployment
b) Consistent programming model
c) Language interoperability
d) Garbage collection
Answer: c
10. Automatic management of resources in .NET is done by:
a) Compiler
b) Garbage Collector (CLR)
c) Operating system
d) Assemblies
Answer: b
11. Deployment in .NET is simplified using:
a) DLL registration
b) Assemblies
c) Command prompt
d) XML files
Answer: b
12. Which benefit allows programmers to perform tasks such as database connectivity
easily?
a) Language interoperability
b) Consistent programming model
c) Automatic memory management
d) Thread safety
Answer: b
13. Which is the execution engine of .NET?
a) CLS
b) CLR
c) FCL
d) ADO.NET
Answer: b
14. Which component defines a standard set of data types?
a) CLR
b) CTS
c) CLS
d) BCL
Answer: b
15. The .NET Framework Class Library is also known as:
a) Base Class Library
b) Core Class Library
c) Component Class Library
d) Application Class Library
Answer: a
16. ASP.NET is mainly used for:
a) Web applications
b) Mobile apps
c) Networking
d) File storage
Answer: a
17. CLR handles:
a) HTML rendering
b) Automatic memory management
c) File compression
d) Only syntax checking
Answer: b
18. Just-In-Time compiler in CLR converts:
a) MSIL to native code
b) Source code to MSIL
c) MSIL to bytecode
d) Native code to MSIL
Answer: a
19. CLR provides:
a) Lifecycle monitoring
b) File encryption
c) Database backups
d) None of the above
Answer: a
20. Which of the following is NOT managed by CLR?
a) Memory
b) Thread execution
c) Type safety
d) File naming conventions
Answer: d
21. MSIL is similar to:
a) Python bytecode
b) Java bytecode
c) C++ machine code
d) SQL queries
Answer: b
22. MSIL ensures:
a) Faster GUI design
b) Runtime type-safety and security
c) Database independence
d) Platform-specific execution
Answer: b
23. Metadata generated includes:
a) File names only
b) Type definitions and signatures
c) Java classes
d) Operating system logs
Answer: b
24. JIT compilation happens:
a) Before execution
b) During execution, method by method
c) After execution
d) During deployment
Answer: b
25. A module refers to:
a) Database record
b) Binary like EXE or DLL
c) Only configuration file
d) Compiler
Answer: b
26. The manifest in an assembly contains:
a) Assembly name and version
b) Hardware details
c) Only namespaces
d) Operating system info
Answer: a
27. No MSIL code can run without:
a) DLLs
b) A manifest
c) Source code
d) Threads
Answer: b
28. An assembly's scope can be:
a) Local only
b) Public or private
c) Private or shared
d) Global only
Answer: c
29. Which IDE is widely used with .NET?
a) Eclipse
b) NetBeans
c) Visual Studio .NET
d) Android Studio
Answer: c
30. Visual Studio .NET introduces:
a) Java
b) C#
c) PHP
d) Kotlin
Answer: b
31. Visual Studio enhances Visual Basic with:
a) OO features
b) Database modules
c) HTML support
d) Security patches
Answer: a
32. Visual Studio is described as:
a) Multi-language development tool
b) Gaming SDK
c) Database engine
d) Scripting tool only
Answer: a
33. C# was built for:
a) Android
b) XML-based Web services on .NET
c) AI development only
d) Robotics exclusively
Answer: b
34. The main design goal of C# is:
a) Pure power
b) Complexity
c) Simplicity
d) Inheritance
Answer: c
35. C# is similar in syntax to:
a) SQL and R
b) C, C++, and Java
c) Ruby and Python
d) Swift and Kotlin
Answer: b
36. Nullable value type, delegates, and lambda expressions are features of:
a) Java
b) Python
c) C#
d) C++
Answer: c
37. Namespaces in C# contain:
a) Only variables
b) Types and other namespaces
c) Operating system code
d) Database connections
Answer: b
38. Organization in C# does not require:
a) Header files
b) Inline code writing
c) Declaration order
d) Constructors
Answer: a
39. C# members include all except:
a) Constants
b) Properties
c) Methods
d) Packages
Answer: d
40. Which is NOT part of type declarations?
a) Classes
b) Structs
c) Interfaces
d) Databases
Answer: d
41. Value types:
a) May be null
b) Cannot be null
c) Always null
d) Must be reference types
Answer: b
42. Reference types:
a) Contain actual data
b) Contain references to objects
c) Cannot be null
d) Are always structs
Answer: b
43. Example of a value type:
a) string
b) object
c) int
d) array
Answer: c
44. Example of a reference type:
a) struct
b) enum
c) class
d) int
Answer: c
45. In C#, int is an alias for:
a) System.Int64
b) System.Int32
c) System.Int16
d) System.Int128
Answer: b
46. Which is a floating-point predefined type?
a) int
b) char
c) double
d) bool
Answer: c
47. bool in C# represents:
a) Character type
b) Logical type
c) Floating type
d) Integer type
Answer: b
48. Which is an unsigned type?
a) sbyte
b) short
c) uint
d) int
Answer: c
49. Classes in C# support:
a) Multiple inheritance
b) Single inheritance
c) No inheritance
d) Unlimited inheritance
Answer: b
50. Structs differ from classes because they:
a) Are heap allocated
b) Are stored in-line
c) Support inheritance
d) Require garbage collection
Answer: b
51. An example of a struct is:
a) class Car
b) struct Point
c) interface IShape
d) array[]
Answer: b
52. One benefit of structs is:
a) More GC pressure
b) Stored on heap
c) More efficient memory use
d) Always inherited
Answer: c
53. A ternary operator uses:
a) ? and :
b) if and else
c) switch and case
d) loop constructs
Answer: a
54. Which is not a decision statement in C#?
a) if
b) switch
c) for
d) ?:
Answer: c
55. In a switch statement, default is used for:
a) Ignoring cases
b) Handling unmatched cases
c) Exiting loops
d) Declaring variables
Answer: b
56. The if statement can check if:
a) A character is uppercase
b) A database is connected
c) The compiler runs
d) The OS boots
Answer: a
57. A loop that always runs at least once is:
a) for
b) foreach
c) while
d) do...while
Answer: d
58. Which loop iterates over collections directly?
a) for
b) while
c) foreach
d) do
Answer: c
59. A while loop executes as long as:
a) True condition
b) Variable is int
c) Compiler accepts
d) It finds a struct
Answer: a
60. A for loop initializes, tests, and updates:
a) At runtime
b) In one line
c) Separately by CLR
d) Using metadata
Answer: b
61. The @ symbol in C# is used for:
a) String interpolation
b) Verbatim identifiers
c) Database connection
d) Type casting
Answer: b
62. The $ symbol in C# is used for:
a) Garbage collection
b) Interpolated strings
c) Declaring variables
d) Access modifiers
Answer: b
63. A raw string literal begins and ends with:
a) One double quote
b) Three or more double quotes
c) Single quotes
d) Backticks
Answer: b
64. The verbatim string literal can handle:
a) File paths easily
b) Thread execution
c) Database errors
d) Loop conditions
Answer: a
65. Interpolated strings are marked with:
a) @
b) $
c) %
d) &
Answer: b
66. Interpolation expressions are replaced with:
a) Null values
b) String representation of results
c) Database entries
d) Metadata
Answer: b
67. Interpolation provides:
a) Slower string handling
b) More readable formatting
c) Complex syntax
d) Unsafe memory usage
Answer: b
68. An example of string interpolation is:
a) Console.WriteLine("Hello, {0}");
b) Console.WriteLine($"Hello, {name}");
c) Console.WriteLine(@"Hello");
d) Console.WriteLine("Hello + name");
Answer: b
69. Delegates in C#:
a) Are similar to function pointers
b) Are variables
c) Are keywords
d) Replace structs
Answer: a
70. Lambda expressions provide:
a) Anonymous functions
b) Memory allocation
c) Loop iteration
d) Garbage collection
Answer: a
71. C# enums are used for:
a) Inheritance
b) Constants grouping
c) String formatting
d) Multithreading
Answer: b
72. Interfaces in C#:
a) Can have implementations
b) Define contracts
c) Are reference types
d) Both b and c
Answer: d
73. Class members can include:
a) Constants, fields, methods
b) Events, operators, constructors
c) Properties and destructors
d) All of the above
Answer: d
74. Member access modifiers in C# do NOT include:
a) public
b) protected
c) internal
d) external
Answer: d
75. Nested types in C# are:
a) Variables inside loops
b) Types declared inside another type
c) Structs only
d) Global constants
Answer: b
76. Static members belong to:
a) An instance of a class
b) The class itself
c) The CLR
d) The compiler
Answer: b
77. Assignment of structs copies:
a) The reference
b) The data
c) The memory address
d) The pointer
Answer: b
78. Structs do not support:
a) Interfaces
b) Inheritance
c) Methods
d) Fields
Answer: b
79. A benefit of structs is:
a) Heap allocation
b) Less garbage collection pressure
c) Always null by default
d) Support for multiple inheritance
Answer: b
80. Common struct examples include:
a) Rectangle, Point, Color
b) Database, Table, Row
c) String, Object, Array
d) Class, Interface, Enum
Answer: a
81. The ternary operator returns:
a) Always true
b) One of two values based on a condition
c) A switch statement
d) A loop control
Answer: b
82. In a switch statement, the case keyword is followed by:
a) A method
b) A type
c) A constant expression
d) A variable declaration
Answer: c
83. In an if statement, conditions must evaluate to:
a) int
b) char
c) bool
d) string
Answer: c
84. The default keyword in a switch:
a) Breaks execution immediately
b) Executes when no case matches
c) Declares the main method
d) Closes the switch
Answer: b
85. The while loop checks the condition:
a) Before each iteration
b) After each iteration
c) Only once
d) Randomly
Answer: a
86. The do...while loop guarantees:
a) The code may never run
b) At least one execution
c) Infinite looping
d) No condition checking
Answer: b
87. The foreach loop works with:
a) Arrays and collections
b) Integers only
c) Structs only
d) CLR metadata
Answer: a
88. A for loop typically consists of:
a) Declaration, body, return
b) Initialization, condition, iteration
c) Import, compile, execute
d) Case, break, default
Answer: b
89. The @ character allows keywords to be used as:
a) Identifiers
b) Strings
c) Methods
d) Enums
Answer: a
90. The @ verbatim string literal is useful for:
a) Mathematical operations
b) File paths and escape sequences
c) Variable declarations
d) Database queries
Answer: b
91. The $ string character is for:
a) Verbatim strings
b) Interpolated strings
c) Numeric types
d) Boolean expressions
Answer: b
92. String interpolation syntax improves:
a) Readability and formatting
b) Compilation speed
c) Execution security
d) Memory management
Answer: a
93. A raw string literal is enclosed in:
a) " "
b) ' '
c) """ """
d) @@
Answer: c
94. Raw string literals can:
a) Span multiple lines
b) Only be one line
c) Replace enums
d) Be used only for numbers
Answer: a
95. The output of @"c:\docs\file.txt" is:
a) c:\docs\file.txt
b) c:\docs\file.txt
c) c:/docs/file.txt
d) Error
Answer: b
96. The @ prefix in @for allows:
a) Reserved keyword "for" as variable
b) Ignoring loop logic
c) Creating inline methods
d) Using foreign functions
Answer: a
97. Delegates in C#:
a) Are type-safe function pointers
b) Are classes
c) Are loops
d) Are structs
Answer: a
98. Lambda expressions are typically used with:
a) Delegates and LINQ
b) Arrays only
c) Value types
d) Assemblies
Answer: a
99. The Common Language Specification (CLS) ensures:
a) Every .NET language can use the code
b) Only C# works
c) Java compatibility
d) File system access
Answer: a
100. The Common Type System (CTS) provides:
a) Standard rules for data types
b) Garbage collection
c) Just-In-Time compilation
d) Assembly deployment
Answer: a