Java Reference
In-Depth Information
StringArrayList.java
Contains a more complete version of
StringArrayList
code in Figure 3.17.
ReadStringsWithStringArrayList.java
Contains a test program for
StringArrayList
.
IN SHORT
3.1
What is
information hiding
? What is
encapsulation
? How does Java
support these concepts?
Explain the public and private sections of the class.
3.2
Describe the role of the constructor.
3.3
If a class provides no constructor, what is the result?
3.4
3.5
Explain the uses of
this
in Java.
3.6
What happens if when attempting to write a constructor, a
void
return
type is included?
3.7
What is
package-visible access
?
3.8
For a class
ClassName
, how is output performed?
3.9
Give the two types of
import
directive forms that allow
BigRational
to
be used without providing the
weiss.math
package name.
3.10
What is the difference between an instance field and a static field?
3.11
Under what circumstances can a static method refer to an instance
field in the same class?
3.12
What is a
design pattern
?
For the code in Figure 3.18, which resides entirely in one file,
a.
3.13
Line 17 is illegal, even though line 18 is legal. Explain why.
b.
Which of lines 20 to 24 are legal and which are not? Explain why.
IN THEORY
3.14
A class provides a single private constructor. Why would this be useful?
Suppose that the
main
method in Figure 3.3 was part of the
IntCell
class.
a.
3.15
Would the program still work?
b.
Could the commented-out line in
main
be uncommented without
generating an error?
Search WWH ::
Custom Search