Computer Science, asked by anuj, 1 year ago

What is method overriding?
with examples

Answers

Answered by denistravelp3ve2y
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 :)

Answered by nalinsingh
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