actually i created a Vehicle interface which has methods engine(),body() and wheels(). Car class and Bike class implement this.
I want to create a variable called color and wheel in Vehicle so that every class which inherits it has these. But unfortunately, I cannot make it. Can anybody please help me in making variables which are used by all the inheriting classes of Vehicle?
Thanks in advance
You can't, unless they are constants (static and final). Variables are implementation details, so they shouldn't be part of an interface.
Instead, what you can do is create an abstract class AbstractVehicle that implements Vehicle, and give that class the color variable (which should be private) and give it getter and/or setter methods to view or change the vehicles color. These methods are then inherited by Car and Bike, which both extend AbstractVehicle.
The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.