+1 vote
in Class 12 by kratos

What is method overriding?

1 Answer

+6 votes
by kratos
 
Best answer

When a method in 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.

Ex : 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.out.printIn ("a + b =" + (a + b));

}

}

...