Number of questions 1,751
Number of tests completed 249,171
Number of questions answered 3,726,767
Number of registered users 19,071
Sign In | Register
Skip Navigation Links
Question: Can there be Virtual Constructors in C#, if so then does the same apply for the Destructor's?
Answer1: we can have virtual constructors and virtual destructors in C#
Answer2: we can not have virtual constructors and virtual destructors in C#
Answer3: we can have virtual constructors and not virtual destructors in C#
Answer4: we can not have virtual constructors but can have virtual destructors in C#
Answer5:
Answer: we can not have virtual constructors but can have virtual destructors in C#

Explaination: Constructors are not virtual in the sense that a derived class must define all the overloads they want for a constructor (nor can they have the virtual keyword). There is no such thing as "inheriting a base class constructor". However C# guarantees that for every derived class constructor a base class constructor will be called first. Normally this is the default constructor however you can use the base keyword to call a specific constructor from the base class. This constructor-chaining concept is prevalent throughout OO languages. C# however says that all destructor's (actually finalizer's) are virtual so no keyword is needed and finalization happens appropriately depending on type.
Link:

Correctly answered: 843
Incorrectly answered: 2040
Terms of Use
contact@quiznetonline.com Ver. 2.0.6783.38332