Skip to main content

Visual Programming MCQs with Answers

Practice important Visual Programming MCQs with answers and explanations.

Chapter: 4
Q101:
Which of the following statements is true about C# memory management?
A. C# uses manual memory management
B. C# does not have garbage collection
C. C# has a "free" memory instruction
D. C# uses garbage collection
Correct Answer: D
Chapter: 4
Q102:
What is the purpose of the try-finally block in C#?
A. To handle exceptions
B. To ensure a block of code is always executed
C. To declare a block of code as unsafe
D. To allow multiple inheritance
Correct Answer: B
Chapter: 4
Q103:
What is NOT allowed in C#?
A. Multiple inheritance
B. Interface implementation
C. Operator overloading
D. Generics
Correct Answer: A
Chapter: 4
Q104:
Which of the following is true about C#'s type safety?
A. It allows narrowing conversions
B. It only allows integer widening
C. It allows all types of conversions
D. It disallows type safety
Correct Answer: B
Chapter: 4
Q105:
What are enumeration members in C#?
A. Globally scoped
B. Always static
C. Scoped within their type
D. Not allowed
Correct Answer: C
Chapter: 4
Q106:
What is the purpose of property syntax in C#?
A. To define global variables
B. To define accessors (getters and setters) for class properties
C. To define local variables
D. To declare constants
Correct Answer: B
Chapter: 4
Q107:
Which programming feature does C# support?
A. Multiple inheritance
B. Checked exceptions
C. Functional programming features like lambda expressions
D. Unchecked exceptions only
Correct Answer: C
Chapter: 4
Q108:
What is the difference between value types and reference types in C#?
A. Value types have referential identity
B. Reference types have referential identity
C. Both value and reference types have referential identity
D. Neither value nor reference types have referential identity
Correct Answer: B
Chapter: 4
Q109:
Which of the following is a value type in C#?
A. System.String
B. Object
C. System.Array
D. int
Correct Answer: D
Chapter: 4
Q110:
What is boxing in C#?
A. Storing a reference type in a value type
B. Storing a value type in a reference type
C. Converting a string to an int
D. Converting a class to a struct
Correct Answer: B
Chapter: 4
Q111:
What is unboxing in C#?
A. Converting a string to a char
B. Storing a reference type in a value type
C. Retrieving a value type from a reference type
D. Converting a class to an interface
Correct Answer: C
Chapter: 4
Q112:
Which of the following is an example of Generics in C#?
A. Public class genericlist<int>
B. Public class genericlist<>
C. Public class genericlist<string, int>
D. Public class genericlist<T>
Correct Answer: D
Chapter: 4
Q113:
What is the purpose of pre-processor directives like #if, #else, and #endif in C#?
A. To manage memory
B. To control conditional compilation
C. To declare variables
D. To define classes
Correct Answer: B
Chapter: 4
Q114:
Which syntax is used for single-line comments in C#?
A. <!-- comment -->
B. /* comment */
C. // comment
D. # comment
Correct Answer: C
Chapter: 4
Q115:
What is the purpose of XML documentation in C#?
A. To create a user manual
B. To generate documentation comments for code
C. To compile the program
D. To manage memory
Correct Answer: B
Chapter: 4
Q116:
What does the using directive do in C#?
A. It manages memory automatically
B. It imports namespaces for use in the code
C. It compiles the program
D. It defines global variables
Correct Answer: B
Chapter: 4
Q117:
How do you keep the console window from disappearing quickly when running a C# program in Visual Studio?
A. Use System.wait()
B. Use Console.readkey()
C. Use Console.readline()
D. Use System.pause()
Correct Answer: C
Chapter: 4
Q118:
Which command is used to compile a C# program from the command line?
A. javac Welcome.cs
B. csc.exe Welcome.cs
C. gcc Welcome.cs
D. dotnet Welcome.cs
Correct Answer: B
Chapter: 4
Q119:
What namespace is typically used for GUI-based applications in C#?
A. System
B. System.Drawing
C. System.Windows
D. System.Windows.Forms
Correct Answer: D
Chapter: 4
Q120:
What does the following C# code do? Messagebox.Show("Hello world!");
A. Prints "Hello world!" in the console
B. Displays a message box with "Hello world!"
C. Writes "Hello world!" to a file
D. Logs "Hello world!" to a system log
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Visual Programming

🚀 Start Quiz Now