What does the keyword virtual mean in the method definition?

Answers were Sorted based on User's Feedback



What does the keyword virtual mean in the method definition?..

Answer / venu gopal

The method can be over-ridden.

Is This Answer Correct ?    16 Yes 2 No

What does the keyword virtual mean in the method definition?..

Answer / kiran

Even though the function in base class is declared with
virtual keyword, it is not compulsory that the derived
class must override it.
namespace TestNewOverride
{
class MyBaseClass
{
int a;
public virtual int doubleit()
{
return 2 * a;
}
public MyBaseClass()
{
a = 5;
}
}

class MyDerivedClass:MyBaseClass
{
public static void Main()
{

}
}
}

Is This Answer Correct ?    7 Yes 0 No

What does the keyword virtual mean in the method definition?..

Answer / praseetha sandeep

when you have a method defined in a class which you want
to allow to be implimented by inherited class you can use
virtual function

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More C Sharp Interview Questions

If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?

1 Answers  


What is the use of tuple in c#?

0 Answers  


What is strong name assembly?

0 Answers  


who is a protected class-level variable available to?

0 Answers   Siebel Systems,


Is learning c# hard?

0 Answers  






What is the difference between “out” and “ref” parameters in c#?

0 Answers  


What are the important concepts in OOPS

5 Answers   Fulcrum Logic,


What is the difference between field and property in c#?

0 Answers  


How many types of variables are there in c#?

0 Answers  


What is the use of command builder?

0 Answers  


What is thread life cycle in c#?

0 Answers  


Difference between StackPanel and RelativePanel ?

0 Answers   HCL,


Categories