Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Multiple Choice Questions
Q641: Which of the following is a feature of C# enumerations?
- A: They are mutable
- B: They are type-safe
- C: They allow multiple values per item
- D: They store only characters
View Answer
B
Q642: Which operator is used to retrieve the string representation of an enumeration in C#?
- A: ToString()
- B: EnumToString()
- C: GetEnumString()
- D: ToEnumString()
View Answer
A
Q643: In C#, which keyword is used to declare unsafe code?
- A: unsafe
- B: fixed
- C: volatile
- D: unsafe-block
View Answer
A
Q644: What does C# use to manage memory allocation in managed code?
- A: Garbage collector
- B: Manual memory management
- C: Direct memory access
- D: Memory pointers
View Answer
A
Q645: Which of the following is an advantage of using unmanaged code in C#?
- A: Easier memory management
- B: Better performance in real-time apps
- C: More flexible array handling
- D: Safer debugging
View Answer
B
Q646: In C#, which of the following statements would lead to a compilation error when working with enumerations?
- A: int i = (int)DAYS.Monday;
- B: DAYS d = (DAYS)i;
- C: int i = DAYS.Monday;
- D: DAYS d = (int)DAYS.Monday;
View Answer
C
Q647: What is a key difference between C# and C++ in terms of pointer usage?
- A: C# pointers can only point to value types
- B: C# pointers can be used for all types
- C: C# does not support pointers
- D: C# allows automatic pointer dereferencing
View Answer
A
Q648: Which operator is used in C# to access elements of a struct via a pointer?
- A: ->
- B: &
- C: *
- D: $
View Answer
A
Q649: Which keyword is used to declare a pointer in C#?
- A: &
- B: *
- C: ->
- D: unsafe
View Answer
B
Q650: In C#, which type of code does not require explicit memory management?
- A: Managed code
- B: Unmanaged code
- C: Unsafe code
- D: Native code
View Answer
A