1

I have a interface ShippingProduct and 2 classes ShippingProductStandard, ShippingProductGurtmass.

The class ShippingProductStandard implements the interface ShippingProduct.

public class ShippingProductStandard implements ShippingProduct {
...
}

Now i want that, the class ShippingProductGurtmass extends ShippingProductStandard and implements ShippingProduct. Do i need to implement the interface ShippingProduct like that:

public class ShippingProductGurtmass extends ShippingProductStandard implements ShippingProduct {
...
}

Or do i only need to extend the class ShippingProductStandard and it will implement the interface ShippingProduct from the parent class automatic?

public class ShippingProductGurtmass extends ShippingProductStandard{
...
}
Vikrant Kashyap
  • 5,900
  • 3
  • 29
  • 50
qvpham
  • 1,857
  • 8
  • 16

2 Answers2

1

Just extend the class ShippingProductStandard and it will implement the interface ShippingProduct from the parent class automatically. You may override those methods if you like.

Nuri Tasdemir
  • 9,495
  • 2
  • 39
  • 65
1

there is no need to write a relationship like this

public class ShippingProductGurtmass extends ShippingProductStandard implements ShippingProduct {
...
}

you can use only this code to call the overrided/implemented methods (in ShippingProductGurtmass) of Interface ShippingProduct

public class ShippingProductGurtmass extends ShippingProductStandard{
...
}

Relation hierarchy is automatically generated. You can Imagine it like as the java Concept says Object is a parent Class for all classes written in Java.

Vikrant Kashyap
  • 5,900
  • 3
  • 29
  • 50