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.
Simple. All you need is to let the subclass inherit the superclass through inheritance. this would allow your subclass implement functions of your superclass. 

For a more detailed reference kindly visit this link: <http://docstore.mik.ua/orelly/java-ent/jnut/ch03_04.htm>