Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Multiple Choice Questions
Q681: What does the 'static' keyword do in C#?
- A: Declares a method to be a class method
- B: Declares a method to be an instance method
- C: Declares a method to be an abstract method
- D: Declares a method to be a virtual method
View Answer
A
Q682: Which method modifier in C# allows external method definitions?
- A: static
- B: new
- C: extern
- D: virtual
View Answer
C
Q683: What is the key difference between hiding and overriding methods in C#?
- A: Overriding always calls the base class method
- B: Hiding is always done with the 'new' keyword
- C: Hiding requires the method to be static
- D: Overriding is less restrictive than hiding
View Answer
B
Q684: In C#, how do you pass a value type by reference?
- A: Use the 'ref' keyword
- B: Use the 'out' keyword
- C: Use the 'params' keyword
- D: Use the 'static' keyword
View Answer
A
Q685: Which of the following is true about the 'ref' keyword in C#?
- A: The parameter must be initialized before being passed
- B: The parameter can be passed uninitialized
- C: The parameter is passed by value
- D: The 'ref' keyword is only used for classes
View Answer
A
Q686: What does the 'out' keyword in C# do?
- A: Passes variables by reference without initialization
- B: Passes variables by reference with initialization
- C: Passes variables by value
- D: It is used for method parameters only
View Answer
A
Q687: What is the purpose of the 'params' keyword in C#?
- A: To pass a fixed number of arguments to a method
- B: To pass an arbitrary number of arguments to a method
- C: To pass arguments as pointers
- D: To pass arguments as reference types
View Answer
B
Q688: Which of the following is NOT a valid modifier for readonly fields in C#?
- A: public
- B: private
- C: protected
- D: readonly
View Answer
D
Q689: What happens if you try to assign a value to a readonly field in C# after initialization?
- A: It results in a compile-time error
- B: It results in a run-time error
- C: The program continues without issues
- D: It causes a warning but runs
View Answer
A
Q690: What is the result of using the 'is' operator in C#?
- A: It checks if an object is of a specific type at compile time
- B: It casts an object to a specific type
- C: It tests if an object is of a specific type at runtime
- D: It converts an object to a string
View Answer
C