Qus:    Explain about the method overriding.
Dec 09, 2020 12:41 2 Answers Views: 618 PADMAKEECHU

 Public Class Parent{

Public void mymethod()

{

Console.Write(“Parent Class”);

}

}

Public Class Child:Parent {

Public void override mymethod()

{

Console.write(“Child Class”)

}

}

//Just overring the implementation in child class

Static void Main()

{

Parent objParent = new Parent()

objParent.Mymethod(); // Output : Parent Class

Child objChild = new Child();

objChild.MyMethod(); // Output : Child Class

}

Prev Next
Answers (2)
PARTH Dec 10, 2020 08:02
Answer:   Method Overriding is a technique that allows the invoking of functions from base class in the derived class. It means creating a method in the derived class with the same signature as a method in the base class.

SHIVA Dec 11, 2020 08:07
Answer:   Public Class Parent{
Public void mymethod()
{
Console.Write(“Parent Class”);
}
}
Public Class Child:Parent {
Public void override mymethod()
{
Console.write(“Child Class”)
}
}
//Just overring the implementation in child class
Static void Main()
{
Parent objParent = new Parent()
objParent.Mymethod(); // Output : Parent Class
Child objChild = new Child();
objChild.MyMethod(); // Output : Child Class
}

Post Your Answer
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect