C Sharp Polymorphism Questions and Answers
C Sharp Polymorphism questions with answers help developers and students understand one of the most important OOP (Object-Oriented Programming) concepts in C#. Polymorphism allows methods to perform different tasks based on the object that invokes them. This collection of programming questions and answers focuses on runtime and compile-time polymorphism, virtual methods, interfaces, and method overriding. Designed for those preparing for C# programming MCQ tests and interviews with TCS, Infosys, or Capgemini, these examples include detailed explanations and code snippets. Practicing such programming interview questions with answers will sharpen your technical problem-solving skills and deepen your understanding of polymorphism in real-world applications.
Learn about polymorphism in C# OOP. You might also find C# inheritance and interfaces .
C Sharp Polymorphism
11. Which of the following modifier is used when a virtual method is redefined by a derived class?
- overloads
- override
- overridable
- virtual
12. In order for an instance of a derived class to completely take over a class member from a base class, the base class has to declare that member as
- new
- base
- virtual
- overrides
13. Which of the following can be declared as a virtual in a class? Methods Properties Events Fields Static fields
- 1, 2, 3
- 3, 5
- 2, 4
- 2, 3, 5
14. Which of the following statements is correct?
- Only one object can be created from an abstract class.
- By default methods are virtual.
- If a derived class does not provide its own version of virtual method then the one in the base class is used
- If the method in the derived class is not preceded by override keywords, the compiler will issue a warning and the method will behave as if the override keyword were present.
15. Which of the following are necessary for Run-time Polymorphism? The overridden base method must be virtual, abstract or override. Both the override method and the virtual method must have the same access level modifier. An override declaration can change the accessibility of the virtual method. An abstract inherited property cannot be overridden in a derived class. An abstract method is implicitly a virtual method.
- 1, 3
- 1, 2, 5
- 2, 3, 4
- 4 only