C# Programming - Polymorphism - Discussion

Discussion Forum : Polymorphism - General Questions (Q.No. 7)
7.
Which of the following statements is correct?
Static methods can be a virtual method.
Abstract methods can be a virtual method.
It is necessary to override a virtual method.
When overriding a method, the names and type signatures of the override method must be the same as the virtual method that is being overriden.
We can override virtual as well as non-virtual methods.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Tiny said:   1 decade ago
[B] Abstract methods can be virtual.

The Following code is An abstract method that is virtual. Also [D] is correct

abstract class Journal
{
abstract virtual public void Issue()
{
// Implementation code
}
}

Vikrant said:   1 decade ago
We can't write the abstract virtual in abstract method. it gives an error "Abstract method Issue() cannot be marked virtual"

Andrue Cope said:   1 decade ago
'B' is sneakily wrong. An abstract method is implicitly virtual so you can't declare them as such. As per 10.6.6 of the the C# 3.0 spec:

'When an instance method declaration includes an abstract modifier, that method is said to be an abstract method. Although an abstract method is implicitly also a virtual method, it cannot have the modifier virtual.'

VHeddoori said:   1 decade ago
Abstract methods are implicit virtual methods.

Post your comments here:

Your comments will be displayed after verification.