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.
Like someone said here you can use the template design pattern which will ensure that steps of an algorithm is given in a method so this way you can have the variable used in a method that can be used in a sub class. 

The other approach would be to set the access modifier as "protected" which ensures that the subclasses that inherits from the super class can use the variables in the super class