What is method overriding?
with examples
Answers
Answered by
0
heya..! here is ur answer..
Overriding is about same method, same signature but different classes connected through inheritance. Overloading is an example of compiler-time polymorphism and overriding is an example of run time polymorphism.
hope u like it :)
Overriding is about same method, same signature but different classes connected through inheritance. Overloading is an example of compiler-time polymorphism and overriding is an example of run time polymorphism.
hope u like it :)
Answered by
1
Hey !!
When a method is a sub class has the same name and the same signature as a method in its super class, then the method in the subclass is said to override the method in the super class. It is determined at runtime.
Example :- public class A
{
public void add(int a, int b)
{
System . out . printIn (a + b);
}
}
class B extends A
public void add (int a, int b)
{
System . ont . printIn (''a + b = '' = (a + b));
}
}
GOOD LUCK !!
Similar questions
Math,
7 months ago
Chemistry,
7 months ago
Social Sciences,
1 year ago
Math,
1 year ago
Math,
1 year ago