Java Reference
In-Depth Information
SR 7.16
a. False - An interface can also include constants.
b. True - There is no body of code defined for an abstract method.
c. True - An interface is a collection of constants and abstract methods.
d. False - Although the class must define the methods that are included
in the interface, the class can also define additional methods.
e. True - As long as each of the implementing classes provides the
required methods.
f. True - As long as the class provides the required methods for each
interface it implements.
g. False - Although the signatures of the methods must be the same,
the implementations of the methods can be different.
7.6 Enumerated Types Revisited
SR 7.17 Using the enumerated type Season as defined in this section, the out-
put is
winter
summer
0
June through August
7.7 Method Design
SR 7.18
Method decomposition is the process of dividing a complex method
into several support methods to get the job done. This simplifies and
facilitates the design of the program.
SR 7.19
Based on the PigLatinTranslator class:
a. The service provided by the class, namely to translate a string into
Pig Latin, is accessed through a static method. Therefore, there is
no need to create an object of the class. It follows that there is no
need for a constructor.
b. The methods defined as private methods do not provide services
directly to clients of the class. Instead, they are used to support the
public method translate .
c. The Scanner object declared in the translate method is used to scan
the string sentence , which is passed to the method by the client.
SR 7.20
The sequence of calls is:
a. translate - translateWord - beginsWithVowel
b. translate - translateWord - beginsWithVowel -
beginsWithBlend
Search WWH ::




Custom Search