C# Programming - Polymorphism - Discussion
Discussion Forum : Polymorphism - General Questions (Q.No. 9)
9.
Which of the following statement is correct about the C#.NET code snippet given below?
public class Sample
{
public int x;
public virtual void fun()
{ }
}
public class DerivedSample : Sample
{
new public void fun()
{ }
}
Discussion:
1 comments Page 1 of 1.
Lokesh Sharma said:
1 decade ago
A. Correct.
B. Sample objSample = new DerivedSample();
objSample.fun(); //it will call fun method of Sample class.
C. No, The Code replaces the Sample class version of fun() method with its DerivedSample class version.
D. It is possible by using Override keyword.
B. Sample objSample = new DerivedSample();
objSample.fun(); //it will call fun method of Sample class.
C. No, The Code replaces the Sample class version of fun() method with its DerivedSample class version.
D. It is possible by using Override keyword.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers