score:-1

In Java we have the ability to extend an entire class. It is up to the programmer to decide which methods become overridden. We use the "extends" keyword to perform this task.

i.e.

public class A
{
  public void method1(){...}
  public void method2(){...}
}

public class B extends A
{
  public void method2(){...}
  public void method3(){...}
}

Here for class B we use the extends keyword. Due to inheritance, class B inherits method1, and in this case overwrites method2 and has added another method called method3. Hope this helps.


Related Query

More Query from same tag