I have a simple hierarchy of inheritance and a single interface. Consider class A which will be extended by class B. I wish for both classes to implement interface I and for class A to be abstract. In java I have roughly the following:

```
public interface I {
    public double foobar();
    public void print();
}

public abstract class A implements I {
    @Override public double foobar() { /*return foo*/}
    @Override public void print() {
        System.out.print(foobar());   
    }
}

public class B extends A {
    @Override public double foobar() { /*return bar*/ }
    @Override public void print() {
        super.print();
        System.out.print(foobar);
    }
}

```

My intent is to, when I instantiate an object of type B and call its print(), have the object of type B print first the foo from class A and then the bar from class B; however, when I compile an execute this code it calls the foobar() from class B in both cases. For example, if foo were to equal 1 and bar to equal 2, the output of the above code would be the following:

2
2

But I would like it to be
1
2

I have tried calling the method with various typecasting but have had no luck. Any suggestions?

Edit: Thank you for the many suggestions and just to clarify, I want each of the potential subclasses of A to implement I and I apologise for not stating that explicitly. Additionally, I currently have working code by adding an additional method in A privateFooBar() which is called by both A's print and A's foobar; however, I still wonder if there are more elegant ways to accomplish this task.