Question: I am using java and I would like to force all of my subclasses to use the variables of the superclass.
The superclass is abstract and the subclasses implement all of its methods but not the variables.
Is there any way I can force the subclasses to use also the variables of the superclass?

thanks

Answer: 
You cannot "force" the subclass to use your variables. But maybe you are looking for the [Template Pattern](https://en.wikipedia.org/wiki/Template_method_pattern). This way, you can define a **template method** in the abstract superclass which defines the structure and the general working of your class. It calls the **hook methods** which are abstract and have to be provided by implementing classes. You can make it final to prevent subclasses from overriding the template method. Then the subclasses have to implement the abstract hook methods provided, but cannot override the template method.
The keyword `super` is most of the times used in conjunction to accessing superclass methods, most of the times a constructor from the parent class .

However, you can also use `super` to access fields of the superclass.

Here is an example of the usage for accessing fields.

```
public class Base {

    public int a = 1;
    protected int b = 2;
    private int c = 3;

    public Base(){

    }
}

public class Extended extends Base{

    public int a = 4;
    protected int b = 5;
    private int c = 6;

    public Extended(){

    }

    public void print(){
        //Fields from the superclass
        System.out.println(super.a);
        System.out.println(super.b);
        System.out.println(super.c); // not possible

    }
}

public static void main(String[] args) {
        Extended ext = new Extended();
        ext.print();
    }

```

You can always rename the fields in your subclasses not to conflict, but if you want to distinguish a method parameter or local variable from the superclass field, use `super` as you would use `this`