Download the full version and explore a variety of test banks
or solution manuals at https://testbankdeal.com
Java Software Solutions 8th Edition Lewis Test
Bank
_____ Follow the link below to get your download now _____
https://testbankdeal.com/product/java-software-
solutions-8th-edition-lewis-test-bank/
Access testbankdeal.com now to download high-quality
test banks or solution manuals
We have selected some products that you may be interested in
Click the link to download now or visit testbankdeal.com
for more options!.
Java Software Solutions 8th Edition Lewis Solutions Manual
https://testbankdeal.com/product/java-software-solutions-8th-edition-
lewis-solutions-manual/
Java Software Solutions 9th Edition Lewis Test Bank
https://testbankdeal.com/product/java-software-solutions-9th-edition-
lewis-test-bank/
Java Software Solutions 9th Edition Lewis Solutions Manual
https://testbankdeal.com/product/java-software-solutions-9th-edition-
lewis-solutions-manual/
Illustrated Microsoft Office 365 and Excel 2016
Intermediate 1st Edition Reding Solutions Manual
https://testbankdeal.com/product/illustrated-microsoft-office-365-and-
excel-2016-intermediate-1st-edition-reding-solutions-manual/
Intercultural Communication Globalization and Social
Justice 2nd Edition Sorrells Test Bank
https://testbankdeal.com/product/intercultural-communication-
globalization-and-social-justice-2nd-edition-sorrells-test-bank/
Organizational Behavior 18th Edition Robbins Solutions
Manual
https://testbankdeal.com/product/organizational-behavior-18th-edition-
robbins-solutions-manual/
Business and Administrative Communication 10th Edition
Locker Test Bank
https://testbankdeal.com/product/business-and-administrative-
communication-10th-edition-locker-test-bank/
Business Driven Information Systems 5th Edition Baltzan
Test Bank
https://testbankdeal.com/product/business-driven-information-
systems-5th-edition-baltzan-test-bank/
Plugged In 1st Edition Joel English Test Bank
https://testbankdeal.com/product/plugged-in-1st-edition-joel-english-
test-bank/
BUSN Canadian 3rd Edition Kelly Test Bank
https://testbankdeal.com/product/busn-canadian-3rd-edition-kelly-test-
bank/
1
Copyright © 2015 Pearson Education, Inc.
Java Software Solutions, 8e (Lewis/Loftus)
Chapter 7 Object-Oriented Design
7.1 Multiple-Choice Questions
1) During program development, software requirements specify
A) how the program will accomplish the task
B) what the task is that the program must perform
C) how to divide the task into subtasks
D) how to test the program when it is done
E) all of the above
Answer: B
Explanation: B) The specification phase is to understand the problem at hand so that the
programmer can determine what needs to be done to solve the problem. The other efforts listed
above are part of the design phase (A, C) and testing phase (D).
2) Once we have implemented the solution, we are not done with the problem because
A) the solution may not be the best (most efficient)
B) the solution may have errors and need testing and fixing before we are done
C) the solution may, at a later date, need revising to handle new specifications
D) the solution may, at a later date, need revising because of new programming language
features
E) all of the above
Answer: E
Explanation: E) A program should not be considered as a finished product until we are
reasonably assured that it is efficient and error-free. Further, it is common that programs require
modification in the future because of a change to specifications or a change to the language or
computer running the program.
3) Of the various phases in software development, which of the following is usually the
lengthiest?
A) specification
B) design
C) implementation
D) testing
E) maintenance
Answer: E
Explanation: E) The maintenance phase exists for as long as the software is in use. Software
requires modification (such as new requirements such as new features or I/O specifications) and
so the maintenance phase is on-going whereas the other phases end once the software has been
released and is in use.
2
Copyright © 2015 Pearson Education, Inc.
4) A bad programming habit is to build an initial program and then spend a great deal of time
modifying the code until it is acceptable. This is known as
A) the prototyping approach
B) the waterfall model
C) iterative development
D) the recursive approach
E) the build-and-fix approach
Answer: E
Explanation: E) Programmers who do not think things through will often build a program that
does not fit the original requirements. They then spend an inordinate amount of time trying to
repair the program to more properly fit. This is known as "build-and-fix" and is a poor
programming practice.
5) The activities of the development cycle are generally thought to
A) be strictly linear
B) be rigidly ordered
C) overlap
D) have optional steps
E) both A and B are true
Answer: C
Explanation: C) A flaw of the waterfall model is that it does not permit repetition or
backtracking through the development cycle. However, phases often need revisiting resulting in
a development cycle where the development activities overlap.
6) The idea of having programmers and developers meet in order to critique a software design or
implementation is known as
A) an interview
B) a walkthrough
C) prototyping
D) aggregation
E) evolutionary development
Answer: B
Explanation: B) Such meetings are very useful so that the various members can analyze the
solution to that point in time and offer suggestions to enhance the design and implementation.
This is called a walkthrough because it involves going step-by-step through the proposed or
implemented design.
3
Copyright © 2015 Pearson Education, Inc.
7) Modifying a program in order to eliminate deficiencies is done in the ________ phase of the
development cycle.
A) design
B) implementation
C) testing
D) use
E) maintenance
Answer: E
Explanation: E) While testing is used to find errors, deficiencies are more commonly identified
by the users of the system once the system has been released. After such deficiencies have been
identified, it is up to the software maintenance group to eliminate them in future versions of the
software.
8) It is easier to correct errors found in a program if
A) they are identified early in the development cycle
B) they are identified during testing
C) they are identified during program use
D) they are identified during maintenance
E) all of the above are equally true, errors are easily corrected in any of these stages
Answer: A
Explanation: A) Errors introduced early in the development cycle often cause tremendous
problems if not caught early on. Therefore, errors found in testing, use or maintenance phases
may be too embedded in the systems' design to be easily corrected. But if found early on, the
errors can be completely eliminated.
9) In general, spending more time in development to ensure better software will
A) shorten testing time
B) slightly reduce maintenance efforts
C) slightly increase maintenance efforts
D) greatly reduce maintenance efforts
E) not alter the time it takes for any other stage whatsoever
Answer: D
Explanation: D) Spending more time in development promises better software, which in turn
leads to less maintenance effort.
4
Copyright © 2015 Pearson Education, Inc.
10) The idea that an object can exist separate from the executing program that creates it is called
A) transience
B) static
C) persistence
D) serialization
E) finality
Answer: C
Explanation: C) Objects are stored in memory and are reclaimed by the garbage collector when
they are no longer referenced. When a Java program terminates, no object is referenced and so
all objects are reclaimed. It is desirable, however, to be able to save any given object for future
use. This trait is called persistence, and the ability to do this is by saving the instance data of the
object to a file. This can be done by writing each instance data to a data file, but is simplified
using Object Serialization.
11) In order to create a constant, you would use which of the following Java reserved words?
A) private
B) static
C) int
D) final
E) class
Answer: D
Explanation: D) The reserved word final indicates that this is the final value that will be stored
in this variable, thus making it unchangeable, or constant. While constants can be of type int,
constants can be of any other type as well. It is the final reserved word that makes the value
unchangeable.
12) Which of the following methods is a static method? The class in which the method is
defined is given in parentheses following the method name.
A) equals (String)
B) toUpperCase (String)
C) sqrt (Math)
D) format (DecimalFormat)
E) paint (Applet)
Answer: C
Explanation: C) The Math class defines all of its methods to be static. Invoking Math methods
is done by using Math rather than a variable of type Math. The other methods above are not
static.
5
Copyright © 2015 Pearson Education, Inc.
13) Static methods cannot
A) reference instance data
B) reference non-static instance data
C) reference other objects
D) invoke other static methods
E) invoke non-static methods
Answer: B
Explanation: B) A static method is a method that is part of the class itself, not an instantiated
object, and therefore the static method is shared among all instantiated objects of the class. Since
the static method is shared, it cannot access non-static instance data because all non-static
instance data are specific to instantiated objects. A static method can access static instance data
because, like the method, the instance data is shared among all objects of the class. A static
method can also access parameters passed to it.
14) An object that refers to part of itself within its own methods can use which of the following
reserved words to denote this relationship?
A) inner
B) i
C) private
D) this
E) static
Answer: D
Explanation: D) The reserved word this is used so that an object can refer to itself. For instance,
if an object has an instance data x, then this.x refers to the object's value x. While this is not
necessary, it can be useful if a local variable or parameter is named the same as an instance data.
The reserved word this is also used to refer to the class as a whole, for instance, if the class is
going to implement an interface class rather than import an implementation of an interface class.
15) An example of an aggregation relationship is
A) parent and child
B) animal and dog
C) teacher and computer
D) phone and fax machine
E) all of the above
Answer: C
Explanation: C) An aggregate relationship describes how one object accomplishes a task by
using another object. In the above list, the teacher uses the computer. The relationship in A is
one of lineage (possibly ownership), in B is an is-a relationship as a dog is a child class of
animal, and in D is one of similarity, phone and fax machine might be thought of as sibling
classes, related to each other in that they are both children of a more general communication
class.
6
Copyright © 2015 Pearson Education, Inc.
16) Inheritance through an extended (derived) class supports which of the following concepts?
A) interfaces
B) modulary
C) information hiding
D) code reuse
E) correctness
Answer: D
Explanation: D) By extending a class and inheriting from it, the new class does not have to
reimplement any of those inherited methods or instance data, thus saving the programmer an
effort. So, code reuse is the ability to reuse someone else's code for your benefit by extending it
for your need.
17) Java does not support multiple inheritance, but some of the abilities of multiple inheritance
are available by
A) importing classes
B) implementing interfaces
C) overriding parent class methods
D) creating aliases
E) using public rather than protected or private modifiers
Answer: B
Explanation: B) Since a class can implement any number of interfaces, that class is in essence
using the interface classes as if those interfaces were defined in this class. So, this class is
inheriting the methods and constants of the interfaces. Further, the class could extend another
class and thus inherit directly and indirectly from multiple classes. This is not the exact same as
multiple inheritance, but it is as close as Java comes to that concept.
18) Abstract methods are used when defining
A) interface classes
B) derived classes
C) classes that have no constructor
D) arrays
E) classes that have no methods
Answer: A
Explanation: A) An interface is a class that has defined some of its components, but leaves other
components (methods) for you to implement. So, these components (methods) are referred to as
abstract and defined in the interface class as abstract.
7
Copyright © 2015 Pearson Education, Inc.
19) Which of the following is not a method of the Object class?
A) clone
B) compareTo
C) equals
D) toString
E) all of the above are methods of the Object class
Answer: B
Explanation: B) The Object class defines clone to create a copy of any object, equals to
determine if two objects are the same object, and toString to translate an Object into a String.
However, compareTo is not implement by Object and must be explicitly implemented in any
class that wants to implement the Comparable interface.
20) Which of the following interfaces would be used to implement a class that represents a group
(or collection) of objects?
A) Iterator
B) Speaker
C) Comparable
D) MouseListener
E) KeyListener
Answer: A
Explanation: A) Iterator is an abstract class allowing the user to extend a given class that
implements Iterator by using the features defined there. These features include being able to
store a group of objects and iterate (step) through them.
21) In order to implement Comparable in a class, what method(s) must be defined in that class?
A) equals
B) compares
C) both lessThan and greaterThan
D) compareTo
E) both compares and equals
Answer: D
Explanation: D) The Comparable class requires the definition of a compareTo method that will
compare two objects and determine if one is equal to the other, or if one is less than or greater
than the other and respond with a negative int, 0 or a positive int. Since compareTo responds
with 0 if the two objects are equal, there is no need to also define an equals method.
For the questions below, consider a class called ChessPiece. This class has two instance data,
String type and int player. The variable type will store "King", "Queen", "Bishop", etc and the
int player will store 0 or 1 depending on whose piece it is. We wish to implement Comparable
for the ChessPiece class. Assume that, the current ChessPiece is compared to a ChessPiece
passed as a parameter. Pieces are ordered as follows: "Pawn" is a lesser piece to a "Knight"
and a "Bishop", "Knight" and "Bishop" are equivalent for this example, both are lesser pieces to
a "Rook" which is a lesser piece to a "Queen" which is a lesser piece to a "King."
8
Copyright © 2015 Pearson Education, Inc.
22) Which of the following method headers would properly define the method needed to make
this class Comparable?
A) public boolean comparable(Object cp)
B) public int comparable(Object cp)
C) public int compareTo(Object cp)
D) public int compareTo( )
E) public boolean compareTo(Object cp)
Answer: C
Explanation: C) To implement Comparable, you must implement a method called compareTo
which returns an int. Further, since this class will compare this ChessPiece to another, we would
except the other ChessPiece to be passed in as a parameter (although compareTo is defined to
accept an Object, not a ChessPiece).
23) Which of the following pieces of logic could be used in the method that implements
Comparable? Assume that the method is passed Object a, which is really a ChessPiece. Also
assume that ChessPiece has a method called returnType which returns the type of the given
piece. Only one of these answers has correct logic.
A) if (this.type < a.returnType( )) return -1;
B) if (this.type = = a.returnType( )) return 0;
C) if (this.type.equals(a.returnType( )) return 0;
D) if (a.returnType( ).equals("King")) return -1;
E) if (a.returnType( ).equals("Pawn")) return 1;
Answer: C
Explanation: C) If the type of this piece and of a are the same type, then they are considered
equal and the method should return 0 to indicate this. Note that this does not cover the case
where this piece is a "Knight" and a is a "Bishop", so additional code would be required for the
"equal to" case. The answer in B is not correct because it compares two Strings to see if they are
the same String, not the same value. The logic in D and E are incorrect because neither of these
takes into account what the current piece is, only what the parameter's type is. In D, if a is a
"King", it will be greater than this piece if this piece is not a "King", but will be equal if this
piece is a "King" and similarly in E, it does not consider if this piece is a "Pawn" or not. Finally,
A would give a syntax error because two Strings cannot be compared using the "<" operator.
24) Which of the following would not be considered an algorithm?
A) a recipe
B) a computer program
C) pseudocode
D) a shopping list
E) travel directions
Answer: D
Explanation: D) An algorithm is a step-by-step description of how to solve a problem, written at
some level of specificity. The recipe and probably the pseudocode are written at a "high level"
whereas a program and perhaps travel directions are written in more detail. A shopping list is
not a step-by-step description, so it would not qualify as an algorithm.
9
Copyright © 2015 Pearson Education, Inc.
25) It is important to dissect a problem into manageable pieces before trying to solve the problem
because
A) most problems are too complex to be solved as a single, large activity
B) most problems are solved by multiple people and it is easy to assign each piece to a separate
person
C) it is easier to integrate small pieces of a program into one program than it is to integrate one
big chunk of code into one program
D) our first solution may not solve the problem correctly
E) all of the above
Answer: A
Explanation: A) Any interesting problem will be too complex to solve easily as a single activity.
By decomposing the problem, we can build small solutions to each piece and then integrate the
pieces. Answer D is true, but does is not the reason why we will break a problem down into
pieces.
26) Having multiple class methods of the same name where each method has a different number
of or type of parameters is known as
A) encapsulation
B) information hiding
C) tokenizing
D) importing
E) method overloading
Answer: E
Explanation: E) When methods share the same name, they are said to be overloaded. The
number and type of parameters passed in the message provides the information by which the
proper method is called.
27) The goal of testing is to
A) ensure that the software has no errors
B) find syntax errors
C) find logical and run-time errors
D) evaluate how well the software meets the original requirements
E) give out-of-work programmers something to do
Answer: C
Explanation: C) Testing is required because all software will have errors. Complex systems
especially need testing before they can be released. The types of errors sought are logical errors
and run-time errors. All syntax errors will have been identified and fixed during implementation.
10
Copyright © 2015 Pearson Education, Inc.
28) Arranging components in a GUI container is accomplished by using which of the following?
A) Layout manager
B) Listener interface
C) String array
D) Event generator
E) JComboBox
Answer: A
Explanation: A) There are several classes of Layout managers. A Layout manager is used to
add GUI components to the container in some manner. The type of Layout manager determines
how items are added.
29) Which Layout Manager type would you use if you want GUI components to be placed at the
North, South, East, West and Center of the container?
A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
E) TabbedPane
Answer: B
Explanation: B) The BorderLayout specifically allows you to specify the component's location
as one of NORTH, SOUTH, EAST, WEST or CENTER where the value (e.g., NORTH) is a
constant predefined in the class.
30) Which Layout Manager type would you use if you want GUI components to be placed in 2
columns over 5 rows?
A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
E) TabbedPane
Answer: D
Explanation: D) The GridLayout manager allows you to specify the number of rows and
columns and then add elements across the column on one row until it is filled, and then on to the
next row, until all of the rows are filled.
31) Which Layout Manager is used by default if you do not specify a Layout Manager for your
GUI container?
A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
E) TabbedPane
Answer: A
Explanation: A) The FlowLayout is the default manager. It places GUI items across in one row
only. Other Layout Managers are more sophisticated and lead to better designed containers.
32) Which of the following GUI classes requires that it have a LayoutManager before any GUI
11
Copyright © 2015 Pearson Education, Inc.
components are added to it?
A) JButton
B) JSlider
C) JPanel
D) JFrame
E) both C and D but not A or B
Answer: C
Explanation: C) The JPanel requires adding a LayoutManager to it before any components are
added to it. This allows the components added to be arranged on the JPanel as desired. Neither
the JButton nor JSlider have components added to them and so do not require a LayoutManager.
The JFrame does not use a LayoutManager but instead adds elements through getContentPane( ).
33) In using the BoxLayout, adding space between components in a container can be
accomplished by
A) including TabbedPanes
B) including JButtons that have no names and thus will appear invisible
C) adding invisible components
D) inserting IconImages of blank images
E) any of the above
Answer: C
Explanation: C) The BoxLayout manager allows for the inclusion of specially designated
"invisible" components to take up space between real components and thus provide spacing.
34) In order to display three components vertically in a container, you could use all but which of
the following layout managers?
A) FlowLayout
B) BoxLayout
C) GridLayout
D) BorderLayout
E) you could use any of the above
Answer: A
Explanation: A) FlowLayout puts components horizontally and you cannot change that.
BoxLayout can place items horizontally or vertically. GridLayout allows you to specify the
number of rows and columns and to place the three components vertically, you would use (3, 1)
that is, 3 rows, 1 column. BorderLayout can place three components vertically by placing them
in the NORTH, CENTER and SOUTH positions.
12
Copyright © 2015 Pearson Education, Inc.
35) What is wrong with the following message to create a BoxLayout for the JPanel jp?
jp.setLayout(new BoxLayout(BoxLayout.X_AXIS));
A) X_AXIS is not a valid constant for BoxLayout, it should instead be HORIZONTAL
B) Aside from X_AXIS, the constructor also requires a Dimension to determine the size of the
Box
C) Aside from X_AXIS, the constructor also needs a command regarding horizontal glue as in
createHorizontalGlue( )
D) The BoxLayout constructor is lacking a reference to the container that the BoxLayout
manager will govern
E) There is nothing wrong with it at all
Answer: D
Explanation: D) The BoxLayout manager constructor requires two parameters, a reference to the
container that the manager will govern, and an axis for the layout, (vertical or horizontal) as
specified by either X_AXIS or Y_AXIS.
36) In which phase of program development would you expect the programmer(s) to create the
pseudocode?
A) Software requirements
B) Software design
C) Software implementation
D) Software testing
E) Could occur in any of the above
Answer: B
Explanation: B) Pseudocode is a description of an algorithm written in an English-like way
rather than in a specific programming language. This is part of the program's design. In the
implementation phase, the programmer(s) translates the pseudocode into the programming
language being used.
37) Which of the following is considered a top-level container?
A) Panel
B) Frame
C) Box
D) Layout Manager
E) A, B, and C
Answer: B
Explanation: B) While the answers in A, B and C are all types of containers, the Box and Panel
are made available to contain other components and are themselves placed into other containers.
The Frame is a top-level container because a Frame will not store other Frames, but instead, the
Frame contains Panels which can contain Boxes, Panels and other components.
13
Copyright © 2015 Pearson Education, Inc.
38) The JFrame below has a JBorder created using which of the following BorderFactory
formats?
A) TitledBorder
B) MatteBorder
C) EtchedBorder
D) RaisedBevelBorder
E) LoweredBevelBorder
Answer: D
Explanation: D) The JFrame has a Bevel border which is raised. A TitledBorder has a title
running along the top of it. The MatteBorder is of a Color or contains an image of some kind.
The EtchedBorder is not raised, and the LoweredBevelBorder is lowered, not raised.
39) To take 2 borders and use one as an outer border and the other as an inner border, you would
create a
A) compound border
B) nested border
C) split border
D) border factory
E) matte border
Answer: A
Explanation: A) The compound border comprises two borders that are combined together, one
border being the outside border and the other being the inside border.
40) In which phase of program development would you expect the programmer(s) to determine
the classes and objects needed?
A) software requirements
B) software design
C) software implementation
D) software testing
E) could occur in any of the above
Answer: B
Explanation: B) Determining which classes and objects to use or create is part of the design.
14
Copyright © 2015 Pearson Education, Inc.
41) If a programmer follows the four phases of program development as intended, which of the
four phases should require the least amount of creativity?
A) software requirements
B) software design
C) software implementation
D) software testing
E) none of the above, all four levels would require equal creativity
Answer: C
Explanation: C) Once the implementation phase has been reached, the algorithm should have
already been specified, so the only effort involved in the implementation phase is of translating
from the design (which is probably in an English-like pseudocode) to the programming language,
and entering the code through an editor. The requirements and design phases require
understanding the problem and coming up with a solution respectively, requiring creativity, and
the testing phase will require diagnostic abilities usually forcing the programmer(s) to be creative
in how the errors are found and fixed.
7.2 True/False Questions
1) The most important decisions regarding the development of a system are made during the
implementation phase while code is actively being written.
Answer: FALSE
Explanation: All of the important decisions should be made during earlier phases of
development, particularly during the design phase. By the time the implementation phase is
reached, the entire system design should be available and this phase should only entail
translating the design into code.
2) Unlike the String class where you must pass a message to an object (instance) of the class, as
in x.length( ), in order to use the Math class, you pass messages directly to the class name, as in
Math.abs( ) or Math.sqrt( ).
Answer: TRUE
Explanation: The Math class uses methods known as static methods (or class methods) which
are invoked by passing a message directly to the class name itself rather than to an object of the
class.
3) Assume that the class Bird has a static method fly( ). If b is a Bird, then to invoke fly, you
could do Bird.fly( );.
Answer: TRUE
Explanation: Static methods are invoked through the class and not an object of the class. This is
because the static method is shared among all instances. So, Bird.fly( ); will invoke fly. It
should be noted that fly can also be invoked through b, so b.fly( ); will also work.
4) Interface classes cannot be extended but classes that implement interfaces can be extended.
Answer: FALSE
Explanation: Any class can be extended whether it is an interface, implements an interface, or
neither. The only exception to this is if the class is explicitly modified with the word "final" in
which case it cannot be extended.
15
Copyright © 2015 Pearson Education, Inc.
5) If classes C1 and C2 both implement an interface Cint, which has a method whichIsIt, and if
C1 c = new C1( ); is performed at one point of the program, then a later instruction c.whichIsIt(
); will invoke the whichIsIt method defined in C1.
Answer: FALSE
Explanation: Because C1 and C2 implement the same interface, they both implement whichIsIt.
The variable c is known as a polymorphic variable, meaning that it can change from being an C1
to a C2. So, the message c.whichIsIt( ); may invoke C1's whichIsIt or C2's whichIsIt. There is
no way to tell until run-time.
6) Any class can implement an interface, but no classes can implement more than a single
interface.
Answer: FALSE
Explanation: Classes can implement any number of interfaces, 0, 1, or more.
7) All objects implement Comparable.
Answer: FALSE
Explanation: Comparable is an interface, and the class must define the compareTo method and
explicitly state that it implements Comparable to be considered an implementation of
Comparable. Most classes do not implement Comparable.
8) Formal parameters are those that appear in the method call and actual parameters are those
that appear in the method header.
Answer: FALSE
Explanation: The question has the two definitions reversed. Formal parameters are those that
appear in the method header, actual parameters are the parameters in the method call (those
being passed to the method).
9) Defining formal parameters requires including each parameters type.
Answer: TRUE
Explanation: In order for the compiler to check to see if a method call is correct, the compiler
needs to know the types for the parameters being passed. Therefore, all formal parameters (those
defined in the method header) must include their type. This is one element that makes Java a
Strongly Typed language.
10) It is not possible to test out any single method or class of a system until the entire system has
been developed, and so all testing is postponed until after the implementation phase.
Answer: FALSE
Explanation: While it is true that testing occurs after implementation, some testing can take
place during implementation. In Java, it is possible to test out single methods or classes by
creating stubs of other methods and classes that are simple placeholders. For instance, if one
method calls another method and the second method is not yet written, a stub of the second
method can be written that simply returns a value that would normally be expected so that the
first method can be tested.
16
Copyright © 2015 Pearson Education, Inc.
11) All parts of a container in BorderLayout must be used.
Answer: FALSE
Explanation: BorderLayout allows components to be inserted in any of North, South, East, West
and Center of the GUI, but as many or as few of these five sections can be used as needed.
12) A JPanel can itself contain JPanels.
Answer: TRUE
Explanation: It is common to place GUI components into a JPanel and then place several
JPanels into another JPanel. Each JPanel has its own layout manager allowing the programmer
to specify in detail how components should appear. For instance, one JPanel might use a
GridLayout and another a BoxLayout and then the two JPanels be placed in the NORTH and
EAST sections of a JPanel using BorderLayout.
13) If a GUI container is resized by the user, all components of the GUI are automatically
increased or decreased by the same fraction to fit in the newly sized container.
Answer: FALSE
Explanation: The layout manager will reposition the GUI items to fit in the newly sized
container.
14) The size and shape of a GUI container is based on the layout manager selected and the type
and number of items added to the container.
Answer: TRUE
Explanation: It is the layout manager's task to arrange the components in the container. Based
on the order that the items are entered and the type of layout manager, the size and shape are
determined.
15) A border can be put around any Swing component with the exception of a JButton and
JScrollPane component.
Answer: FALSE
Explanation: A border can be up around any Swing component no matter the type.
16) The term "test case" is used to express a set of inputs (or user actions) and the expected
outputs to be used in testing out software.
Answer: TRUE
Explanation: In order to test software to see if it is working correctly, a tester will often start
with a series of inputs and the expected outputs. If, when running the program on the inputs, the
outputs are not the expected results, then errors are assumed to exist. These input/output pairs
are known as test cases.
17
Copyright © 2015 Pearson Education, Inc.
17) In black-box testing, the tester should already know something about how the program is
implemented so that he/she can more carefully identify what portion(s) of the software are
leading to errors.
Answer: FALSE
Explanation: In black-box testing, the tester should know nothing about how the software is
implemented. In essence, the software is a black-box which has an input and an output and the
mechanisms of the program are opaque. If the tester does know something about how the
program works, then the tester's test cases might be biased. If the tester knows how the program
works, then testing is known as glass-box testing.
7.3 Free-Form Questions
1) Provide a reason why an instance data would be declared static.
Answer: If an instance data is to be shared among all objects of the class, the instance data
would be static. As an example, an instance data that counts the number of times something has
happened across all objects of the class would be made static. If we are writing a chess game
and have a ChessPiece class that includes a method called movePiece, we would want to know
how many moves a player has made, but not necessarily how many times a single piece has been
moved. So, all of the ChessPieces share a numberOfTimesMoved instance data that is
incremented by any ChessPiece whenever it is moved.
2) Provide a reason why a method would be declared static.
Answer: A method is declared static if it might be used, not by the current object, but by any
objects of the class. That is, the method does not require access to any single object's instance
data. Consider a class called Point that consists of an x and y coordinate. To determine the
distance between two Points, we could make a static computeDistance method. It is passed two
Points as parameters and computes the distance. Another example is the Keyboard class from
the textbook, which does not itself have any instance data.
3) Write a static method that is passed two ChessPieces and determines if the two pieces are
owned by the same player. It should return true or false.
Answer: public static boolean samePlayer(ChessPiece p1, ChessPiece p2)
{
return (p1.returnPlayer( ) = = p2.returnPlayer( ));
}
4) Explain the difference between implementing an interface and a derived class.
Answer: Implementing an interface means that you are adding to your class any mechanisms
defined in an abstract class. Your class essentially is expanded to contain those items defined in
the interface class but you have to implement any of those items that are abstract. The appeal is
that other objects might call upon your class to use the interface methods without knowing
anything else about your class. The derived class is similar in that you are gaining items
previously defined, although in this case, those items are defined in the parent class (as long as
those items are protected or public) and you do not have to implement any of them unless you
want to redefine them. One difference between the two is that the interface cannot be
instantiated directly. Another difference is that your class "inherits" abstract methods from the
interface class as opposed to implemented methods from a super class.
18
Copyright © 2015 Pearson Education, Inc.
5) Define an interface class that contains two int constants, X = 5 and Y = 10 and one int method
called useXY which receives no parameters. Call your interface class XYClass
Answer: public interface XYClass
{
public final int X = 5;
public final int Y = 10;
public int useXY( );
}
6) Assume a class Foo implements Comparable. Without knowing anything else about the Foo
class, write an equal method that returns true if the Foo parameter passed to this Foo is equal to
this Foo as determined by using the implementation of Comparable.
Answer: public boolean equals(Foo a)
{
if(compareTo(a)) = = 0)
return true;
else
return false;
}
19
Copyright © 2015 Pearson Education, Inc.
7) To implement Comparable for the ChessPiece class, the current ChessPiece's type is
compared to a ChessPiece passed as a parameter. The method should return 0 if the types are
equal, -1 if this piece's type is a lesser piece than the parameter's type, and 1 if this piece's type is
a greater piece than the parameter's type. Pieces are ordered as follows: "Pawn" is a lesser piece
to a "Knight" and a "Bishop", "Knight" and "Bishop" are equivalent for this example, both are
lesser pieces to a "Rook" which is a lesser piece to a "Queen" which is a lesser piece to a "King."
Write the proper method to implement Comparable for this class.
Answer: public int compareTo(ChessPiece a)
{
if (this.type.equals(a.returnType( )) | |
(this.type.equals("Knight") && a.returnType( ).equals("Bishop")) | |
(this.type.equals("Bishop") && a.returnType( ).equals("Knight")))
return 0;
else if (this.type.equals("King"))
return 1;
else if (a.returnType( ).equals("King"))
return-1;
else if (this.type.equals("Queen"))
return 1;
else if (a.returnType( ).equals("Queen"))
return -1;
else if (this.type.equals("Rook"))
return 1;
else if (a.returnType( ).equals("Rook"))
return -1;
else if (this.type.equals("Knight") | | (this.type.equals("Bishop"))
return 1;
else if (a.returnType( ).equals("Knight") | | (a.returnType( ).equals("Bishop"))
return -1;
}
8) Why was the Y2K problem a problem of software maintenance and not a problem of software
testing?
Answer: The Y2K problem was caused by older software that stored the year as a 2-digit value
instead of a 4-digit value (older software attempted to save memory space in any way possible,
this was a common way to save 2 bytes). Since the 2-digit year was not a logical or run-time
error, but instead, a flaw in the design, this problem was not detected during software testing.
Instead, it was not until the late 1990s, when people began to realize that a 2-digit year would
cause a problem starting in 2000, that the Y2K problem was identified and solutions sought, so
the problem was one of software maintenance how to maintain this older software so that it still
functions starting in the year 2000.
20
Copyright © 2015 Pearson Education, Inc.
9) In what way is black-box testing better than glass-box testing? In what way is glass-box
testing better than black-box testing?
Answer: Black-box testing is superior because the tester knows nothing of the software and so
will test the software without preconceived ideas of where errors might exist. The tester is
testing the software blindly, much as a user will use the software–without intimate knowledge of
how the software works. The result should be that if errors exist that a user might stumble
across, the tester should find them. While black-box testing of software has the advantage that
the tester operates much like the users are expected to, the disadvantage is that it is a blind test
and knowledge of how the software functions could be useful. If programmers suspect that some
awkward or difficult implementation may be buggy, then spending more time testing that portion
of the software is advantageous. This form of testing requires knowledge of how the software
works. So, both black-box and glass-box testing have their own advantages and disadvantages.
10) Write a set of code that will allow a user to select an input image and then place this image in
a JLabel lab1 and add lab1 to a JPanel as the northern component in a JFrame using
BorderLayout. The JFrame has already been instantiated as jf and the BorderLayout already
established. Hint: a JFileChooser returns a File and JLabel requires the String name of a file as
an argument. A File can return its name using File class' method getAbsolutePath( )
Answer: JFileChooser jfc = new JFileChooser( );
jfc.showOpenDialog(null);
File f = jfc.getSelectedFile( );
ImageIcon im = new ImageIcon(f. getAbsoluteFile( ));
JLabel lab1 = new JLabel(im);
jp.add(lab1, BorderLayout.NORTH);
jf.getContentPane( ).add(jp);
jf.pack( );
jf.setVisible(true);
21
Copyright © 2015 Pearson Education, Inc.
11) Write code to create a JPanel with 4 JCheckBox GUI components and two JLabels for
output, one that says "Current cost is" and the other that outputs the computed cost based on
which of the food items has been selected.
Answer: FoodListener fl = new FoodListener( );
JPanel jp = new JPanel(new GridLayout(3, 2));
jcb1 = new JCheckBox("Burger");
jcb2 = new JCheckBox("Fries");
jcb3 = new JCheckBox("Soda");
jcb4 = new JCheckBox("Cookie");
jcb1.addItemListener(fl);
jcb2.addItemListener(fl);
jcb3.addItemListener(fl);
jcb4.addItemListener(fl);
jl1 = new JLabel("Current cost is");
jl2 = new JLabel(" ");
jp.add(jcb1);
jp.add(jcb2);
jp.add(jcb3);
jp.add(jcb4);
jp.add(jl1)
jpadd(jl2);
add(jp);
22
Copyright © 2015 Pearson Education, Inc.
12) Provide code to generate the following JFrame. Each lettered item is a JButton. Hint:
Create several JPanels, each one having two or more JButtons and taken up a portion of the
JFrame.
Answer: JFrame jf = new JFrame( );
JPanel jp1 = new JPanel(new BorderLayout( ));
JPanel jp2 = new JPanel(new FlowLayout( ));
JPanel jp3 = new JPanel(new GridLayout(2, 3));
JButton lab1 = new JButton("A");
JButton lab2 = new JButton("B");
JButton lab3 = new JButton("C");
JButton lab4 = new JButton("D");
JButton lab5 = new JButton("E");
JButton lab6 = new JButton("F");
JButton lab7 = new JButton("G");
JButton lab8 = new JButton("H");
JButton lab9 = new JButton("I");
JButton lab10 = new JButton("J");
JButton lab11 = new JButton("K");
JButton lab12 = new JButton("L");
JButton lab13 = new JButton("M");
jp1.add(lab1, BorderLayout.NORTH);
jp1.add(lab2, BorderLayout.WEST);
jp1.add(lab3, BorderLayout.CENTER);
jp1.add(lab4, BorderLayout.EAST);
jp1.add(lab5, BorderLayout.SOUTH);
jp2.add(lab6);
jp2.add(lab7);
jp3.add(lab8);
jp3.add(lab9);
jp3.add(lab10);
jp3.add(lab11);
23
Copyright © 2015 Pearson Education, Inc.
jp3.add(lab12);
jp3.add(lab13);
JPanel jp4 = new JPanel(new GridLayout(3, 1));
jp4.add(jp1);
jp4.add(jp2);
jp4.add(jp3);
jf.getContentPane( ).add(jp4);
jf.pack( );
jf.setVisible(true);
24
Copyright © 2015 Pearson Education, Inc.
13) Provide code to generate the following JFrame. Each lettered item is a JButton. Hint:
Create several JPanels, each one having two or more JButtons and taken up a portion of the
JFrame.
Answer: JFrame jf = new JFrame( );
JPanel jp1 = new JPanel(new GridLayout(1, 3));
JPanel jp2 = new JPanel(new GridLayout(3, 1));
JPanel jp3 = new JPanel(new GridLayout(3, 1));
JPanel jp4 = new JPanel(new GridLayout(1, 3));
JPanel jp5 = new JPanel(new BorderLayout( ));
JButton lab1 = new JButton("A");
JButton lab2 = new JButton("B");
JButton lab3 = new JButton("C");
JButton lab4 = new JButton("D");
JButton lab5 = new JButton("E");
JButton lab6 = new JButton("F");
JButton lab7 = new JButton("G");
JButton lab8 = new JButton("H");
JButton lab9 = new JButton("I");
JButton lab10 = new JButton("J");
JButton lab11 = new JButton("K");
JButton lab12 = new JButton("L");
JButton lab13 = new JButton("M");
jp1.add(lab1);
jp1.add(lab2);
jp1.add(lab3);
jp2.add(lab4);
jp2.add(lab5);
jp2.add(lab6);
jp3.add(lab7);
jp3.add(lab8);
jp3.add(lab9);
jp4.add(lab11);
jp4.add(lab12);
jp4.add(lab13);
jp5.add(jp1, BorderLayout.NORTH);
jp5.add(jp2, BorderLayout.WEST);
jp5.add(lab10, BorderLayout.CENTER);
25
Copyright © 2015 Pearson Education, Inc.
jp5.add(jp3, BorderLayout.EAST);
jp5.add(jp4, BorderLayout.SOUTH);
jf.getContentPane( ).add(jp5);
jf.pack( );
jf.setVisible(true);
14) Provide code to generate the following JFrame. Each lettered item is a JButton. Hint:
Create several JPanels, each one having two or more JButtons and taken up a portion of the
JFrame.
Answer: JFrame jf = new JFrame( );
JPanel jp1 = new JPanel(new GridLayout(2, 2));
JPanel jp2 = new JPanel(new GridLayout(2, 2));
JPanel jp3 = new JPanel(new FlowLayout( ));
JPanel jp4 = new JPanel(new BorderLayout( ));
JPanel jp5 = new JPanel(new GridLayout(2, 2));
JButton lab1 = new JButton("A");
JButton lab2 = new JButton("B");
JButton lab3 = new JButton("C");
JButton lab4 = new JButton("D");
JButton lab5 = new JButton("E");
JButton lab6 = new JButton("F");
JButton lab7 = new JButton("G");
JButton lab8 = new JButton("H");
JButton lab9 = new JButton("I");
JButton lab10 = new JButton("J");
JButton lab11 = new JButton("K");
JButton lab12 = new JButton("L");
JButton lab13 = new JButton("M");
JButton lab14 = new JButton("N");
JButton lab15 = new JButton("O");
JButton lab16 = new JButton("P");
jp1.add(lab1);
jp1.add(lab2);
jp1.add(lab3);
26
Copyright © 2015 Pearson Education, Inc.
jp1.add(lab4);
jp2.add(lab5);
jp2.add(lab6);
jp2.add(lab7);
jp2.add(lab8);
jp3.add(lab9);
jp3.add(lab10);
jp3.add(lab11);
jp4.add(lab12, BorderLayout.WEST);
jp4.add(lab13, BorderLayout.NORTH);
jp4.add(lab14, BorderLayout.CENTER);
jp4.add(lab15, BorderLayout.EAST);
jp4.add(lab16, BorderLayout.SOUTH);
jp5.add(jp1);
jp5.add(jp2);
jp5.add(jp3);
jp5.add(jp4);
jf.getContentPane( ).add(jp5);
jf.pack( );
jf.setVisible(true);
27
Copyright © 2015 Pearson Education, Inc.
15) Draw the JFrame as you think it would appear given the following set of code:
JButton jb1 = new JButton("A");
JButton jb2 = new JButton("B");
JButton jb3 = new JButton("C");
JButton jb4 = new JButton("D");
JButton jb5 = new JButton("E");
JButton jb6 = new JButton("F");
JButton jb7 = new JButton("G");
JButton jb8 = new JButton("H");
JButton jb9 = new JButton("I");
JButton jb10 = new JButton("J");
JButton jb11 = new JButton("K");
JButton jb12 = new JButton("L");
JPanel jp1 = new JPanel( );
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
jp1.add(jb4);
JPanel jp2 = new JPanel(new GridLayout(4, 1));
jp2.add(jb5);
jp2.add(jb6);
jp2.add(jb7);
jp2.add(jb8);
JPanel jp3 = new JPanel(new GridLayout(2, 2));
jp3.add(jb9);
jp3.add(jb10);
jp3.add(jb11);
jp3.add(jb12);
JPanel jp4 = new JPanel(new BorderLayout( ));
jp4.add(jp1, BorderLayout.NORTH);
jp4.add(jp2, BorderLayout.EAST);
jp4.add(jp3, BorderLayout.WEST);
JFrame jf = new JFrame( );
jf.getContentPane( ).add(jp4);
jf.pack( );
jf.setVisible(true);
28
Copyright © 2015 Pearson Education, Inc.
Answer:
16) Draw the JFrame as you think it would appear given the following set of code:
JButton jb1 = new JButton("A");
JButton jb2 = new JButton("B");
JButton jb3 = new JButton("C");
JButton jb4 = new JButton("D");
JButton jb5 = new JButton("E");
JButton jb6 = new JButton("F");
JButton jb7 = new JButton("G");
JPanel jp1 = new JPanel(new GridLayout(3, 3));
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
jp1.add(jb4);
jp1.add(jb5);
jp1.add(jb6);
jp1.add(jb7);
JFrame jf = new JFrame( );
jf.getContentPane( ).add(jp1);
jf.pack( );
jf.setVisible(true);
Answer:
29
Copyright © 2015 Pearson Education, Inc.
17) Draw the JFrame as you think it would appear given the following set of code:
JButton jb1 = new JButton("A");
JButton jb2 = new JButton("B");
JButton jb3 = new JButton("C");
JButton jb4 = new JButton("D");
JButton jb5 = new JButton("E");
JButton jb6 = new JButton("F");
JButton jb7 = new JButton("G");
JButton jb8 = new JButton("H");
JButton jb9 = new JButton("I");
JPanel jp1 = new JPanel(new BorderLayout( ));
jp1.add(jb1, BorderLayout.NORTH);
jp1.add(jb2, BorderLayout.WEST);
jp1.add(jb3, BorderLayout.EAST);
JPanel jp2 = new JPanel(new BorderLayout( ));
jp2.add(jb4, BorderLayout.WEST);
jp2.add(jb5, BorderLayout.SOUTH);
jp2.add(jb6, BorderLayout.EAST);
JPanel jp3 = new JPanel(new BorderLayout( ));
jp3.add(jb7, BorderLayout.WEST);
jp3.add(jb8, BorderLayout.NORTH);
jp3.add(jb9, BorderLayout.EAST);
JPanel jp4 = new JPanel(new BorderLayout( ));
jp4.add(jp1, BorderLayout.NORTH);
jp4.add(jp2, BorderLayout.EAST);
jp4.add(jp3, BorderLayout.SOUTH);
JFrame jf = new JFrame( );
jf.getContentPane( ).add(jp4);
jf.pack( );
jf.setVisible(true );
Answer:
30
Copyright © 2015 Pearson Education, Inc.
18) Why should the add( ), subtract( ), multiply( ), divide( ) methods in the RationalNumber
class in the textbook be declared to be public, while the gcd( ) method is declared to be private?
Answer: The numeric operations must be public because they must be accessible to users of the
RationalNumber class. Declaring them private or protected don't accomplish this. The gcd( )
method is declared private because it is a "utility" method within the class. It should only be
used by class members because it has access to the internal structure of the class. One might
want to declare a static gcd( ) method one that just accepts a pair of ints, or longs, or whatever.
This static method would be similar to those in the Math class, like abs( ), sqrt( ), max( ), etc.
Other documents randomly have
different content
"Do you know who has come to-night to stay with us for a month?
Dicky—Dicky Browne. He met auntie and me last season in town.
And auntie asked him to run down to us for a bit. He's a nuisance,
certainly," shrugging her shoulders. "We all know that, in spite of
everything; but I do love Dicky more than any one else, I think."
"I wish I could believe that," said Agatha, in a low tone. Lord Ambert
was standing near, waiting for Elfrida. "Better love him than—-"
"Pouf! What a suggestion! Why should I love any one?" Elfrida's
piquant face was now alight with mischief. "Do you think I am such
a one as thyself? I tell you, Agatha, that I, for one, have no heart! I
can't afford one."
"I should think you could afford anything," said Agatha. "You could,
at all events, afford to marry the man who loved you."
"And where does he live?" asked Elfrida, laughing.
"You know," said Agatha slowly, earnestly.
"You're lovely; you're a perfect delight!" said Miss Firs-Robinson, her
amusement now growing more apparent; "but really I don't. I know
only that I—want to be—-"
"Happy?" said Agatha, answering.
"No; a countess," said the pretty little fairy, with a gay grimace. She
looked over Agatha's shoulder and beckoned to Lord Ambert, who
was still "in waiting," to come to her.
He came. A middle-sized, well-set-up man of about forty, with a
rather supercilious mouth and small eyes. He looked quite a
gentleman, however; which a great many earls do not, and, of
course, there he scored. He was a poor man for his rank in life, and
was desirous of impounding the numerous thousands in which Miss
Firs-Robinson lay, as it were, enwrapped. He never forgot his dignity,
however, when with her. He gave her quite to understand that she
was by birth many degrees below zero, and that he was a star in her
firmament.
In the meantime Elfrida, who had a very acute mind of her own, saw
straight through him. In a sense he amused her, and, after all, she
knew very well who would be mistress and master after her
marriage with him. Not Ambert, anyway. Her money should be
securely settled on herself; she was quite decided about that. She
was quite decided also about her marriage with him. She had lived
some little time in America, as has been said, and had learned the
value of our English lords; so she had arranged with herself very
early in life never to die until she could have a title carved upon her
tombstone. Ambert had come in quite handy. He was the only
unmarried earl within a radius of a tremendous number of miles, so,
of course, he would have to do. It was a pity he was so old—that he
was a little bald—that his expression was so unpleasant. But he was
an earl. She would be Lady Ambert; and if he thought he would
have it all his own way afterwards—why, she would show him. She
hadn't the least doubt about his proposing to her. She gave herself
no trouble on that head; and, indeed, she used to know great mirth
sometimes, when he had been specially laborious over his efforts to
prove to her that he had twenty or forty heiresses in his eye, who
would all be ready at a moment's notice to accept his title, his debts,
and his bald head.
For all that, she was determined to marry him. This, however, did
not prevent her indulging in small flirtations here and there. There
were several young officers in the barracks in the next town who
were literally at her feet, and there was the curate, Tom Blount, who
every one knew was a very slave to her every caprice.
"Ah, Mr. Blount," said she, as she passed him now on her way to the
conservatory. "Here? And you haven't asked me for a single dance."
"I don't dance," said Tom Blount. "The bishop doesn't like it, you
know, and to ask you to sit out a dance with me would be more than
I dare venture."
He smiled at her out of two honest blue eyes. And she smiled back
at him out of two very dishonest ones, though all four were much of
the same colour.
"'If thy heart fail thee,'" quoted she daringly.
"Well, I shan't let it fail me," said the curate suddenly. His smile was
somewhat forced, however. "Will you sit out one with me?"
"You don't deserve it," said she. "But—-"
Here Lord Ambert bent and whispered something into her ear. He
was evidently urging her to refuse the insolent request of this
nobody, this curate of a small country parish. But his words took no
effect. Elfrida listened to them, nodded and smiled as if acquiescing,
and then—-
"The fourteenth is a quadrille, for the sake of appeasing old Lady
Saunders, I believe," said she, looking at the curate. "Will you have
that dance—to sit it out with me?"
"Won't I!" said the curate enthusiastically, who had not long left
Oxford, and who was wonderfully young in many ways.
"You promised that quadrille to me," said Ambert, frowning.
"Yes, I know. But as I never dance quadrilles—-" She paused and
looked up at Ambert. "You see?"
"No, I don't," said he.
"Well I am sure Mr. Blount does," said Elfrida audaciously. "Now,
remember, Mr. Blount, the fourteenth is ours."
Lord Ambert looked at him.
Really the audacity of this contemptible curate passed
comprehension. To speak so to her, his—Ambert's—future wife. He
frowned and bit his lip. That was the worst of marrying into the
middle classes; they never know how to keep those beneath them in
order.
Lord Ambert, holding her hand during her descent from the steps to
the garden beneath, ventured a cold remonstrance.
"Is it wise of you—you will pardon, I hope, my interference— but is
it wise of you to be so kind to a person of that sort?"
"A person? Is he a person?" asked Miss Firs-Robinson with much airy
astonishment. "I quite understood he was a man of good family.
Whereas a 'person' must be of no family whatever."
"If without money," put in Lord Ambert quickly, "quite so. There are,
of course, grades."
"Grades?"
"Yes. A man of no birth with money is not the same as a man of no
birth without it. For money educates, refines, elevates." This he
pointed with little emphases, as a small hint to her.
"And a man of birth without money?"
"Sinks." Here Lord Ambert's voice took even a lower tone. "Sinks
until he meets the extreme—that is, the lowest of all classes—with
which he unites. I am afraid that young man you have just been
talking to will come to that end. His people, I believe, were in a
decent set at one time; but there is no money there now, and
probably he will marry his landlady's daughter, or the young woman
who manages the school in the village, and— repent it soon after."
"Repentance is good for the soul," said Elfrida; she laughed.
"But as you show it, money is everything. Even the 'person' can be
raised by it."
"It is sad of course, but I am afraid that is really the case. In these
days money is of great importance—of nearly as great importance as
birth or position. It lifts the 'person,' as you call it—-"
"Has it, then, lifted me?"
"Dear Miss Firs-Robinson! What a question! Surely you do not
consider yourself part of this discussion?"
He, however, had considered her so, and had taken pleasure in the
argument that had laid her low. This was part of what he called his
"training" of her!
"You—who are a thing apart, a thing most precious—-"
"I don't want to be a 'thing,' however precious," said Miss Firs-
Robinson, with decision. "I should much rather be a 'person,' for
choice, however criminal it sounds. It only wants 'age' put to it to be
magnificent. And so you call Mr. Blount 'a person'?"
"Perhaps I was wrong," said Ambert contemptuously; "a 'beggar'
would be nearer the mark."
CHAPTER V
Meanwhile Agatha was left standing near the doorway, whilst her
chaperon was explaining the reason of her late arrival to old Miss
Firs-Robinson, Elfrida's aunt.
The girl's eyes were directed towards the dancers, and so absorbed
was her gaze that she started visibly when a voice sounded at her
elbow—that hated voice!
"May I have the pleasure of this waltz, Miss Nesbitt?"
Agatha looked up. Dr. Darkham, tall, handsome, almost young, was
standing beside her.
"I am sorry—but the dance is promised," said Agatha, gently but
coldly.
"I am unfortunate." He looked keenly at her, with open question in
his eyes. He had educated himself very carefully on the lines of
social etiquette; but education of that sort, unless it comes by
nature, is often defective and sometimes he forgot. It did not now
suggest itself to him that to question Agatha's word, whether that
word were true or false, was a bêtise. Some men had come up to
ask, Agatha for a dance, and when they were gone he spoke.
"It is promised, then?" he said. "And yet you have only just come?"
Agatha looked at him for a moment as if surprised.
"It is promised," she said again.
She made no attempt to explain herself. Her manner, however, was
very quiet, although her face was set and her tone frozen.
Suddenly, however, her expression changed. It lit up with a happy
fervour, and her eyes shone. They were looking past Dr. Darkham's
towards something beyond, and the latter, as though unable to
control his longing to learn the cause of this sweet change in the
lovely face before him, turned to follow her glance, and saw over
there, making anxious efforts to reach her, a young man rather
above middle height, with a face that, if not strictly handsome, was
at all events extremely good to look at.
It was Dillwyn, the young doctor who had lately come into the
neighbourhood, and who was beginning to do pretty well with a
certain class of patients. Not the better classes; those belonged
almost exclusively to Darkham.
Dillwyn was still a long way off, hemmed in by a crowd of skirts that
now, being a little stiffened at the tail, took up a considerable
amount of room and were not easily passed. There was still a
moment or two before he could reach Agatha. Darkham caught his
opportunity and turned hurriedly to her.
"I hope you will give me a dance later on?" he said, with a dogged
sort of determination. He saw that she did not wish to dance with
him, but the knowledge only served to strengthen his desire to
dance with her; yet he did not ask her for the next dance. An almost
mad longing to waltz with her, to hold her in his arms for even a few
minutes, to feel her hand in his, took possession of him. He would
risk it.
"If the first supper dance is not engaged, may I hope for that?" he
said, his voice quite even, his heart beating wildly.
"I am afraid I have promised that, too," said Agatha, who had not
promised it, but she felt driven to desperation. Her voice was low
and tremulous. What was it about him that repelled her so? She
could not, she would not dance with him, whatever came of it.
Darkham bowed and drew back, leaning against the wall just behind
her. She felt miserable, and yet thankful, that she could no longer
see him. Yet she knew he was behind her, watching her; and she
had been rude—certainly, very rude.
At that moment Mrs. Poynter joined her.
"Not a partner yet? I suppose you must wait for this dance to be
over? Ah! here I see Dr. Dillwyn coming towards us. You know,
Agatha dearest, that he is a cousin of mine, and quite good family
and all that."
Agatha laughed.
"Yes, yes; you ought to take it that way. It really should not be
serious," said Mrs. Poynter, who was a young woman and fond of
Agatha, and thought the girl with her charming face ought to make
a good match. "I am so glad you are not going to be serious over it,
because, really, it would be a terrible throwing away of yourself."
"But Mrs. Poynter—-"
"Yes, of course. He hasn't proposed, you mean; but—I really wish he
had not been placed here through the influence of old Mrs.
Greatorex, Reginald Greatorex. The old gentleman might just as well
have sent him anywhere else, and he does run after you a good
deal, Agatha, doesn't he now?"
"I never saw him run in my life," said Agatha demurely.
"Ah, there! I see you are evading the subject. And here he comes.
Now Agatha, be careful; you know—-"
"Yes; I know, I know," said Agatha, smiling at her. Yet she hardly
heard her; her eyes and thoughts were for the young man who was
standing before her.
Neither of them saw the face behind them—the face of the man
leaning against the wall!
CHAPTER VI
"At last!" said John Dillwyn. "You have not given it away? You have
remembered?"
"The dance?"
"Yes. You know you said you would give me the first on your arrival."
"But this! I am so late! I could not have expected you to wait—-"
"I have waited, however. And it is mine?" He was now looking at her
anxiously. What did her manner, her hesitation, mean?
"Yes, of course, but have you no partner?"
"I have, indeed"—laughing. "One I would not readily change. I have
you."
"But," looking up at him a little shyly after this plain speech, "how
did you arrange it?"
"Very simply. This will be my first waltz as well a yours."
"Oh, that is too bad of you," said the girl, colouring softly. She
meant to be angry with him, perhaps; but if so, the effort was a
dead failure. The corners of her lips were smiling, and a happy light
had crept into her eyes. "To wait so long, and—-"
"It was long. I admit that," interrupted he, smiling. "I thought you
would never come."
"It was all Mrs. Poynter's fault," said Agatha. "And really, but for me
I am sure she would not be here even now."
"Well, come on, now; let us get even a turn or two," said Dillwyn.
"By the bye, the next—is that free?"
"Yes," said Agatha. She felt a little frightened. She hoped he would
not know she had kept it free purposely. Four or five men had asked
her for dances whilst she stood near the door on her arrival with
Mrs. Poynter, and when giving them a dance here and there she had
steadily refused to part with the next one. She did not tell herself
why at the moment, but she knew all the same.
"May I have it?" asked Dillwyn, with such a delightful anxiety that all
at once her mind was set at rest.
He suspected nothing, thought of nothing but his fear that the dance
might have been given away before he could ask her for it. Oh, how
dear he was! Was there ever any one so good, so perfect?
He passed his arm round her waist, and together they joined the
dancers.
Agatha waltzed delightfully. Her lovely svelte figure swayed and
sympathised with the music, just as though it had caught her and
was moving with her. Dillwyn waltzed well too.
The dance was too soon at an end.
"The night is lovely," said he, "will you come out?" He felt that he
wanted to be more alone with her; the presence of the people round
checked him, destroyed the keenness of the joy he always knew
when with her.
"I should like it," said she.
They went towards the conservatory, from which there were steps to
the garden outside. The door of the conservatory opened off the
dancing-room, and was close to where Agatha had been standing on
her entrance. Darkham was still there.
He had not stirred since Agatha had floated away with Dillwyn's arm
around her. He had watched her persistently. He watched her now as
she went through the conservatory door down to the gardens, that
glad, sweet light upon her face. Were his wife's words true then,
after all? Was there something between her and that fellow—that
interloper, who had come from no one knew where, to dispute his
right in all the parish ailments? His eyes followed them as though
they could not tear themselves away, as Dillwyn and Agatha, happy,
laughing, went out of the door beyond into the mild and starlit night.
A laugh roused him; it was his wife's. A terrible vision in scarlet
satin, trimmed with black velvet bows, met his gaze as he turned.
Mrs. Darkham was distinctly en fête to-night.
"Well, what d'ye think now? That's her young man. What did I say?
Don't you wish you were young, eh? Why, she looks upon you as a
Methusaler!"
Darkham drew his breath sharply. He looked quickly round him. Had
any one heard? The woman's hideous vulgarity made him sick. Try
as he would, how could he raise himself with this incubus hanging
round his neck?
He moved away, tired at heart, half mad with misery.
Agatha and Dillwyn had reached the garden by this time—a garden
lit by heaven's own lamps, and sweet with the breath of sleeping
flowers.
A few other couples were strolling up and down the paths—but over
there was a garden-chair untenanted. They moved towards it in a
leisurely fashion. Whether they stood or walked or sat, they were
together—that was the principal thing.
"The next is mine, too," said he, in a glad voice, as if dwelling on
some joy that nothing could spoil.
"Yes. We must take care not to lose it."
"And yet it is so lovely out here. Are you sure you are warm enough?
And, at all events, it is a good thing to know we need not hurry—
that there is no other partner waiting for either of us."
He seemed to dwell upon the "we" and "us" as if they conveyed
great sweetness to him. His heart seemed full. All at once it seemed
to him as though he must speak to her—must tell her of the love
that filled his heart. The hour, the loneliness, the silence, all tempted
him, and yet he feared!
She had known him so short a time—and what was there in her
manner to him that should give him courage? Could he dare to put it
to the touch to win—or lose it all? To lose! That was what held him
back.
Agatha was speaking.
"I am so sorry you waited for me," said she, lying unconsciously.
Had not her heart beaten with delight because he had waited? "And
you, too, who are so fond of dancing."
"Ah! fond! That is a strong expression. I am not a slave to it, you
know."
"No." She paused. She seemed to study him for a moment. His face,
young, strong, with a sort of defiance in it, as though he could and
would conquer his world, fascinated her. It had always fascinated
her from the first moment she saw it, now three months ago. It was
not so much the kindliness of it as its strength that attracted her.
She, too, could be strong. She felt in harmony with him from the
very first. He was, as has been said, not strictly handsome, but his
eyes were dark and expressive, and his mouth firm. The pose of his
head was charming and his figure well-built and athletic. He was
always in splendid spirits, and the milk of human kindness ran swiftly
within his veins. Already the poor in his district began to adore him,
for kind were his words and encouraging his smiles, and these
counted with the sickly ones even more than the shillings that so
often came out of a pocket where but few shilling lay. He had begun
his fight with life unaided, save by the influence of old Reginald
Greatorex, who had property in Rickton, and had got him appointed
there, but he felt no fears. A natural buoyancy upheld him.
"Well," said he, smiling at her. He was wondering at the depth of her
regard.
"I was thinking," said she, starting slightly, "that you could never be
a slave to anything."
Dillwyn looked at her now.
"There you wrong me," said he. "I could be—I am—a slave!"
"It is difficult to believe," said she calmly.
"Why should it be difficult?"
"I don't know. But you don't lend yourself readily to the idea. You
look as if you could never be easily swayed or governed."
"Not easily, perhaps. But—-" He put out his hand as if to clasp hers.
At this moment a sudden movement in the bushes behind her struck
upon Agatha's ears. She sprang to her feet.
CHAPTER VII
A sense of faintness crept over her. By some strange prescience, she
knew who stood behind there in the darkness, concealed, listening.
A great horror took possession of her. Why should he haunt her so?
What was she to him? He who had a living wife!
She turned to Dillwyn, who had risen too.
"Come back to the house," said she. Her voice was nervous, but very
low. She moved away from the seat, on which she had been resting,
with a haste that was almost feverish. Dillwyn followed her, his mind
disturbed. Had she fathomed his determination to speak to her, and
had she purposely prevented his speaking? He went at once to the
point, as he always did when uncertain or perplexed.
"Have I offended you?" asked he.
"No! Oh, no! You must not think that. How could you have offended
me? But I thought I heard some one—there—behind the shrubs."
"But even so, there are people all over the place to-night."
"Yes, I know." Her tone now was almost heartbroken. She stopped
suddenly and held out her hand to him. "You are still my friend?"
said she.
"I shall be your friend to the last day of my life," said Dillwyn. But
his tone was heavy; the elasticity that always distinguished it had
gone out of it for the first time.
In silence they reached the house. Not another word was said about
the dance impending. Agatha seeing a couch surrounded by fragrant
shrubs, went towards it.
"The dance has begun," said Dillwyn, but so coldly that she shrank
from him.
"I am tired," she said.
"Then you had better rest here. Shall I bring you an ice?"
"Thank you."
He went away. Agatha dropped on to the lounge and gave her
misery full play. She had put an end to it all—all that might have
made her dull life a very spring of joy. And yet to tell the man who
loved her that another man—a married man—pursued her with his
hateful attentions was more than she could do.
Now, left alone, her spirit failed her, and her eyes filled with tears.
She would have given all she possessed to be at home, in her own
room, alone, so that her grief might have full sway. She almost
hoped he would not come back with the ice. She dreaded the
coldness of his regard more than his absence. She—-
"Can I do anything for you, Miss Nesbitt?"
Dr. Darkham stood beside her. It was to Agatha as though he had
risen from the dead. She had supposed him still outside in the
garden. But he had followed her apparently.
"No, thank you," she said, in a voice well kept in order.
"You are not dancing, then?"
"Not for the moment."
"Your partner is Dr. Dillwyn?"
"Yes."
"He was your partner for the last two, I think?"
Agatha roused herself. She looked full at him; there was a smile
upon her beautiful lips.
"Ah, Dr. Darkham, I have already a chaperon!" said she.
"A most inefficient one," said Darkham steadily. "Why should you be
allowed to listen to the solicitations of a mere beggar? Were your
aunt to hear of this—-"
"My aunt!"
Agatha looked up at him, but after that one swift glance drew back.
What was there in his eyes? Oh, horrible! Surely, surely now she
knew that she was not wrong when lately she told herself in
shrinking whispers that this man was in love with her. There had
been something so strange in the expression of his eyes when
looking at her—something so empressé in his manner— something
so downright hateful in the inflection of his voice.
"My aunt is quite capable of looking after me without the
interference of any one," said Agatha slowly. "You have been very
kind to Mrs. Greatorex, but you must not extend your kindness to
me. I want no other guardian but my aunt." She rose and looked
him straight in the face. "Pray do not trouble yourself about my
welfare for the future."
She passed him and went on; she saw Dillwyn coming towards her
with the ice; she had believed she would rather not have seen him
return, but now she went to him gladly.
Darkham fell slowly into the chair she had just left. That girl —her
face, her form—they haunted him. And side by side with hers always
grew another face, another form—that of his wife! What vile fiend
had arranged his marriage? A mere mockery of marriage, where
hatred alone was the link that bound the two.
Gold that had given a false brilliancy to the faded yellow of her hair,
and thrown a gleaming into her light, lustreless eyes. Had he but
waited, had he but relied upon himself and given his undoubted
genius a chance, he might have risen, unaided, to the highest point,
and been now free to marry the woman he loved.
With wild, increasing exultation he remembered how she had risen
to-night out there in the shrubberies as Dillwyn was on the point of
proposing to her. She had cast him off in a sense. Gently, though.
She was always kind and gentle. But she certainly put him off; she
did not care for him, then.
Darkham's face glowed as he sat there in the conservatory.
If this woman to whom he was tied was gone—dead! Then his
chance might come. If she did not care for Dillwyn—why, she might
care for him. At present how could she?
"Why don't you come out and look at her?" said the coarse voice he
dreaded at his ear; "she's dancing with Dillwyn. She dances lovely
—'specially with Dillwyn."
CHAPTER VIII
Mrs. Greatorex was, in a ladylike sort of way, a confirmed gossip. To
have told her so personally would have been to make her your
enemy for life. The way she looked at it was far more Christian—she
said "she took a kindly interest in her neighbours."
To-day her interest was particularly strong, if not very kindly; and
she was now, from the depths of her low lounging chair, catechising
Agatha about the dance last night. She was always very keen about
any news that concerned the Firs-Robinsons, who were really
nobodies, whilst she—-
Her grandfather had been an earl—out-at-elbows, it was true, but
yet an earl. She laid great store by this, and periodically reminded
her acquaintances of it. Her mother, Lady Winifred, had married
(badly from a moneyed point of view) a young and reckless
guardsman, who died three years after her marriage, leaving her all
his debts and an infant daughter. But then he was one of the
Engletons of Derbyshire, and would have come into a baronetcy if
three uncles and five cousins had been removed.
Unfortunately, her husband predeceased his father! And when the
old man (who detested her) followed him to the family vault three
months later, it was found that she was not as much as mentioned in
his will.
There had been no settlements. As there were no children, all the
property went to the second son, Reginald Greatorex.
The sorest subject with Agatha's aunt was this brother-in-law. She
had treated him very cavalierly during her short reign at Medlands,
as wife of the elder son; and when Reginald came in for the property
he remembered it. He portioned her off with as small a dowry as
decency would allow.
He was testy, self-contained old bachelor—and the last of his race—
though with a good point here and there. He had a been good, at all
events, to John Dillwyn, whose father was the rector of his parish,
and whose mother, some said, had been the one love of old
Reginald's life. Both father and mother were dead now, and the
young man, after a fierce struggle for existence in town, had passed
all his exams, and was free to kill or cure, anywhere. It was when he
stood triumphant, but friendless, that Mr. Greatorex had come
forward, and got him his post at Rickton, where the former had a
good deal of property, though Medlands itself lay in an adjoining
county.
Mrs. Greatorex had received the young man coldly. Any one
connected with Reginald must be distasteful to her. To do her
justice, she had never truckled to her brother-in-law in any way, and
had contented herself with undisguised hatred of him. Agatha had
nothing to do with him, she thanked Heaven—otherwise she could
not have supported existence with her. She came from her side of
the house, where people had been officers and—-
"Mrs Darkham looked frightful," said Agatha. "She really did, poor
woman! Fancy, such a gown—red satin and black velvet— and her
face—-"
"As red as the satin, no doubt. But is it possible, Agatha, what you
tell me—that Richard Browne is staying with those people?"
"Those people" were always the Firs-Robinsons with Mrs. Greatorex.
The fact that they could have bought her up a thousand times over
at any moment rankled in her mind. She could not forgive them that.
Still in some queer way she hankered after the Robinsons— desiring
to know this and that about them, and being, as has been hinted, of
a parsimonious turn of mind, did not refrain from accepting from
them fruits and flowers and vegetables. Indeed, face to face with
them she was delightful. She justified herself over this hypocritical
turn, and explained herself to Agatha, by quoting St. Paul. "All things
to all men" was a motto of his.
"Richard?" questioned Agatha, as if surprised. Indeed, Mrs.
Greatorex was perhaps the only person of his acquaintance who
called Mr. Browne "Richard." "Dicky, you mean?"
"Yes, of course. He was christened Richard, Agatha. That ought to
count. His father's name is Richard."
"It is so funny to think of Dicky's having a father," said Agatha,
laughing. "What kind is he, auntie?"
"A mummy! A modern mummy," said Mrs. Greatorex, laying down
her sock. "A dandified mummy. All paint and wig and teeth—-"
"But a mummy! It wouldn't have—-"
"Yes, I know. But there's nothing in him! Nothing that is his own. He
is padded and stuffed and perfumed! He"—indignantly— "ought to
have died ten years ago, and yet now he goes about the world
rejuvenated yearly. Only last month I had a letter from a friend of
mine, saying Richard's father had come back from the German spas
describing himself as 'a giant refreshed.' Just fancy that, at seventy-
eight!"
"I always feel I could love old Mr. Browne," said Agatha, laughing
still.
"You must have precious little to love," said her aunt, knitting
vigorously. She had known old Mr. Browne in her youth.
Agatha's laughter came to a sudden end. She sprang to her feet.
"Here is Edwy Darkham," said Agatha, moving to the window—"and
looking so wild! Aunt Hilda, do come here! Oh!"—anxiously— "surely
there is something wrong with him."
Across the lawn, running uncouthly, hideously—rolling from side to
side—yet with astonishing speed, the idiot came. His huge head was
thrown up, and the beauty that was in his face when it was in
repose was now all gone. He was mouthing horribly, and inarticulate
cries seemed to be bursting from his lips.
Agatha struck by the great terror that so evidently possessed him,
conquered all fear, and springing out of the low French window, ran
to meet him.
At times she shrank from him—not always. Deep pity for him lay
within her heart, because he was so docile, and because he clung to
her so, poor thing! and seemed to find such comfort in her presence.
She had been specially kind in her manner to his mother often
because of him, and perhaps that kindness to her—the mother—
whom the poor, handsome, ill-shapen idiot adored, had been the
first cause of his affection for Agatha. She had always been good to
Edwy, in spite of her detestation of his father, and now, when the
unhappy creature was in such evident trouble—a trouble that
rendered him a thousand times more repulsive than usual—she lost
her fear of him, and ran down the balcony steps to meet him.
He was unhappy—this poor boy, whose soul was but an empty shell!
What ailed him? All her young, strong, gentle heart went out to him.
"Edwy! Edwy!" cried she, as eloquently as though he could hear her.
He rushed to her, and caught her arm, and sank on his knees before
her.
"Sho! Sho! Sho!" he yelled.
It was his one word. To him it meant "mother."
Agatha understood him. She pressed his poor head against her arm.
"What is it? What is it, Edwy?" asked she. There was quick anxiety in
her tone.
Her voice was unheard by him, but his eyes followed hers and the
movement of her lips. Some thread in his weak brain caught at the
meaning of her words. His fingers clutched her and closed upon both
her arms. The pain was excessive, almost beyond bearing, and
Agatha tried to shake herself free. But after a first effort she checked
herself. The agony in the poor boy's face, usually so expressionless,
moved her so powerfully that she stood still, bearing the pain
courageously.
She managed to lay her hand, however, on the large bony one (so
singularly muscular) that was grasping her right arm, and after a
moment or two Edwy relaxed his hold.
"Aunt Hilda," cried Agatha, turning to the window. "What can be the
matter?" But Mrs. Greatorex, who had carefully taken refuge behind
the window curtains, from which safety point she could see without
being seen, declined to leave her shelter to solve the problem
offered her.
"Send him away! send him away!" she screamed dramatically, safe in
the knowledge that the idiot could not hear her. "He is going mad. I
can see it in his eyes. He'll murder you if you encourage him any
further. Get rid of him, Agatha, I implore you, before he does any
mischief."
"Oh no, it isn't that. It is only that he is in terrible distress about
something."
At this moment Edwy rose to his feet, and, approaching her, began
to gesticulate violently and make loud guttural sounds. In vain
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
testbankdeal.com

Java Software Solutions 8th Edition Lewis Test Bank

  • 1.
    Download the fullversion and explore a variety of test banks or solution manuals at https://testbankdeal.com Java Software Solutions 8th Edition Lewis Test Bank _____ Follow the link below to get your download now _____ https://testbankdeal.com/product/java-software- solutions-8th-edition-lewis-test-bank/ Access testbankdeal.com now to download high-quality test banks or solution manuals
  • 2.
    We have selectedsome products that you may be interested in Click the link to download now or visit testbankdeal.com for more options!. Java Software Solutions 8th Edition Lewis Solutions Manual https://testbankdeal.com/product/java-software-solutions-8th-edition- lewis-solutions-manual/ Java Software Solutions 9th Edition Lewis Test Bank https://testbankdeal.com/product/java-software-solutions-9th-edition- lewis-test-bank/ Java Software Solutions 9th Edition Lewis Solutions Manual https://testbankdeal.com/product/java-software-solutions-9th-edition- lewis-solutions-manual/ Illustrated Microsoft Office 365 and Excel 2016 Intermediate 1st Edition Reding Solutions Manual https://testbankdeal.com/product/illustrated-microsoft-office-365-and- excel-2016-intermediate-1st-edition-reding-solutions-manual/
  • 3.
    Intercultural Communication Globalizationand Social Justice 2nd Edition Sorrells Test Bank https://testbankdeal.com/product/intercultural-communication- globalization-and-social-justice-2nd-edition-sorrells-test-bank/ Organizational Behavior 18th Edition Robbins Solutions Manual https://testbankdeal.com/product/organizational-behavior-18th-edition- robbins-solutions-manual/ Business and Administrative Communication 10th Edition Locker Test Bank https://testbankdeal.com/product/business-and-administrative- communication-10th-edition-locker-test-bank/ Business Driven Information Systems 5th Edition Baltzan Test Bank https://testbankdeal.com/product/business-driven-information- systems-5th-edition-baltzan-test-bank/ Plugged In 1st Edition Joel English Test Bank https://testbankdeal.com/product/plugged-in-1st-edition-joel-english- test-bank/
  • 4.
    BUSN Canadian 3rdEdition Kelly Test Bank https://testbankdeal.com/product/busn-canadian-3rd-edition-kelly-test- bank/
  • 5.
    1 Copyright © 2015Pearson Education, Inc. Java Software Solutions, 8e (Lewis/Loftus) Chapter 7 Object-Oriented Design 7.1 Multiple-Choice Questions 1) During program development, software requirements specify A) how the program will accomplish the task B) what the task is that the program must perform C) how to divide the task into subtasks D) how to test the program when it is done E) all of the above Answer: B Explanation: B) The specification phase is to understand the problem at hand so that the programmer can determine what needs to be done to solve the problem. The other efforts listed above are part of the design phase (A, C) and testing phase (D). 2) Once we have implemented the solution, we are not done with the problem because A) the solution may not be the best (most efficient) B) the solution may have errors and need testing and fixing before we are done C) the solution may, at a later date, need revising to handle new specifications D) the solution may, at a later date, need revising because of new programming language features E) all of the above Answer: E Explanation: E) A program should not be considered as a finished product until we are reasonably assured that it is efficient and error-free. Further, it is common that programs require modification in the future because of a change to specifications or a change to the language or computer running the program. 3) Of the various phases in software development, which of the following is usually the lengthiest? A) specification B) design C) implementation D) testing E) maintenance Answer: E Explanation: E) The maintenance phase exists for as long as the software is in use. Software requires modification (such as new requirements such as new features or I/O specifications) and so the maintenance phase is on-going whereas the other phases end once the software has been released and is in use.
  • 6.
    2 Copyright © 2015Pearson Education, Inc. 4) A bad programming habit is to build an initial program and then spend a great deal of time modifying the code until it is acceptable. This is known as A) the prototyping approach B) the waterfall model C) iterative development D) the recursive approach E) the build-and-fix approach Answer: E Explanation: E) Programmers who do not think things through will often build a program that does not fit the original requirements. They then spend an inordinate amount of time trying to repair the program to more properly fit. This is known as "build-and-fix" and is a poor programming practice. 5) The activities of the development cycle are generally thought to A) be strictly linear B) be rigidly ordered C) overlap D) have optional steps E) both A and B are true Answer: C Explanation: C) A flaw of the waterfall model is that it does not permit repetition or backtracking through the development cycle. However, phases often need revisiting resulting in a development cycle where the development activities overlap. 6) The idea of having programmers and developers meet in order to critique a software design or implementation is known as A) an interview B) a walkthrough C) prototyping D) aggregation E) evolutionary development Answer: B Explanation: B) Such meetings are very useful so that the various members can analyze the solution to that point in time and offer suggestions to enhance the design and implementation. This is called a walkthrough because it involves going step-by-step through the proposed or implemented design.
  • 7.
    3 Copyright © 2015Pearson Education, Inc. 7) Modifying a program in order to eliminate deficiencies is done in the ________ phase of the development cycle. A) design B) implementation C) testing D) use E) maintenance Answer: E Explanation: E) While testing is used to find errors, deficiencies are more commonly identified by the users of the system once the system has been released. After such deficiencies have been identified, it is up to the software maintenance group to eliminate them in future versions of the software. 8) It is easier to correct errors found in a program if A) they are identified early in the development cycle B) they are identified during testing C) they are identified during program use D) they are identified during maintenance E) all of the above are equally true, errors are easily corrected in any of these stages Answer: A Explanation: A) Errors introduced early in the development cycle often cause tremendous problems if not caught early on. Therefore, errors found in testing, use or maintenance phases may be too embedded in the systems' design to be easily corrected. But if found early on, the errors can be completely eliminated. 9) In general, spending more time in development to ensure better software will A) shorten testing time B) slightly reduce maintenance efforts C) slightly increase maintenance efforts D) greatly reduce maintenance efforts E) not alter the time it takes for any other stage whatsoever Answer: D Explanation: D) Spending more time in development promises better software, which in turn leads to less maintenance effort.
  • 8.
    4 Copyright © 2015Pearson Education, Inc. 10) The idea that an object can exist separate from the executing program that creates it is called A) transience B) static C) persistence D) serialization E) finality Answer: C Explanation: C) Objects are stored in memory and are reclaimed by the garbage collector when they are no longer referenced. When a Java program terminates, no object is referenced and so all objects are reclaimed. It is desirable, however, to be able to save any given object for future use. This trait is called persistence, and the ability to do this is by saving the instance data of the object to a file. This can be done by writing each instance data to a data file, but is simplified using Object Serialization. 11) In order to create a constant, you would use which of the following Java reserved words? A) private B) static C) int D) final E) class Answer: D Explanation: D) The reserved word final indicates that this is the final value that will be stored in this variable, thus making it unchangeable, or constant. While constants can be of type int, constants can be of any other type as well. It is the final reserved word that makes the value unchangeable. 12) Which of the following methods is a static method? The class in which the method is defined is given in parentheses following the method name. A) equals (String) B) toUpperCase (String) C) sqrt (Math) D) format (DecimalFormat) E) paint (Applet) Answer: C Explanation: C) The Math class defines all of its methods to be static. Invoking Math methods is done by using Math rather than a variable of type Math. The other methods above are not static.
  • 9.
    5 Copyright © 2015Pearson Education, Inc. 13) Static methods cannot A) reference instance data B) reference non-static instance data C) reference other objects D) invoke other static methods E) invoke non-static methods Answer: B Explanation: B) A static method is a method that is part of the class itself, not an instantiated object, and therefore the static method is shared among all instantiated objects of the class. Since the static method is shared, it cannot access non-static instance data because all non-static instance data are specific to instantiated objects. A static method can access static instance data because, like the method, the instance data is shared among all objects of the class. A static method can also access parameters passed to it. 14) An object that refers to part of itself within its own methods can use which of the following reserved words to denote this relationship? A) inner B) i C) private D) this E) static Answer: D Explanation: D) The reserved word this is used so that an object can refer to itself. For instance, if an object has an instance data x, then this.x refers to the object's value x. While this is not necessary, it can be useful if a local variable or parameter is named the same as an instance data. The reserved word this is also used to refer to the class as a whole, for instance, if the class is going to implement an interface class rather than import an implementation of an interface class. 15) An example of an aggregation relationship is A) parent and child B) animal and dog C) teacher and computer D) phone and fax machine E) all of the above Answer: C Explanation: C) An aggregate relationship describes how one object accomplishes a task by using another object. In the above list, the teacher uses the computer. The relationship in A is one of lineage (possibly ownership), in B is an is-a relationship as a dog is a child class of animal, and in D is one of similarity, phone and fax machine might be thought of as sibling classes, related to each other in that they are both children of a more general communication class.
  • 10.
    6 Copyright © 2015Pearson Education, Inc. 16) Inheritance through an extended (derived) class supports which of the following concepts? A) interfaces B) modulary C) information hiding D) code reuse E) correctness Answer: D Explanation: D) By extending a class and inheriting from it, the new class does not have to reimplement any of those inherited methods or instance data, thus saving the programmer an effort. So, code reuse is the ability to reuse someone else's code for your benefit by extending it for your need. 17) Java does not support multiple inheritance, but some of the abilities of multiple inheritance are available by A) importing classes B) implementing interfaces C) overriding parent class methods D) creating aliases E) using public rather than protected or private modifiers Answer: B Explanation: B) Since a class can implement any number of interfaces, that class is in essence using the interface classes as if those interfaces were defined in this class. So, this class is inheriting the methods and constants of the interfaces. Further, the class could extend another class and thus inherit directly and indirectly from multiple classes. This is not the exact same as multiple inheritance, but it is as close as Java comes to that concept. 18) Abstract methods are used when defining A) interface classes B) derived classes C) classes that have no constructor D) arrays E) classes that have no methods Answer: A Explanation: A) An interface is a class that has defined some of its components, but leaves other components (methods) for you to implement. So, these components (methods) are referred to as abstract and defined in the interface class as abstract.
  • 11.
    7 Copyright © 2015Pearson Education, Inc. 19) Which of the following is not a method of the Object class? A) clone B) compareTo C) equals D) toString E) all of the above are methods of the Object class Answer: B Explanation: B) The Object class defines clone to create a copy of any object, equals to determine if two objects are the same object, and toString to translate an Object into a String. However, compareTo is not implement by Object and must be explicitly implemented in any class that wants to implement the Comparable interface. 20) Which of the following interfaces would be used to implement a class that represents a group (or collection) of objects? A) Iterator B) Speaker C) Comparable D) MouseListener E) KeyListener Answer: A Explanation: A) Iterator is an abstract class allowing the user to extend a given class that implements Iterator by using the features defined there. These features include being able to store a group of objects and iterate (step) through them. 21) In order to implement Comparable in a class, what method(s) must be defined in that class? A) equals B) compares C) both lessThan and greaterThan D) compareTo E) both compares and equals Answer: D Explanation: D) The Comparable class requires the definition of a compareTo method that will compare two objects and determine if one is equal to the other, or if one is less than or greater than the other and respond with a negative int, 0 or a positive int. Since compareTo responds with 0 if the two objects are equal, there is no need to also define an equals method. For the questions below, consider a class called ChessPiece. This class has two instance data, String type and int player. The variable type will store "King", "Queen", "Bishop", etc and the int player will store 0 or 1 depending on whose piece it is. We wish to implement Comparable for the ChessPiece class. Assume that, the current ChessPiece is compared to a ChessPiece passed as a parameter. Pieces are ordered as follows: "Pawn" is a lesser piece to a "Knight" and a "Bishop", "Knight" and "Bishop" are equivalent for this example, both are lesser pieces to a "Rook" which is a lesser piece to a "Queen" which is a lesser piece to a "King."
  • 12.
    8 Copyright © 2015Pearson Education, Inc. 22) Which of the following method headers would properly define the method needed to make this class Comparable? A) public boolean comparable(Object cp) B) public int comparable(Object cp) C) public int compareTo(Object cp) D) public int compareTo( ) E) public boolean compareTo(Object cp) Answer: C Explanation: C) To implement Comparable, you must implement a method called compareTo which returns an int. Further, since this class will compare this ChessPiece to another, we would except the other ChessPiece to be passed in as a parameter (although compareTo is defined to accept an Object, not a ChessPiece). 23) Which of the following pieces of logic could be used in the method that implements Comparable? Assume that the method is passed Object a, which is really a ChessPiece. Also assume that ChessPiece has a method called returnType which returns the type of the given piece. Only one of these answers has correct logic. A) if (this.type < a.returnType( )) return -1; B) if (this.type = = a.returnType( )) return 0; C) if (this.type.equals(a.returnType( )) return 0; D) if (a.returnType( ).equals("King")) return -1; E) if (a.returnType( ).equals("Pawn")) return 1; Answer: C Explanation: C) If the type of this piece and of a are the same type, then they are considered equal and the method should return 0 to indicate this. Note that this does not cover the case where this piece is a "Knight" and a is a "Bishop", so additional code would be required for the "equal to" case. The answer in B is not correct because it compares two Strings to see if they are the same String, not the same value. The logic in D and E are incorrect because neither of these takes into account what the current piece is, only what the parameter's type is. In D, if a is a "King", it will be greater than this piece if this piece is not a "King", but will be equal if this piece is a "King" and similarly in E, it does not consider if this piece is a "Pawn" or not. Finally, A would give a syntax error because two Strings cannot be compared using the "<" operator. 24) Which of the following would not be considered an algorithm? A) a recipe B) a computer program C) pseudocode D) a shopping list E) travel directions Answer: D Explanation: D) An algorithm is a step-by-step description of how to solve a problem, written at some level of specificity. The recipe and probably the pseudocode are written at a "high level" whereas a program and perhaps travel directions are written in more detail. A shopping list is not a step-by-step description, so it would not qualify as an algorithm.
  • 13.
    9 Copyright © 2015Pearson Education, Inc. 25) It is important to dissect a problem into manageable pieces before trying to solve the problem because A) most problems are too complex to be solved as a single, large activity B) most problems are solved by multiple people and it is easy to assign each piece to a separate person C) it is easier to integrate small pieces of a program into one program than it is to integrate one big chunk of code into one program D) our first solution may not solve the problem correctly E) all of the above Answer: A Explanation: A) Any interesting problem will be too complex to solve easily as a single activity. By decomposing the problem, we can build small solutions to each piece and then integrate the pieces. Answer D is true, but does is not the reason why we will break a problem down into pieces. 26) Having multiple class methods of the same name where each method has a different number of or type of parameters is known as A) encapsulation B) information hiding C) tokenizing D) importing E) method overloading Answer: E Explanation: E) When methods share the same name, they are said to be overloaded. The number and type of parameters passed in the message provides the information by which the proper method is called. 27) The goal of testing is to A) ensure that the software has no errors B) find syntax errors C) find logical and run-time errors D) evaluate how well the software meets the original requirements E) give out-of-work programmers something to do Answer: C Explanation: C) Testing is required because all software will have errors. Complex systems especially need testing before they can be released. The types of errors sought are logical errors and run-time errors. All syntax errors will have been identified and fixed during implementation.
  • 14.
    10 Copyright © 2015Pearson Education, Inc. 28) Arranging components in a GUI container is accomplished by using which of the following? A) Layout manager B) Listener interface C) String array D) Event generator E) JComboBox Answer: A Explanation: A) There are several classes of Layout managers. A Layout manager is used to add GUI components to the container in some manner. The type of Layout manager determines how items are added. 29) Which Layout Manager type would you use if you want GUI components to be placed at the North, South, East, West and Center of the container? A) FlowLayout B) BorderLayout C) BoxLayout D) GridLayout E) TabbedPane Answer: B Explanation: B) The BorderLayout specifically allows you to specify the component's location as one of NORTH, SOUTH, EAST, WEST or CENTER where the value (e.g., NORTH) is a constant predefined in the class. 30) Which Layout Manager type would you use if you want GUI components to be placed in 2 columns over 5 rows? A) FlowLayout B) BorderLayout C) BoxLayout D) GridLayout E) TabbedPane Answer: D Explanation: D) The GridLayout manager allows you to specify the number of rows and columns and then add elements across the column on one row until it is filled, and then on to the next row, until all of the rows are filled. 31) Which Layout Manager is used by default if you do not specify a Layout Manager for your GUI container? A) FlowLayout B) BorderLayout C) BoxLayout D) GridLayout E) TabbedPane Answer: A Explanation: A) The FlowLayout is the default manager. It places GUI items across in one row only. Other Layout Managers are more sophisticated and lead to better designed containers. 32) Which of the following GUI classes requires that it have a LayoutManager before any GUI
  • 15.
    11 Copyright © 2015Pearson Education, Inc. components are added to it? A) JButton B) JSlider C) JPanel D) JFrame E) both C and D but not A or B Answer: C Explanation: C) The JPanel requires adding a LayoutManager to it before any components are added to it. This allows the components added to be arranged on the JPanel as desired. Neither the JButton nor JSlider have components added to them and so do not require a LayoutManager. The JFrame does not use a LayoutManager but instead adds elements through getContentPane( ). 33) In using the BoxLayout, adding space between components in a container can be accomplished by A) including TabbedPanes B) including JButtons that have no names and thus will appear invisible C) adding invisible components D) inserting IconImages of blank images E) any of the above Answer: C Explanation: C) The BoxLayout manager allows for the inclusion of specially designated "invisible" components to take up space between real components and thus provide spacing. 34) In order to display three components vertically in a container, you could use all but which of the following layout managers? A) FlowLayout B) BoxLayout C) GridLayout D) BorderLayout E) you could use any of the above Answer: A Explanation: A) FlowLayout puts components horizontally and you cannot change that. BoxLayout can place items horizontally or vertically. GridLayout allows you to specify the number of rows and columns and to place the three components vertically, you would use (3, 1) that is, 3 rows, 1 column. BorderLayout can place three components vertically by placing them in the NORTH, CENTER and SOUTH positions.
  • 16.
    12 Copyright © 2015Pearson Education, Inc. 35) What is wrong with the following message to create a BoxLayout for the JPanel jp? jp.setLayout(new BoxLayout(BoxLayout.X_AXIS)); A) X_AXIS is not a valid constant for BoxLayout, it should instead be HORIZONTAL B) Aside from X_AXIS, the constructor also requires a Dimension to determine the size of the Box C) Aside from X_AXIS, the constructor also needs a command regarding horizontal glue as in createHorizontalGlue( ) D) The BoxLayout constructor is lacking a reference to the container that the BoxLayout manager will govern E) There is nothing wrong with it at all Answer: D Explanation: D) The BoxLayout manager constructor requires two parameters, a reference to the container that the manager will govern, and an axis for the layout, (vertical or horizontal) as specified by either X_AXIS or Y_AXIS. 36) In which phase of program development would you expect the programmer(s) to create the pseudocode? A) Software requirements B) Software design C) Software implementation D) Software testing E) Could occur in any of the above Answer: B Explanation: B) Pseudocode is a description of an algorithm written in an English-like way rather than in a specific programming language. This is part of the program's design. In the implementation phase, the programmer(s) translates the pseudocode into the programming language being used. 37) Which of the following is considered a top-level container? A) Panel B) Frame C) Box D) Layout Manager E) A, B, and C Answer: B Explanation: B) While the answers in A, B and C are all types of containers, the Box and Panel are made available to contain other components and are themselves placed into other containers. The Frame is a top-level container because a Frame will not store other Frames, but instead, the Frame contains Panels which can contain Boxes, Panels and other components.
  • 17.
    13 Copyright © 2015Pearson Education, Inc. 38) The JFrame below has a JBorder created using which of the following BorderFactory formats? A) TitledBorder B) MatteBorder C) EtchedBorder D) RaisedBevelBorder E) LoweredBevelBorder Answer: D Explanation: D) The JFrame has a Bevel border which is raised. A TitledBorder has a title running along the top of it. The MatteBorder is of a Color or contains an image of some kind. The EtchedBorder is not raised, and the LoweredBevelBorder is lowered, not raised. 39) To take 2 borders and use one as an outer border and the other as an inner border, you would create a A) compound border B) nested border C) split border D) border factory E) matte border Answer: A Explanation: A) The compound border comprises two borders that are combined together, one border being the outside border and the other being the inside border. 40) In which phase of program development would you expect the programmer(s) to determine the classes and objects needed? A) software requirements B) software design C) software implementation D) software testing E) could occur in any of the above Answer: B Explanation: B) Determining which classes and objects to use or create is part of the design.
  • 18.
    14 Copyright © 2015Pearson Education, Inc. 41) If a programmer follows the four phases of program development as intended, which of the four phases should require the least amount of creativity? A) software requirements B) software design C) software implementation D) software testing E) none of the above, all four levels would require equal creativity Answer: C Explanation: C) Once the implementation phase has been reached, the algorithm should have already been specified, so the only effort involved in the implementation phase is of translating from the design (which is probably in an English-like pseudocode) to the programming language, and entering the code through an editor. The requirements and design phases require understanding the problem and coming up with a solution respectively, requiring creativity, and the testing phase will require diagnostic abilities usually forcing the programmer(s) to be creative in how the errors are found and fixed. 7.2 True/False Questions 1) The most important decisions regarding the development of a system are made during the implementation phase while code is actively being written. Answer: FALSE Explanation: All of the important decisions should be made during earlier phases of development, particularly during the design phase. By the time the implementation phase is reached, the entire system design should be available and this phase should only entail translating the design into code. 2) Unlike the String class where you must pass a message to an object (instance) of the class, as in x.length( ), in order to use the Math class, you pass messages directly to the class name, as in Math.abs( ) or Math.sqrt( ). Answer: TRUE Explanation: The Math class uses methods known as static methods (or class methods) which are invoked by passing a message directly to the class name itself rather than to an object of the class. 3) Assume that the class Bird has a static method fly( ). If b is a Bird, then to invoke fly, you could do Bird.fly( );. Answer: TRUE Explanation: Static methods are invoked through the class and not an object of the class. This is because the static method is shared among all instances. So, Bird.fly( ); will invoke fly. It should be noted that fly can also be invoked through b, so b.fly( ); will also work. 4) Interface classes cannot be extended but classes that implement interfaces can be extended. Answer: FALSE Explanation: Any class can be extended whether it is an interface, implements an interface, or neither. The only exception to this is if the class is explicitly modified with the word "final" in which case it cannot be extended.
  • 19.
    15 Copyright © 2015Pearson Education, Inc. 5) If classes C1 and C2 both implement an interface Cint, which has a method whichIsIt, and if C1 c = new C1( ); is performed at one point of the program, then a later instruction c.whichIsIt( ); will invoke the whichIsIt method defined in C1. Answer: FALSE Explanation: Because C1 and C2 implement the same interface, they both implement whichIsIt. The variable c is known as a polymorphic variable, meaning that it can change from being an C1 to a C2. So, the message c.whichIsIt( ); may invoke C1's whichIsIt or C2's whichIsIt. There is no way to tell until run-time. 6) Any class can implement an interface, but no classes can implement more than a single interface. Answer: FALSE Explanation: Classes can implement any number of interfaces, 0, 1, or more. 7) All objects implement Comparable. Answer: FALSE Explanation: Comparable is an interface, and the class must define the compareTo method and explicitly state that it implements Comparable to be considered an implementation of Comparable. Most classes do not implement Comparable. 8) Formal parameters are those that appear in the method call and actual parameters are those that appear in the method header. Answer: FALSE Explanation: The question has the two definitions reversed. Formal parameters are those that appear in the method header, actual parameters are the parameters in the method call (those being passed to the method). 9) Defining formal parameters requires including each parameters type. Answer: TRUE Explanation: In order for the compiler to check to see if a method call is correct, the compiler needs to know the types for the parameters being passed. Therefore, all formal parameters (those defined in the method header) must include their type. This is one element that makes Java a Strongly Typed language. 10) It is not possible to test out any single method or class of a system until the entire system has been developed, and so all testing is postponed until after the implementation phase. Answer: FALSE Explanation: While it is true that testing occurs after implementation, some testing can take place during implementation. In Java, it is possible to test out single methods or classes by creating stubs of other methods and classes that are simple placeholders. For instance, if one method calls another method and the second method is not yet written, a stub of the second method can be written that simply returns a value that would normally be expected so that the first method can be tested.
  • 20.
    16 Copyright © 2015Pearson Education, Inc. 11) All parts of a container in BorderLayout must be used. Answer: FALSE Explanation: BorderLayout allows components to be inserted in any of North, South, East, West and Center of the GUI, but as many or as few of these five sections can be used as needed. 12) A JPanel can itself contain JPanels. Answer: TRUE Explanation: It is common to place GUI components into a JPanel and then place several JPanels into another JPanel. Each JPanel has its own layout manager allowing the programmer to specify in detail how components should appear. For instance, one JPanel might use a GridLayout and another a BoxLayout and then the two JPanels be placed in the NORTH and EAST sections of a JPanel using BorderLayout. 13) If a GUI container is resized by the user, all components of the GUI are automatically increased or decreased by the same fraction to fit in the newly sized container. Answer: FALSE Explanation: The layout manager will reposition the GUI items to fit in the newly sized container. 14) The size and shape of a GUI container is based on the layout manager selected and the type and number of items added to the container. Answer: TRUE Explanation: It is the layout manager's task to arrange the components in the container. Based on the order that the items are entered and the type of layout manager, the size and shape are determined. 15) A border can be put around any Swing component with the exception of a JButton and JScrollPane component. Answer: FALSE Explanation: A border can be up around any Swing component no matter the type. 16) The term "test case" is used to express a set of inputs (or user actions) and the expected outputs to be used in testing out software. Answer: TRUE Explanation: In order to test software to see if it is working correctly, a tester will often start with a series of inputs and the expected outputs. If, when running the program on the inputs, the outputs are not the expected results, then errors are assumed to exist. These input/output pairs are known as test cases.
  • 21.
    17 Copyright © 2015Pearson Education, Inc. 17) In black-box testing, the tester should already know something about how the program is implemented so that he/she can more carefully identify what portion(s) of the software are leading to errors. Answer: FALSE Explanation: In black-box testing, the tester should know nothing about how the software is implemented. In essence, the software is a black-box which has an input and an output and the mechanisms of the program are opaque. If the tester does know something about how the program works, then the tester's test cases might be biased. If the tester knows how the program works, then testing is known as glass-box testing. 7.3 Free-Form Questions 1) Provide a reason why an instance data would be declared static. Answer: If an instance data is to be shared among all objects of the class, the instance data would be static. As an example, an instance data that counts the number of times something has happened across all objects of the class would be made static. If we are writing a chess game and have a ChessPiece class that includes a method called movePiece, we would want to know how many moves a player has made, but not necessarily how many times a single piece has been moved. So, all of the ChessPieces share a numberOfTimesMoved instance data that is incremented by any ChessPiece whenever it is moved. 2) Provide a reason why a method would be declared static. Answer: A method is declared static if it might be used, not by the current object, but by any objects of the class. That is, the method does not require access to any single object's instance data. Consider a class called Point that consists of an x and y coordinate. To determine the distance between two Points, we could make a static computeDistance method. It is passed two Points as parameters and computes the distance. Another example is the Keyboard class from the textbook, which does not itself have any instance data. 3) Write a static method that is passed two ChessPieces and determines if the two pieces are owned by the same player. It should return true or false. Answer: public static boolean samePlayer(ChessPiece p1, ChessPiece p2) { return (p1.returnPlayer( ) = = p2.returnPlayer( )); } 4) Explain the difference between implementing an interface and a derived class. Answer: Implementing an interface means that you are adding to your class any mechanisms defined in an abstract class. Your class essentially is expanded to contain those items defined in the interface class but you have to implement any of those items that are abstract. The appeal is that other objects might call upon your class to use the interface methods without knowing anything else about your class. The derived class is similar in that you are gaining items previously defined, although in this case, those items are defined in the parent class (as long as those items are protected or public) and you do not have to implement any of them unless you want to redefine them. One difference between the two is that the interface cannot be instantiated directly. Another difference is that your class "inherits" abstract methods from the interface class as opposed to implemented methods from a super class.
  • 22.
    18 Copyright © 2015Pearson Education, Inc. 5) Define an interface class that contains two int constants, X = 5 and Y = 10 and one int method called useXY which receives no parameters. Call your interface class XYClass Answer: public interface XYClass { public final int X = 5; public final int Y = 10; public int useXY( ); } 6) Assume a class Foo implements Comparable. Without knowing anything else about the Foo class, write an equal method that returns true if the Foo parameter passed to this Foo is equal to this Foo as determined by using the implementation of Comparable. Answer: public boolean equals(Foo a) { if(compareTo(a)) = = 0) return true; else return false; }
  • 23.
    19 Copyright © 2015Pearson Education, Inc. 7) To implement Comparable for the ChessPiece class, the current ChessPiece's type is compared to a ChessPiece passed as a parameter. The method should return 0 if the types are equal, -1 if this piece's type is a lesser piece than the parameter's type, and 1 if this piece's type is a greater piece than the parameter's type. Pieces are ordered as follows: "Pawn" is a lesser piece to a "Knight" and a "Bishop", "Knight" and "Bishop" are equivalent for this example, both are lesser pieces to a "Rook" which is a lesser piece to a "Queen" which is a lesser piece to a "King." Write the proper method to implement Comparable for this class. Answer: public int compareTo(ChessPiece a) { if (this.type.equals(a.returnType( )) | | (this.type.equals("Knight") && a.returnType( ).equals("Bishop")) | | (this.type.equals("Bishop") && a.returnType( ).equals("Knight"))) return 0; else if (this.type.equals("King")) return 1; else if (a.returnType( ).equals("King")) return-1; else if (this.type.equals("Queen")) return 1; else if (a.returnType( ).equals("Queen")) return -1; else if (this.type.equals("Rook")) return 1; else if (a.returnType( ).equals("Rook")) return -1; else if (this.type.equals("Knight") | | (this.type.equals("Bishop")) return 1; else if (a.returnType( ).equals("Knight") | | (a.returnType( ).equals("Bishop")) return -1; } 8) Why was the Y2K problem a problem of software maintenance and not a problem of software testing? Answer: The Y2K problem was caused by older software that stored the year as a 2-digit value instead of a 4-digit value (older software attempted to save memory space in any way possible, this was a common way to save 2 bytes). Since the 2-digit year was not a logical or run-time error, but instead, a flaw in the design, this problem was not detected during software testing. Instead, it was not until the late 1990s, when people began to realize that a 2-digit year would cause a problem starting in 2000, that the Y2K problem was identified and solutions sought, so the problem was one of software maintenance how to maintain this older software so that it still functions starting in the year 2000.
  • 24.
    20 Copyright © 2015Pearson Education, Inc. 9) In what way is black-box testing better than glass-box testing? In what way is glass-box testing better than black-box testing? Answer: Black-box testing is superior because the tester knows nothing of the software and so will test the software without preconceived ideas of where errors might exist. The tester is testing the software blindly, much as a user will use the software–without intimate knowledge of how the software works. The result should be that if errors exist that a user might stumble across, the tester should find them. While black-box testing of software has the advantage that the tester operates much like the users are expected to, the disadvantage is that it is a blind test and knowledge of how the software functions could be useful. If programmers suspect that some awkward or difficult implementation may be buggy, then spending more time testing that portion of the software is advantageous. This form of testing requires knowledge of how the software works. So, both black-box and glass-box testing have their own advantages and disadvantages. 10) Write a set of code that will allow a user to select an input image and then place this image in a JLabel lab1 and add lab1 to a JPanel as the northern component in a JFrame using BorderLayout. The JFrame has already been instantiated as jf and the BorderLayout already established. Hint: a JFileChooser returns a File and JLabel requires the String name of a file as an argument. A File can return its name using File class' method getAbsolutePath( ) Answer: JFileChooser jfc = new JFileChooser( ); jfc.showOpenDialog(null); File f = jfc.getSelectedFile( ); ImageIcon im = new ImageIcon(f. getAbsoluteFile( )); JLabel lab1 = new JLabel(im); jp.add(lab1, BorderLayout.NORTH); jf.getContentPane( ).add(jp); jf.pack( ); jf.setVisible(true);
  • 25.
    21 Copyright © 2015Pearson Education, Inc. 11) Write code to create a JPanel with 4 JCheckBox GUI components and two JLabels for output, one that says "Current cost is" and the other that outputs the computed cost based on which of the food items has been selected. Answer: FoodListener fl = new FoodListener( ); JPanel jp = new JPanel(new GridLayout(3, 2)); jcb1 = new JCheckBox("Burger"); jcb2 = new JCheckBox("Fries"); jcb3 = new JCheckBox("Soda"); jcb4 = new JCheckBox("Cookie"); jcb1.addItemListener(fl); jcb2.addItemListener(fl); jcb3.addItemListener(fl); jcb4.addItemListener(fl); jl1 = new JLabel("Current cost is"); jl2 = new JLabel(" "); jp.add(jcb1); jp.add(jcb2); jp.add(jcb3); jp.add(jcb4); jp.add(jl1) jpadd(jl2); add(jp);
  • 26.
    22 Copyright © 2015Pearson Education, Inc. 12) Provide code to generate the following JFrame. Each lettered item is a JButton. Hint: Create several JPanels, each one having two or more JButtons and taken up a portion of the JFrame. Answer: JFrame jf = new JFrame( ); JPanel jp1 = new JPanel(new BorderLayout( )); JPanel jp2 = new JPanel(new FlowLayout( )); JPanel jp3 = new JPanel(new GridLayout(2, 3)); JButton lab1 = new JButton("A"); JButton lab2 = new JButton("B"); JButton lab3 = new JButton("C"); JButton lab4 = new JButton("D"); JButton lab5 = new JButton("E"); JButton lab6 = new JButton("F"); JButton lab7 = new JButton("G"); JButton lab8 = new JButton("H"); JButton lab9 = new JButton("I"); JButton lab10 = new JButton("J"); JButton lab11 = new JButton("K"); JButton lab12 = new JButton("L"); JButton lab13 = new JButton("M"); jp1.add(lab1, BorderLayout.NORTH); jp1.add(lab2, BorderLayout.WEST); jp1.add(lab3, BorderLayout.CENTER); jp1.add(lab4, BorderLayout.EAST); jp1.add(lab5, BorderLayout.SOUTH); jp2.add(lab6); jp2.add(lab7); jp3.add(lab8); jp3.add(lab9); jp3.add(lab10); jp3.add(lab11);
  • 27.
    23 Copyright © 2015Pearson Education, Inc. jp3.add(lab12); jp3.add(lab13); JPanel jp4 = new JPanel(new GridLayout(3, 1)); jp4.add(jp1); jp4.add(jp2); jp4.add(jp3); jf.getContentPane( ).add(jp4); jf.pack( ); jf.setVisible(true);
  • 28.
    24 Copyright © 2015Pearson Education, Inc. 13) Provide code to generate the following JFrame. Each lettered item is a JButton. Hint: Create several JPanels, each one having two or more JButtons and taken up a portion of the JFrame. Answer: JFrame jf = new JFrame( ); JPanel jp1 = new JPanel(new GridLayout(1, 3)); JPanel jp2 = new JPanel(new GridLayout(3, 1)); JPanel jp3 = new JPanel(new GridLayout(3, 1)); JPanel jp4 = new JPanel(new GridLayout(1, 3)); JPanel jp5 = new JPanel(new BorderLayout( )); JButton lab1 = new JButton("A"); JButton lab2 = new JButton("B"); JButton lab3 = new JButton("C"); JButton lab4 = new JButton("D"); JButton lab5 = new JButton("E"); JButton lab6 = new JButton("F"); JButton lab7 = new JButton("G"); JButton lab8 = new JButton("H"); JButton lab9 = new JButton("I"); JButton lab10 = new JButton("J"); JButton lab11 = new JButton("K"); JButton lab12 = new JButton("L"); JButton lab13 = new JButton("M"); jp1.add(lab1); jp1.add(lab2); jp1.add(lab3); jp2.add(lab4); jp2.add(lab5); jp2.add(lab6); jp3.add(lab7); jp3.add(lab8); jp3.add(lab9); jp4.add(lab11); jp4.add(lab12); jp4.add(lab13); jp5.add(jp1, BorderLayout.NORTH); jp5.add(jp2, BorderLayout.WEST); jp5.add(lab10, BorderLayout.CENTER);
  • 29.
    25 Copyright © 2015Pearson Education, Inc. jp5.add(jp3, BorderLayout.EAST); jp5.add(jp4, BorderLayout.SOUTH); jf.getContentPane( ).add(jp5); jf.pack( ); jf.setVisible(true); 14) Provide code to generate the following JFrame. Each lettered item is a JButton. Hint: Create several JPanels, each one having two or more JButtons and taken up a portion of the JFrame. Answer: JFrame jf = new JFrame( ); JPanel jp1 = new JPanel(new GridLayout(2, 2)); JPanel jp2 = new JPanel(new GridLayout(2, 2)); JPanel jp3 = new JPanel(new FlowLayout( )); JPanel jp4 = new JPanel(new BorderLayout( )); JPanel jp5 = new JPanel(new GridLayout(2, 2)); JButton lab1 = new JButton("A"); JButton lab2 = new JButton("B"); JButton lab3 = new JButton("C"); JButton lab4 = new JButton("D"); JButton lab5 = new JButton("E"); JButton lab6 = new JButton("F"); JButton lab7 = new JButton("G"); JButton lab8 = new JButton("H"); JButton lab9 = new JButton("I"); JButton lab10 = new JButton("J"); JButton lab11 = new JButton("K"); JButton lab12 = new JButton("L"); JButton lab13 = new JButton("M"); JButton lab14 = new JButton("N"); JButton lab15 = new JButton("O"); JButton lab16 = new JButton("P"); jp1.add(lab1); jp1.add(lab2); jp1.add(lab3);
  • 30.
    26 Copyright © 2015Pearson Education, Inc. jp1.add(lab4); jp2.add(lab5); jp2.add(lab6); jp2.add(lab7); jp2.add(lab8); jp3.add(lab9); jp3.add(lab10); jp3.add(lab11); jp4.add(lab12, BorderLayout.WEST); jp4.add(lab13, BorderLayout.NORTH); jp4.add(lab14, BorderLayout.CENTER); jp4.add(lab15, BorderLayout.EAST); jp4.add(lab16, BorderLayout.SOUTH); jp5.add(jp1); jp5.add(jp2); jp5.add(jp3); jp5.add(jp4); jf.getContentPane( ).add(jp5); jf.pack( ); jf.setVisible(true);
  • 31.
    27 Copyright © 2015Pearson Education, Inc. 15) Draw the JFrame as you think it would appear given the following set of code: JButton jb1 = new JButton("A"); JButton jb2 = new JButton("B"); JButton jb3 = new JButton("C"); JButton jb4 = new JButton("D"); JButton jb5 = new JButton("E"); JButton jb6 = new JButton("F"); JButton jb7 = new JButton("G"); JButton jb8 = new JButton("H"); JButton jb9 = new JButton("I"); JButton jb10 = new JButton("J"); JButton jb11 = new JButton("K"); JButton jb12 = new JButton("L"); JPanel jp1 = new JPanel( ); jp1.add(jb1); jp1.add(jb2); jp1.add(jb3); jp1.add(jb4); JPanel jp2 = new JPanel(new GridLayout(4, 1)); jp2.add(jb5); jp2.add(jb6); jp2.add(jb7); jp2.add(jb8); JPanel jp3 = new JPanel(new GridLayout(2, 2)); jp3.add(jb9); jp3.add(jb10); jp3.add(jb11); jp3.add(jb12); JPanel jp4 = new JPanel(new BorderLayout( )); jp4.add(jp1, BorderLayout.NORTH); jp4.add(jp2, BorderLayout.EAST); jp4.add(jp3, BorderLayout.WEST); JFrame jf = new JFrame( ); jf.getContentPane( ).add(jp4); jf.pack( ); jf.setVisible(true);
  • 32.
    28 Copyright © 2015Pearson Education, Inc. Answer: 16) Draw the JFrame as you think it would appear given the following set of code: JButton jb1 = new JButton("A"); JButton jb2 = new JButton("B"); JButton jb3 = new JButton("C"); JButton jb4 = new JButton("D"); JButton jb5 = new JButton("E"); JButton jb6 = new JButton("F"); JButton jb7 = new JButton("G"); JPanel jp1 = new JPanel(new GridLayout(3, 3)); jp1.add(jb1); jp1.add(jb2); jp1.add(jb3); jp1.add(jb4); jp1.add(jb5); jp1.add(jb6); jp1.add(jb7); JFrame jf = new JFrame( ); jf.getContentPane( ).add(jp1); jf.pack( ); jf.setVisible(true); Answer:
  • 33.
    29 Copyright © 2015Pearson Education, Inc. 17) Draw the JFrame as you think it would appear given the following set of code: JButton jb1 = new JButton("A"); JButton jb2 = new JButton("B"); JButton jb3 = new JButton("C"); JButton jb4 = new JButton("D"); JButton jb5 = new JButton("E"); JButton jb6 = new JButton("F"); JButton jb7 = new JButton("G"); JButton jb8 = new JButton("H"); JButton jb9 = new JButton("I"); JPanel jp1 = new JPanel(new BorderLayout( )); jp1.add(jb1, BorderLayout.NORTH); jp1.add(jb2, BorderLayout.WEST); jp1.add(jb3, BorderLayout.EAST); JPanel jp2 = new JPanel(new BorderLayout( )); jp2.add(jb4, BorderLayout.WEST); jp2.add(jb5, BorderLayout.SOUTH); jp2.add(jb6, BorderLayout.EAST); JPanel jp3 = new JPanel(new BorderLayout( )); jp3.add(jb7, BorderLayout.WEST); jp3.add(jb8, BorderLayout.NORTH); jp3.add(jb9, BorderLayout.EAST); JPanel jp4 = new JPanel(new BorderLayout( )); jp4.add(jp1, BorderLayout.NORTH); jp4.add(jp2, BorderLayout.EAST); jp4.add(jp3, BorderLayout.SOUTH); JFrame jf = new JFrame( ); jf.getContentPane( ).add(jp4); jf.pack( ); jf.setVisible(true ); Answer:
  • 34.
    30 Copyright © 2015Pearson Education, Inc. 18) Why should the add( ), subtract( ), multiply( ), divide( ) methods in the RationalNumber class in the textbook be declared to be public, while the gcd( ) method is declared to be private? Answer: The numeric operations must be public because they must be accessible to users of the RationalNumber class. Declaring them private or protected don't accomplish this. The gcd( ) method is declared private because it is a "utility" method within the class. It should only be used by class members because it has access to the internal structure of the class. One might want to declare a static gcd( ) method one that just accepts a pair of ints, or longs, or whatever. This static method would be similar to those in the Math class, like abs( ), sqrt( ), max( ), etc.
  • 35.
    Other documents randomlyhave different content
  • 36.
    "Do you knowwho has come to-night to stay with us for a month? Dicky—Dicky Browne. He met auntie and me last season in town. And auntie asked him to run down to us for a bit. He's a nuisance, certainly," shrugging her shoulders. "We all know that, in spite of everything; but I do love Dicky more than any one else, I think." "I wish I could believe that," said Agatha, in a low tone. Lord Ambert was standing near, waiting for Elfrida. "Better love him than—-" "Pouf! What a suggestion! Why should I love any one?" Elfrida's piquant face was now alight with mischief. "Do you think I am such a one as thyself? I tell you, Agatha, that I, for one, have no heart! I can't afford one." "I should think you could afford anything," said Agatha. "You could, at all events, afford to marry the man who loved you." "And where does he live?" asked Elfrida, laughing. "You know," said Agatha slowly, earnestly. "You're lovely; you're a perfect delight!" said Miss Firs-Robinson, her amusement now growing more apparent; "but really I don't. I know only that I—want to be—-" "Happy?" said Agatha, answering. "No; a countess," said the pretty little fairy, with a gay grimace. She looked over Agatha's shoulder and beckoned to Lord Ambert, who was still "in waiting," to come to her. He came. A middle-sized, well-set-up man of about forty, with a rather supercilious mouth and small eyes. He looked quite a gentleman, however; which a great many earls do not, and, of course, there he scored. He was a poor man for his rank in life, and was desirous of impounding the numerous thousands in which Miss Firs-Robinson lay, as it were, enwrapped. He never forgot his dignity,
  • 37.
    however, when withher. He gave her quite to understand that she was by birth many degrees below zero, and that he was a star in her firmament. In the meantime Elfrida, who had a very acute mind of her own, saw straight through him. In a sense he amused her, and, after all, she knew very well who would be mistress and master after her marriage with him. Not Ambert, anyway. Her money should be securely settled on herself; she was quite decided about that. She was quite decided also about her marriage with him. She had lived some little time in America, as has been said, and had learned the value of our English lords; so she had arranged with herself very early in life never to die until she could have a title carved upon her tombstone. Ambert had come in quite handy. He was the only unmarried earl within a radius of a tremendous number of miles, so, of course, he would have to do. It was a pity he was so old—that he was a little bald—that his expression was so unpleasant. But he was an earl. She would be Lady Ambert; and if he thought he would have it all his own way afterwards—why, she would show him. She hadn't the least doubt about his proposing to her. She gave herself no trouble on that head; and, indeed, she used to know great mirth sometimes, when he had been specially laborious over his efforts to prove to her that he had twenty or forty heiresses in his eye, who would all be ready at a moment's notice to accept his title, his debts, and his bald head. For all that, she was determined to marry him. This, however, did not prevent her indulging in small flirtations here and there. There were several young officers in the barracks in the next town who were literally at her feet, and there was the curate, Tom Blount, who every one knew was a very slave to her every caprice. "Ah, Mr. Blount," said she, as she passed him now on her way to the conservatory. "Here? And you haven't asked me for a single dance."
  • 38.
    "I don't dance,"said Tom Blount. "The bishop doesn't like it, you know, and to ask you to sit out a dance with me would be more than I dare venture." He smiled at her out of two honest blue eyes. And she smiled back at him out of two very dishonest ones, though all four were much of the same colour. "'If thy heart fail thee,'" quoted she daringly. "Well, I shan't let it fail me," said the curate suddenly. His smile was somewhat forced, however. "Will you sit out one with me?" "You don't deserve it," said she. "But—-" Here Lord Ambert bent and whispered something into her ear. He was evidently urging her to refuse the insolent request of this nobody, this curate of a small country parish. But his words took no effect. Elfrida listened to them, nodded and smiled as if acquiescing, and then—- "The fourteenth is a quadrille, for the sake of appeasing old Lady Saunders, I believe," said she, looking at the curate. "Will you have that dance—to sit it out with me?" "Won't I!" said the curate enthusiastically, who had not long left Oxford, and who was wonderfully young in many ways. "You promised that quadrille to me," said Ambert, frowning. "Yes, I know. But as I never dance quadrilles—-" She paused and looked up at Ambert. "You see?" "No, I don't," said he. "Well I am sure Mr. Blount does," said Elfrida audaciously. "Now, remember, Mr. Blount, the fourteenth is ours."
  • 39.
    Lord Ambert lookedat him. Really the audacity of this contemptible curate passed comprehension. To speak so to her, his—Ambert's—future wife. He frowned and bit his lip. That was the worst of marrying into the middle classes; they never know how to keep those beneath them in order. Lord Ambert, holding her hand during her descent from the steps to the garden beneath, ventured a cold remonstrance. "Is it wise of you—you will pardon, I hope, my interference— but is it wise of you to be so kind to a person of that sort?" "A person? Is he a person?" asked Miss Firs-Robinson with much airy astonishment. "I quite understood he was a man of good family. Whereas a 'person' must be of no family whatever." "If without money," put in Lord Ambert quickly, "quite so. There are, of course, grades." "Grades?" "Yes. A man of no birth with money is not the same as a man of no birth without it. For money educates, refines, elevates." This he pointed with little emphases, as a small hint to her. "And a man of birth without money?" "Sinks." Here Lord Ambert's voice took even a lower tone. "Sinks until he meets the extreme—that is, the lowest of all classes—with which he unites. I am afraid that young man you have just been talking to will come to that end. His people, I believe, were in a decent set at one time; but there is no money there now, and probably he will marry his landlady's daughter, or the young woman who manages the school in the village, and— repent it soon after."
  • 40.
    "Repentance is goodfor the soul," said Elfrida; she laughed. "But as you show it, money is everything. Even the 'person' can be raised by it." "It is sad of course, but I am afraid that is really the case. In these days money is of great importance—of nearly as great importance as birth or position. It lifts the 'person,' as you call it—-" "Has it, then, lifted me?" "Dear Miss Firs-Robinson! What a question! Surely you do not consider yourself part of this discussion?" He, however, had considered her so, and had taken pleasure in the argument that had laid her low. This was part of what he called his "training" of her! "You—who are a thing apart, a thing most precious—-" "I don't want to be a 'thing,' however precious," said Miss Firs- Robinson, with decision. "I should much rather be a 'person,' for choice, however criminal it sounds. It only wants 'age' put to it to be magnificent. And so you call Mr. Blount 'a person'?" "Perhaps I was wrong," said Ambert contemptuously; "a 'beggar' would be nearer the mark."
  • 41.
    CHAPTER V Meanwhile Agathawas left standing near the doorway, whilst her chaperon was explaining the reason of her late arrival to old Miss Firs-Robinson, Elfrida's aunt. The girl's eyes were directed towards the dancers, and so absorbed was her gaze that she started visibly when a voice sounded at her elbow—that hated voice! "May I have the pleasure of this waltz, Miss Nesbitt?" Agatha looked up. Dr. Darkham, tall, handsome, almost young, was standing beside her. "I am sorry—but the dance is promised," said Agatha, gently but coldly. "I am unfortunate." He looked keenly at her, with open question in his eyes. He had educated himself very carefully on the lines of social etiquette; but education of that sort, unless it comes by nature, is often defective and sometimes he forgot. It did not now suggest itself to him that to question Agatha's word, whether that word were true or false, was a bêtise. Some men had come up to ask, Agatha for a dance, and when they were gone he spoke. "It is promised, then?" he said. "And yet you have only just come?" Agatha looked at him for a moment as if surprised. "It is promised," she said again.
  • 42.
    She made noattempt to explain herself. Her manner, however, was very quiet, although her face was set and her tone frozen. Suddenly, however, her expression changed. It lit up with a happy fervour, and her eyes shone. They were looking past Dr. Darkham's towards something beyond, and the latter, as though unable to control his longing to learn the cause of this sweet change in the lovely face before him, turned to follow her glance, and saw over there, making anxious efforts to reach her, a young man rather above middle height, with a face that, if not strictly handsome, was at all events extremely good to look at. It was Dillwyn, the young doctor who had lately come into the neighbourhood, and who was beginning to do pretty well with a certain class of patients. Not the better classes; those belonged almost exclusively to Darkham. Dillwyn was still a long way off, hemmed in by a crowd of skirts that now, being a little stiffened at the tail, took up a considerable amount of room and were not easily passed. There was still a moment or two before he could reach Agatha. Darkham caught his opportunity and turned hurriedly to her. "I hope you will give me a dance later on?" he said, with a dogged sort of determination. He saw that she did not wish to dance with him, but the knowledge only served to strengthen his desire to dance with her; yet he did not ask her for the next dance. An almost mad longing to waltz with her, to hold her in his arms for even a few minutes, to feel her hand in his, took possession of him. He would risk it. "If the first supper dance is not engaged, may I hope for that?" he said, his voice quite even, his heart beating wildly. "I am afraid I have promised that, too," said Agatha, who had not promised it, but she felt driven to desperation. Her voice was low
  • 43.
    and tremulous. Whatwas it about him that repelled her so? She could not, she would not dance with him, whatever came of it. Darkham bowed and drew back, leaning against the wall just behind her. She felt miserable, and yet thankful, that she could no longer see him. Yet she knew he was behind her, watching her; and she had been rude—certainly, very rude. At that moment Mrs. Poynter joined her. "Not a partner yet? I suppose you must wait for this dance to be over? Ah! here I see Dr. Dillwyn coming towards us. You know, Agatha dearest, that he is a cousin of mine, and quite good family and all that." Agatha laughed. "Yes, yes; you ought to take it that way. It really should not be serious," said Mrs. Poynter, who was a young woman and fond of Agatha, and thought the girl with her charming face ought to make a good match. "I am so glad you are not going to be serious over it, because, really, it would be a terrible throwing away of yourself." "But Mrs. Poynter—-" "Yes, of course. He hasn't proposed, you mean; but—I really wish he had not been placed here through the influence of old Mrs. Greatorex, Reginald Greatorex. The old gentleman might just as well have sent him anywhere else, and he does run after you a good deal, Agatha, doesn't he now?" "I never saw him run in my life," said Agatha demurely. "Ah, there! I see you are evading the subject. And here he comes. Now Agatha, be careful; you know—-"
  • 44.
    "Yes; I know,I know," said Agatha, smiling at her. Yet she hardly heard her; her eyes and thoughts were for the young man who was standing before her. Neither of them saw the face behind them—the face of the man leaning against the wall!
  • 45.
    CHAPTER VI "At last!"said John Dillwyn. "You have not given it away? You have remembered?" "The dance?" "Yes. You know you said you would give me the first on your arrival." "But this! I am so late! I could not have expected you to wait—-" "I have waited, however. And it is mine?" He was now looking at her anxiously. What did her manner, her hesitation, mean? "Yes, of course, but have you no partner?" "I have, indeed"—laughing. "One I would not readily change. I have you." "But," looking up at him a little shyly after this plain speech, "how did you arrange it?" "Very simply. This will be my first waltz as well a yours." "Oh, that is too bad of you," said the girl, colouring softly. She meant to be angry with him, perhaps; but if so, the effort was a dead failure. The corners of her lips were smiling, and a happy light had crept into her eyes. "To wait so long, and—-" "It was long. I admit that," interrupted he, smiling. "I thought you would never come."
  • 46.
    "It was allMrs. Poynter's fault," said Agatha. "And really, but for me I am sure she would not be here even now." "Well, come on, now; let us get even a turn or two," said Dillwyn. "By the bye, the next—is that free?" "Yes," said Agatha. She felt a little frightened. She hoped he would not know she had kept it free purposely. Four or five men had asked her for dances whilst she stood near the door on her arrival with Mrs. Poynter, and when giving them a dance here and there she had steadily refused to part with the next one. She did not tell herself why at the moment, but she knew all the same. "May I have it?" asked Dillwyn, with such a delightful anxiety that all at once her mind was set at rest. He suspected nothing, thought of nothing but his fear that the dance might have been given away before he could ask her for it. Oh, how dear he was! Was there ever any one so good, so perfect? He passed his arm round her waist, and together they joined the dancers. Agatha waltzed delightfully. Her lovely svelte figure swayed and sympathised with the music, just as though it had caught her and was moving with her. Dillwyn waltzed well too. The dance was too soon at an end. "The night is lovely," said he, "will you come out?" He felt that he wanted to be more alone with her; the presence of the people round checked him, destroyed the keenness of the joy he always knew when with her. "I should like it," said she.
  • 47.
    They went towardsthe conservatory, from which there were steps to the garden outside. The door of the conservatory opened off the dancing-room, and was close to where Agatha had been standing on her entrance. Darkham was still there. He had not stirred since Agatha had floated away with Dillwyn's arm around her. He had watched her persistently. He watched her now as she went through the conservatory door down to the gardens, that glad, sweet light upon her face. Were his wife's words true then, after all? Was there something between her and that fellow—that interloper, who had come from no one knew where, to dispute his right in all the parish ailments? His eyes followed them as though they could not tear themselves away, as Dillwyn and Agatha, happy, laughing, went out of the door beyond into the mild and starlit night. A laugh roused him; it was his wife's. A terrible vision in scarlet satin, trimmed with black velvet bows, met his gaze as he turned. Mrs. Darkham was distinctly en fête to-night. "Well, what d'ye think now? That's her young man. What did I say? Don't you wish you were young, eh? Why, she looks upon you as a Methusaler!" Darkham drew his breath sharply. He looked quickly round him. Had any one heard? The woman's hideous vulgarity made him sick. Try as he would, how could he raise himself with this incubus hanging round his neck? He moved away, tired at heart, half mad with misery. Agatha and Dillwyn had reached the garden by this time—a garden lit by heaven's own lamps, and sweet with the breath of sleeping flowers. A few other couples were strolling up and down the paths—but over there was a garden-chair untenanted. They moved towards it in a
  • 48.
    leisurely fashion. Whetherthey stood or walked or sat, they were together—that was the principal thing. "The next is mine, too," said he, in a glad voice, as if dwelling on some joy that nothing could spoil. "Yes. We must take care not to lose it." "And yet it is so lovely out here. Are you sure you are warm enough? And, at all events, it is a good thing to know we need not hurry— that there is no other partner waiting for either of us." He seemed to dwell upon the "we" and "us" as if they conveyed great sweetness to him. His heart seemed full. All at once it seemed to him as though he must speak to her—must tell her of the love that filled his heart. The hour, the loneliness, the silence, all tempted him, and yet he feared! She had known him so short a time—and what was there in her manner to him that should give him courage? Could he dare to put it to the touch to win—or lose it all? To lose! That was what held him back. Agatha was speaking. "I am so sorry you waited for me," said she, lying unconsciously. Had not her heart beaten with delight because he had waited? "And you, too, who are so fond of dancing." "Ah! fond! That is a strong expression. I am not a slave to it, you know." "No." She paused. She seemed to study him for a moment. His face, young, strong, with a sort of defiance in it, as though he could and would conquer his world, fascinated her. It had always fascinated her from the first moment she saw it, now three months ago. It was not so much the kindliness of it as its strength that attracted her.
  • 49.
    She, too, couldbe strong. She felt in harmony with him from the very first. He was, as has been said, not strictly handsome, but his eyes were dark and expressive, and his mouth firm. The pose of his head was charming and his figure well-built and athletic. He was always in splendid spirits, and the milk of human kindness ran swiftly within his veins. Already the poor in his district began to adore him, for kind were his words and encouraging his smiles, and these counted with the sickly ones even more than the shillings that so often came out of a pocket where but few shilling lay. He had begun his fight with life unaided, save by the influence of old Reginald Greatorex, who had property in Rickton, and had got him appointed there, but he felt no fears. A natural buoyancy upheld him. "Well," said he, smiling at her. He was wondering at the depth of her regard. "I was thinking," said she, starting slightly, "that you could never be a slave to anything." Dillwyn looked at her now. "There you wrong me," said he. "I could be—I am—a slave!" "It is difficult to believe," said she calmly. "Why should it be difficult?" "I don't know. But you don't lend yourself readily to the idea. You look as if you could never be easily swayed or governed." "Not easily, perhaps. But—-" He put out his hand as if to clasp hers. At this moment a sudden movement in the bushes behind her struck upon Agatha's ears. She sprang to her feet.
  • 51.
    CHAPTER VII A senseof faintness crept over her. By some strange prescience, she knew who stood behind there in the darkness, concealed, listening. A great horror took possession of her. Why should he haunt her so? What was she to him? He who had a living wife! She turned to Dillwyn, who had risen too. "Come back to the house," said she. Her voice was nervous, but very low. She moved away from the seat, on which she had been resting, with a haste that was almost feverish. Dillwyn followed her, his mind disturbed. Had she fathomed his determination to speak to her, and had she purposely prevented his speaking? He went at once to the point, as he always did when uncertain or perplexed. "Have I offended you?" asked he. "No! Oh, no! You must not think that. How could you have offended me? But I thought I heard some one—there—behind the shrubs." "But even so, there are people all over the place to-night." "Yes, I know." Her tone now was almost heartbroken. She stopped suddenly and held out her hand to him. "You are still my friend?" said she. "I shall be your friend to the last day of my life," said Dillwyn. But his tone was heavy; the elasticity that always distinguished it had gone out of it for the first time.
  • 52.
    In silence theyreached the house. Not another word was said about the dance impending. Agatha seeing a couch surrounded by fragrant shrubs, went towards it. "The dance has begun," said Dillwyn, but so coldly that she shrank from him. "I am tired," she said. "Then you had better rest here. Shall I bring you an ice?" "Thank you." He went away. Agatha dropped on to the lounge and gave her misery full play. She had put an end to it all—all that might have made her dull life a very spring of joy. And yet to tell the man who loved her that another man—a married man—pursued her with his hateful attentions was more than she could do. Now, left alone, her spirit failed her, and her eyes filled with tears. She would have given all she possessed to be at home, in her own room, alone, so that her grief might have full sway. She almost hoped he would not come back with the ice. She dreaded the coldness of his regard more than his absence. She—- "Can I do anything for you, Miss Nesbitt?" Dr. Darkham stood beside her. It was to Agatha as though he had risen from the dead. She had supposed him still outside in the garden. But he had followed her apparently. "No, thank you," she said, in a voice well kept in order. "You are not dancing, then?" "Not for the moment." "Your partner is Dr. Dillwyn?"
  • 53.
    "Yes." "He was yourpartner for the last two, I think?" Agatha roused herself. She looked full at him; there was a smile upon her beautiful lips. "Ah, Dr. Darkham, I have already a chaperon!" said she. "A most inefficient one," said Darkham steadily. "Why should you be allowed to listen to the solicitations of a mere beggar? Were your aunt to hear of this—-" "My aunt!" Agatha looked up at him, but after that one swift glance drew back. What was there in his eyes? Oh, horrible! Surely, surely now she knew that she was not wrong when lately she told herself in shrinking whispers that this man was in love with her. There had been something so strange in the expression of his eyes when looking at her—something so empressé in his manner— something so downright hateful in the inflection of his voice. "My aunt is quite capable of looking after me without the interference of any one," said Agatha slowly. "You have been very kind to Mrs. Greatorex, but you must not extend your kindness to me. I want no other guardian but my aunt." She rose and looked him straight in the face. "Pray do not trouble yourself about my welfare for the future." She passed him and went on; she saw Dillwyn coming towards her with the ice; she had believed she would rather not have seen him return, but now she went to him gladly. Darkham fell slowly into the chair she had just left. That girl —her face, her form—they haunted him. And side by side with hers always grew another face, another form—that of his wife! What vile fiend
  • 54.
    had arranged hismarriage? A mere mockery of marriage, where hatred alone was the link that bound the two. Gold that had given a false brilliancy to the faded yellow of her hair, and thrown a gleaming into her light, lustreless eyes. Had he but waited, had he but relied upon himself and given his undoubted genius a chance, he might have risen, unaided, to the highest point, and been now free to marry the woman he loved. With wild, increasing exultation he remembered how she had risen to-night out there in the shrubberies as Dillwyn was on the point of proposing to her. She had cast him off in a sense. Gently, though. She was always kind and gentle. But she certainly put him off; she did not care for him, then. Darkham's face glowed as he sat there in the conservatory. If this woman to whom he was tied was gone—dead! Then his chance might come. If she did not care for Dillwyn—why, she might care for him. At present how could she? "Why don't you come out and look at her?" said the coarse voice he dreaded at his ear; "she's dancing with Dillwyn. She dances lovely —'specially with Dillwyn."
  • 55.
    CHAPTER VIII Mrs. Greatorexwas, in a ladylike sort of way, a confirmed gossip. To have told her so personally would have been to make her your enemy for life. The way she looked at it was far more Christian—she said "she took a kindly interest in her neighbours." To-day her interest was particularly strong, if not very kindly; and she was now, from the depths of her low lounging chair, catechising Agatha about the dance last night. She was always very keen about any news that concerned the Firs-Robinsons, who were really nobodies, whilst she—- Her grandfather had been an earl—out-at-elbows, it was true, but yet an earl. She laid great store by this, and periodically reminded her acquaintances of it. Her mother, Lady Winifred, had married (badly from a moneyed point of view) a young and reckless guardsman, who died three years after her marriage, leaving her all his debts and an infant daughter. But then he was one of the Engletons of Derbyshire, and would have come into a baronetcy if three uncles and five cousins had been removed. Unfortunately, her husband predeceased his father! And when the old man (who detested her) followed him to the family vault three months later, it was found that she was not as much as mentioned in his will. There had been no settlements. As there were no children, all the property went to the second son, Reginald Greatorex.
  • 56.
    The sorest subjectwith Agatha's aunt was this brother-in-law. She had treated him very cavalierly during her short reign at Medlands, as wife of the elder son; and when Reginald came in for the property he remembered it. He portioned her off with as small a dowry as decency would allow. He was testy, self-contained old bachelor—and the last of his race— though with a good point here and there. He had a been good, at all events, to John Dillwyn, whose father was the rector of his parish, and whose mother, some said, had been the one love of old Reginald's life. Both father and mother were dead now, and the young man, after a fierce struggle for existence in town, had passed all his exams, and was free to kill or cure, anywhere. It was when he stood triumphant, but friendless, that Mr. Greatorex had come forward, and got him his post at Rickton, where the former had a good deal of property, though Medlands itself lay in an adjoining county. Mrs. Greatorex had received the young man coldly. Any one connected with Reginald must be distasteful to her. To do her justice, she had never truckled to her brother-in-law in any way, and had contented herself with undisguised hatred of him. Agatha had nothing to do with him, she thanked Heaven—otherwise she could not have supported existence with her. She came from her side of the house, where people had been officers and—- "Mrs Darkham looked frightful," said Agatha. "She really did, poor woman! Fancy, such a gown—red satin and black velvet— and her face—-" "As red as the satin, no doubt. But is it possible, Agatha, what you tell me—that Richard Browne is staying with those people?" "Those people" were always the Firs-Robinsons with Mrs. Greatorex. The fact that they could have bought her up a thousand times over at any moment rankled in her mind. She could not forgive them that.
  • 57.
    Still in somequeer way she hankered after the Robinsons— desiring to know this and that about them, and being, as has been hinted, of a parsimonious turn of mind, did not refrain from accepting from them fruits and flowers and vegetables. Indeed, face to face with them she was delightful. She justified herself over this hypocritical turn, and explained herself to Agatha, by quoting St. Paul. "All things to all men" was a motto of his. "Richard?" questioned Agatha, as if surprised. Indeed, Mrs. Greatorex was perhaps the only person of his acquaintance who called Mr. Browne "Richard." "Dicky, you mean?" "Yes, of course. He was christened Richard, Agatha. That ought to count. His father's name is Richard." "It is so funny to think of Dicky's having a father," said Agatha, laughing. "What kind is he, auntie?" "A mummy! A modern mummy," said Mrs. Greatorex, laying down her sock. "A dandified mummy. All paint and wig and teeth—-" "But a mummy! It wouldn't have—-" "Yes, I know. But there's nothing in him! Nothing that is his own. He is padded and stuffed and perfumed! He"—indignantly— "ought to have died ten years ago, and yet now he goes about the world rejuvenated yearly. Only last month I had a letter from a friend of mine, saying Richard's father had come back from the German spas describing himself as 'a giant refreshed.' Just fancy that, at seventy- eight!" "I always feel I could love old Mr. Browne," said Agatha, laughing still. "You must have precious little to love," said her aunt, knitting vigorously. She had known old Mr. Browne in her youth.
  • 58.
    Agatha's laughter cameto a sudden end. She sprang to her feet. "Here is Edwy Darkham," said Agatha, moving to the window—"and looking so wild! Aunt Hilda, do come here! Oh!"—anxiously— "surely there is something wrong with him." Across the lawn, running uncouthly, hideously—rolling from side to side—yet with astonishing speed, the idiot came. His huge head was thrown up, and the beauty that was in his face when it was in repose was now all gone. He was mouthing horribly, and inarticulate cries seemed to be bursting from his lips. Agatha struck by the great terror that so evidently possessed him, conquered all fear, and springing out of the low French window, ran to meet him. At times she shrank from him—not always. Deep pity for him lay within her heart, because he was so docile, and because he clung to her so, poor thing! and seemed to find such comfort in her presence. She had been specially kind in her manner to his mother often because of him, and perhaps that kindness to her—the mother— whom the poor, handsome, ill-shapen idiot adored, had been the first cause of his affection for Agatha. She had always been good to Edwy, in spite of her detestation of his father, and now, when the unhappy creature was in such evident trouble—a trouble that rendered him a thousand times more repulsive than usual—she lost her fear of him, and ran down the balcony steps to meet him. He was unhappy—this poor boy, whose soul was but an empty shell! What ailed him? All her young, strong, gentle heart went out to him. "Edwy! Edwy!" cried she, as eloquently as though he could hear her. He rushed to her, and caught her arm, and sank on his knees before her. "Sho! Sho! Sho!" he yelled.
  • 59.
    It was hisone word. To him it meant "mother." Agatha understood him. She pressed his poor head against her arm. "What is it? What is it, Edwy?" asked she. There was quick anxiety in her tone. Her voice was unheard by him, but his eyes followed hers and the movement of her lips. Some thread in his weak brain caught at the meaning of her words. His fingers clutched her and closed upon both her arms. The pain was excessive, almost beyond bearing, and Agatha tried to shake herself free. But after a first effort she checked herself. The agony in the poor boy's face, usually so expressionless, moved her so powerfully that she stood still, bearing the pain courageously. She managed to lay her hand, however, on the large bony one (so singularly muscular) that was grasping her right arm, and after a moment or two Edwy relaxed his hold. "Aunt Hilda," cried Agatha, turning to the window. "What can be the matter?" But Mrs. Greatorex, who had carefully taken refuge behind the window curtains, from which safety point she could see without being seen, declined to leave her shelter to solve the problem offered her. "Send him away! send him away!" she screamed dramatically, safe in the knowledge that the idiot could not hear her. "He is going mad. I can see it in his eyes. He'll murder you if you encourage him any further. Get rid of him, Agatha, I implore you, before he does any mischief." "Oh no, it isn't that. It is only that he is in terrible distress about something." At this moment Edwy rose to his feet, and, approaching her, began to gesticulate violently and make loud guttural sounds. In vain
  • 60.
    Welcome to ourwebsite – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! testbankdeal.com