Ch.2 Flashcards

1
Q

As the name implies, the main “actors” in the
object-oriented paradigm are called [o..s]. Each
object is an [i..e] of a class. Each class presents
to the outside world a concise and consistent view of
the objects that are instances of this class…
The class definition typically specifies the [d..a
f..s], also known as [i..e v..s], that an
object contains, as well as the [m..s] (operations)
that an object can …

A

[objects][instance][data fields][instance variables][methods] 60

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The notion of [a..n] is to distill a complicated
system down to its most fundamental parts. Typically,
describing the parts of a system involves naming
them and explaining their functionality. Applying the
abstraction…

A

[abstraction] 62

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
...paradigm to the design of data structures gives rise to [a..t d..a t..s] (ADTs). An ADT is a
mathematical model of a data structure that specifies
the type of data stored, the operations supported on
them, and the types of parameters of the operations.
An ADT specifies [w..t] each operation does, but not
[h..w] it does it. In Java, an ADT can be expressed by an
[i..e], which is simply a list of method
declarations, where each method has an empty body.
...
An ADT is is realized by a concrete data structure,
which is modeled in Java by a [c..s] ... Also,
unlike interfaces, classes specify [h..w] the operations
are performed inthe body of each method. A Java
class is said to [i..t an i..e] if its
methods include all the methods declared in the
interface, thus providing a body for them. However, a
class can have more methods than those of the
interface...
A

[abstract data types][what][how][interface][class][how][implement an instance] 62

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

[M..y] refers to an organizing principle in
which different compo-nents of a software system are
divided into separate functional units. Robustness is
greatly increased because it is easier to test and debug
separate components before they are integrated …

A

[Modularity] 62

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Of special relevance to this book is the concept of [d..n p..n], which describes a solution to a
“typical” software design problem. A pattern provides
a general template for a solution that can be applied in
many different situations. It describes the main
elements of a solution in an abstract way that can be
specialized for a …

A

[design pattern] 64

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
The PredatoryCreditCard class [a..s] the
original CreditCard class, adding a new instance
variable named apr to store the annual percentage
rate, and adding a new method named processMonth
that will assess interest charges. The new class also
[s..s] its superclass by [o..g] the original
charge method in order to provide a new
implementation that assess a ...
A

[augments][specializes][overriding] 65

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
We begin with the first line of the class definition,
which indicates that the new class inherits from the
existing CreditCard class by using Java’s [e..s]
keyword followed by the name of its superclass. In
Java, each class can extend exactly one other class.
Because of this property, Java is said to allow only
[s..e i..e] among classes. We should also note
that even if a class definition makes no explicit use of
the e..s clause, it automatically inherits from a
class, java.lang.Object, which serves as the universal
superclass ...
A

[extends][single inheritance][extends] 66

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In Java, a constructor of the superclass is invoked
by using the keyword [s..r] with appropriate parameterization, as demonstrated at line 8 of our
implementation:
s..r;
This use of the [s..r] keyword is very similar to
use of the keyword [t..s] when invoking a different
constructor within the same class (as described on
page 15 of Section 1.2.2).
If a constructor for a subclass
does not make an explicit call to [s..r] or [t..s] as its
first command, then an implicit call to [s..r()], the
zero-parameter version of the superclass constructor,
will be made. Returning our attention to the
constructor for PredatoryCreditCard, after calling
the superclass constructor with appropriate
parameters …

A

[super][super][super][this][super][this][super()] 67

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

This is permitted precisely because the balance attributed was declared with [p..d] visibility in the original CreditCard class. (See Code Fragment 1.5.)
The most challenging aspect in implementing
the processMonth method is making sure…

A

[protected] 67

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Finally, we consider the new implementation of
the charge method provided for the
PredatoryCreditCard class (lines 21–27). This
definition [o..s] the inherited method. Yet, our
implementation of the new method relies ona call to
the inherited method, with syntax
[s..r].charge(price) at line 22. The return…

A

[overrides][super] 67

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

PredatoryCreditCard(…); // parameters omitted

This is a demonstration of what is known as the
[L..v S..n P..e], which states that a
variable (or parameter) with a declared type can be
assigned an instance from any direct or indirect
subclass of that type. Informally, this is a
manifestation of the “is a” relationship modeled by
inheritance, as apredatory credit card is a credit card
(but acredit card is not necessarily predatory).
We say that the variable, card, is [p..c]; it
may take one of many forms, depending on the
specific class of the object to which it refers.
Because card has been declared with type
CreditCard, that variable may only be used to call
methods …

A

[Liskov Substitution Principle][polymorphic] 68

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Java uses a process known as [d..c d..h],
deciding at runtime to call the version of the method
that is most specific to the actual type of the
referenced object (not the declared type). So, if the
object is a PredatoryCreditCard instance, it will
execute the PredatoryCreditCard.charge …
Java also provides an [i..f] operator that
tests, at runtime, whether an instance satisfies as a
particular type. For example, the evaluation of the
boolean condition, (card [i..f]
PredatoryCreditCard), produces [t..e] if cur-rently referenced by the variable card belongs to
the PredatoryCreditCard class …

A

[dynamic dispatch][instanceof][instanceof][true] 68

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Our second example of a specialized progression is
a geometric progression, in which each value is
produced by multiplying the preceding value by a
fixed con-stant, known as the [b..e] of the geometric
progression. The starting point of a geometric
progression is traditionally 1, rather than 0, because
multiplying 0 by any factor results in 0.

A

[base] 72

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
A [w..g c..n] occurs when a type T is
converted into a “wider” type U. The following are
common cases of widening conversions:
•
T and U are class types and U is a superclass of T...
A [n..g c..n] occurs when a type T is converted into a “narrower” type S. The following
are common cases of narrowing conversions:
• T and S are class types and Sis a subclass of T.
class
•T and S are interface types and S is a
subinterface of T...
A

[widening conversion] [narrowing conversion] 88

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

This is our first example
of an object-oriented design pattern known as the
[c..n d..n p..n]. If we know, for example,
that we want a pair to store a string and a
floating-point number, perhaps to store a stock ticker
label and a price, we could easily design a custom
class for that purpose. However, for another purpose,
we…

A

[composition design pattern] 91

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
Java includes support for writing [g..c] classes and
methods that can operate on a variety of data types
while often avoiding the need for explicit casts. The
generics framework allows us to define a class in
terms of a set of [f..l t..e p..s], which can
then be used as the declared type for variables,
parameters, and return values within ...
A

[generic][formal type parameters] 91

17
Q
Angle brackets are used at line 1 to enclose the
sequence of formal type parameters. Although any
valid identifier can be used for a formal type
parameter, single-letter uppercase names are
conventionally used (in this example, A and B)... When subsequently declaring a variable with such
a parameterize type, we must explicitly specify [a..l
t..e p..s] that will take the place of the
generic formal type parameters...
An instance of the
generic class is created, with the actual types for the
formal type parameters determined based upon the
original declaration of the variable to ...This process is known as [t..e i..e], and was introduced to the generics framework in Java SE7.
A

[actual type parameters][type inference] 92