Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Multiple Choice Questions
Q651: Which of the following is not a type of array in C#?
- A: Single-dimensional array
- B: Rectangular array
- C: Jagged array
- D: Two-dimensional array
View Answer
D
Q652: Which of the following would be used to prevent a pointer from pointing to an incorrect memory location due to garbage collection in C#?
- A: fixed
- B: unsafe
- C: void
- D: static
View Answer
A
Q653: What would happen if you try to access a reference type using a pointer in C#?
- A: Compilation error
- B: Memory leak
- C: Invalid pointer
- D: Stack overflow
View Answer
A
Q654: What is the syntax for declaring a single-dimensional array in C#?
- A: int[] i = new int[5];
- B: int i[] = new int[5];
- C: int i = new int[5];
- D: int[5] i = new int[];
View Answer
A
Q655: In C#, which type of array allows each dimension to have a different length?
- A: Jagged array
- B: Rectangular array
- C: Multidimensional array
- D: Dynamic array
View Answer
A
Q656: What does the 'unsafe' keyword allow in C#?
- A: Declaring methods unsafe
- B: Declaring unsafe pointers
- C: Declaring managed memory
- D: Declaring fixed-size arrays
View Answer
B
Q657: In C#, Boolean values do not convert to which of the following?
- A: Integer variables
- B: Boolean expressions
- C: Arithmetic operations
- D: Characters
View Answer
A
Q658: What is the result of the following C# code: int a = 5; x = a++ + --a; if evaluated left-to-right?
- A: 8
- B: 10
- C: 5
- D: 6
View Answer
B
Q659: Which of the following loop types is used to iterate through the values contained by an object that implements the IEnumerable interface?
- A: while
- B: do-while
- C: for
- D: foreach
View Answer
D
Q660: What is the correct syntax for a 'foreach' loop in C#?
- A: foreach (variable1 in variable2) statement[s]
- B: foreach (variable1) statement[s]
- C: for (variable1 in variable2) statement[s]
- D: foreach variable1 in variable2 statement[s]
View Answer
A