Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Chapter: 6
Q181:
How can we rename a namespace in C# using the 'using' directive?
A. Using 'using' keyword
B. Using 'namespace' keyword
C. Using '=' operator
D. Using ':' operator
Correct Answer:
C
Chapter: 6
Q182:
What is the output of the following code: Console.writeline("I'm a Square.");
A. I’m a Square
B. I’m a Square.
C. Square Output
D. Console Output
Correct Answer:
B
Chapter: 6
Q183:
In C#, which constructor is called first when an object of a derived class is created?
A. Static constructor
B. Destructor
C. Base class constructor
D. Derived class constructor
Correct Answer:
C
Chapter: 6
Q184:
What does the following code print: Console.writeline("I'm just a generic drawing object.");
A. Generic drawing object
B. I’m just a generic drawing object
C. I’m just a generic drawing object.
D. Drawing object output
Correct Answer:
C
Chapter: 7
Q185:
What is the primary purpose of auto-implemented properties in C#?
A. Simplify property declarations
B. Increase performance
C. Ensure thread safety
D. Simplify inheritance
Correct Answer:
A
Chapter: 7
Q186:
Which keyword is used in C# to define an indexer?
A. array
B. index
C. this
D. object
Correct Answer:
C
Chapter: 7
Q187:
How do you access an indexer in a C# class?
A. Using curly braces {}
B. Using parentheses ()
C. Using square brackets []
D. Using angle brackets <>
Correct Answer:
C
Chapter: 7
Q188:
What keyword is used to define a structure in C#?
A. struct
B. class
C. interface
D. enum
Correct Answer:
A
Chapter: 7
Q189:
What is a key difference between a struct and a class in C#?
A. Structs are reference types, classes are value types
B. Structs can inherit from other structs
C. Structs are value types, classes are reference types
D. Classes cannot contain methods, but structs can
Correct Answer:
C
Chapter: 7
Q190:
Which of the following statements about interfaces in C# is true?
A. Interfaces can contain implementation code
B. Interfaces cannot be inherited
C. Interfaces define a contract without implementation
D. Interfaces are used to implement multiple inheritance
Correct Answer:
C
Chapter: 7
Q191:
What happens if a class does not implement all methods of an interface it inherits in C#?
A. The class will not compile
B. The missing methods are automatically generated
C. The class will still compile with warnings
D. The class will inherit the methods from the base class
Correct Answer:
A
Chapter: 7
Q192:
Which method signature is correct for implementing an interface method in C#?
A. void MethodToImplement()
B. public void MethodToImplement()
C. private void MethodToImplement()
D. protected void MethodToImplement()
Correct Answer:
B
Chapter: 7
Q193:
What is the purpose of the "I" prefix in interface names in C#?
A. It enforces implementation
B. It is required by the C# compiler
C. It is a naming convention
D. It automatically implements the interface
Correct Answer:
C
Chapter: 7
Q194:
In C#, which of the following is true about polymorphism using interfaces?
A. It allows objects to be interchanged if they implement the same interface
B. It restricts the use of multiple interfaces
C. It prevents inheritance
D. It forces all objects to use the same methods
Correct Answer:
A
Chapter: 7
Q195:
What keyword is used to define an interface in C#?
A. interface
B. class
C. struct
D. implement
Correct Answer:
A
Chapter: 7
Q196:
Which method does a class implementing IDisposable interface need to define?
A. Dispose()
B. Release()
C. Cleanup()
D. Finalize()
Correct Answer:
A
Chapter: 7
Q197:
How are indexers overloaded in C#?
A. By changing the return type
B. By changing the number and types of parameters
C. By using different names
D. By using different access modifiers
Correct Answer:
B
Chapter: 7
Q198:
What will be the output of the following code if an indexer is used to access an element that is not set?
A. A null value
B. A compile-time error
C. An "empty" string
D. An "index out of range" error
Correct Answer:
C
Chapter: 7
Q199:
Which statement about structs in C# is true?
A. Structs can inherit from other structs
B. Structs can have destructors
C. Structs are reference types
D. Structs cannot inherit from classes but can implement interfaces
Correct Answer:
D
Chapter: 7
Q200:
Can a struct in C# have a constructor with parameters?
A. Yes, but it cannot override the default constructor
B. No, structs cannot have constructors
C. Yes, and it can override the default constructor
D. Only if the struct has no fields
Correct Answer:
A