Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Multiple Choice Questions
Q621: In C#, structs cannot have _______.
- A: constructors
- B: methods
- C: fields
- D: events
View Answer
A
Q622: Which of the following does NOT belong to the C# data types?
- A: struct
- B: class
- C: array
- D: table
View Answer
D
Q623: What would be the output of the following code: string s1 = "hello"; s1 = "world";
- A: hello
- B: world
- C: both hello and world
- D: Error
View Answer
B
Q624: Which of the following is true about C# properties?
- A: They are like fields
- B: They can be accessed like variables
- C: They are equivalent to methods
- D: They cannot have both get and set methods
View Answer
B
Q625: In C#, which data type is used to store Unicode characters?
- A: char
- B: string
- C: int
- D: bool
View Answer
A
Q626: What is the range of an int in C#?
- A: -32768 to 32767
- B: -2147483648 to 2147483647
- C: 0 to 255
- D: 0 to 65535
View Answer
B
Q627: In C#, which type of code is executed under the control of the Common Language Runtime (CLR)?
- A: Managed code
- B: Unmanaged code
- C: Unsafe code
- D: Native code
View Answer
A
Q628: What is the primary purpose of using pointers in C#?
- A: Accessing memory locations
- B: Writing cleaner code
- C: Allocating dynamic memory
- D: Managing string operations
View Answer
A
Q629: Which of the following is true about C# pointers?
- A: They can point to reference types
- B: They are used in unsafe code only
- C: They work in both managed and unmanaged code
- D: They work with Java data types
View Answer
B
Q630: What is the role of the garbage collector in C#?
- A: To handle explicit memory allocation
- B: To automatically free unused memory
- C: To track memory errors
- D: To optimize the use of pointers
View Answer
B