3. Implementing Interface must include: the methods (changeGear, changeCadence,
speedUp, applyBrakes, etc)
class BRANDBicycle implements Bicycle {
int cadence = 0;
int speed = 0; INITIAL VARIABLE
int gear = 1;
// The compiler will now require that methods
// changeCadence, changeGear, speedUp, and applyBrakes
// all be implemented. Compilation will fail if those
// methods are missing from this class.
void changeCadence(int newValue) {
cadence = newValue;
}
void changeGear(int newValue) {
gear = newValue;
}
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void printStates() {
System.out.println("cadence:" +
cadence + " speed:" +
speed + " gear:" + gear);
}
}
4. Questions
1. Real-world objects contain State and Behaviour.
2. A software object's state is stored in ___.
3. A software object's behaviour is exposed through ___.
4. Hiding internal data from the outside world and accessing it only through publicly exposed
methods is known as data ___.
5. A blueprint for a software object is called a ___.
6. Common behaviour can be defined in a ___ and inherited into a ___ using the ___ keyword.
7. A collection of methods with no implementation is called a ___.
8. A namespace that organizes classes and interfaces by functionality is called a ___.
9. The term API stands for ___?