Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Multiple Choice Questions
Q151: How do you declare an array in C#?
- A: int myarray[] = new int[3];
- B: int[] myarray = new int[3];
- C: myarray[] = int[3];
- D: myarray = new int[3];
View Answer
B
Q152: What is the purpose of the out parameter in C# methods?
- A: To pass a value to the method
- B: To return a value from the method
- C: To pass a reference to the method
- D: To terminate the method
View Answer
B
Q153: What does the following code snippet do? String mychoice; Mychoice = getchoice();
- A: Calls a static method
- B: Calls a non-static method
- C: Calls a constructor
- D: Declares a new class
View Answer
B
Q154: Which of the following is true about object variables in C#?
- A: They hold the actual object
- B: They are references to the original object
- C: They are copies of the original object
- D: They are pointers to the original object
View Answer
B
Q155: What will the foreach loop do in this code? foreach (string person in names) { Console.writeline("{0} ", person); }
- A: It will iterate over the array names and print each element
- B: It will create a new array
- C: It will iterate in reverse order
- D: It will skip the first element
View Answer
A
Q156: What does the ref keyword in C# allow you to do?
- A: Pass parameters by value
- B: Pass parameters by reference
- C: Return multiple values
- D: Overload methods
View Answer
B
Q157: How can you create a multi-dimensional array in C#?
- A: int[,] array = new int[2, 2];
- B: int[] array = new int[2];
- C: int[2][2] array;
- D: int[2, 2] array = new int[2, 2];
View Answer
A
Q158: What is the main difference between switch and if-else statements?
- A: switch is for looping, if-else is for conditions
- B: switch can handle multiple cases, if-else handles only one
- C: switch is faster for multiple cases, if-else is more versatile
- D: switch is only for numbers, if-else is for all types
View Answer
C
Q159: What is the purpose of namespaces in C#?
- A: To group classes
- B: To manage exceptions
- C: To simplify loops
- D: To store data
View Answer
A
Q160: How can nested namespaces be accessed in C#?
- A: By using 'outer.inner'
- B: By using 'inner.outer'
- C: By using 'namespace::inner'
- D: By using 'outer/inner'
View Answer
A