Java Reference
In-Depth Information
Review Questions
1. Fill in the blank: If all of the non-final fields of a class are private and the class contains
public methods to view or modify the fields, this is an example of
.
A. Tight encapsulation
B. Loose coupling
C. High cohesion
D. The is-a relationship
E. The has-a relationship
2. Given the following Television class definition:
public class Television {
public int channel;
private boolean on;
private int volume;
public void changeChannel(int newChannel) {
channel = newChannel;
}
public int getChannel() {
return channel;
}
public void turnOn() {
on = true;
}
public void turnOff() {
on = false;
}
public void turnUp() {
volume += 1;
}
Search WWH ::




Custom Search