Java Software Solutions 8th Edition Lewis Test Bank
download pdf
https://testbankfan.com/product/java-software-solutions-8th-edition-
lewis-test-bank/
Visit testbankfan.com today to download the complete set of
test banks or solution manuals!
We believe these products will be a great fit for you. Click
the link to download now, or visit testbankfan.com
to discover even more!
Java Software Solutions 8th Edition Lewis Solutions Manual
https://testbankfan.com/product/java-software-solutions-8th-edition-
lewis-solutions-manual/
Java Software Solutions 9th Edition Lewis Test Bank
https://testbankfan.com/product/java-software-solutions-9th-edition-
lewis-test-bank/
Java Software Solutions 9th Edition Lewis Solutions Manual
https://testbankfan.com/product/java-software-solutions-9th-edition-
lewis-solutions-manual/
Essentials of Psychiatric Mental Health Nursing 1st
Edition Varcarolis Test Bank
https://testbankfan.com/product/essentials-of-psychiatric-mental-
health-nursing-1st-edition-varcarolis-test-bank/
Discrete Mathematics with Applications 4th Edition Susanna
Solutions Manual
https://testbankfan.com/product/discrete-mathematics-with-
applications-4th-edition-susanna-solutions-manual/
Law for Business 11th Edition Barnes Test Bank
https://testbankfan.com/product/law-for-business-11th-edition-barnes-
test-bank/
Understanding Cross Cultural Management 2nd Edition
Browaeys Solutions Manual
https://testbankfan.com/product/understanding-cross-cultural-
management-2nd-edition-browaeys-solutions-manual/
Organizational Behavior A Critical Thinking Approach 1st
Edition Neck Solutions Manual
https://testbankfan.com/product/organizational-behavior-a-critical-
thinking-approach-1st-edition-neck-solutions-manual/
Principles of Leadership International 7th Edition DuBrin
Test Bank
https://testbankfan.com/product/principles-of-leadership-
international-edition-7th-edition-dubrin-test-bank/
Sociology in Our Times 9th Edition Diana Test Bank
https://testbankfan.com/product/sociology-in-our-times-9th-edition-
diana-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.
Random documents with unrelated
content Scribd suggests to you:
i passi e i balzi e i gridi sordi conta,
ch'ella fa per sfuggire
a quello sconosciuto
ch'è rinchiuso con lei,
a quell'essere enorme
e beffardo ch'è nato
a poco a poco dalla malattia,
che s'è nutrito e ha fatto l'ossa ed ora
è il compagno e il nemico,
il custode e il padrone;
che ha più carne di lei,
che ha più soffio di lei,
che la guarda, le parla,
le s'accosta, la tocca,
le rifiata vicino
intollerabilmente,
visibile e palpabile
per lei sola...
Donna Aldegrina.
No, no!
Taci.
Ella pone le sue mani scarne su la bocca di Gigliola.
Sei devastata,
sei disperata fino a dentro, sei
bruciata fino alta radice. Tutto
quel che è misero e offeso
e rotto e agonizzante
parla per la tua bocca. Sei la voce
della nostra ruina,
di tutte le ruine senza scampo.
O mia povera povera
povera creatura,
piccola anima mia,
per me piccola sempre,
chi ti consolerà?
chi t'inumidirà un'altra volta
queste pàlpebre secche? Ahimè! Ahimè!
Una pietra, una terra calcinata,
una stoppia riarsa.
E che farò per te io vecchia e lógora?
Chi mai chi mai farà per te nel mondo
alcuna cosa, o piccola mia sola?
Gigliola.
Io, io farò. Fare bisogna, fare
bisogna. Alzarmi debbo,
restar diritta in piedi fino all'ora
di coricarmi. Baciami la fronte.
Mi bacerai a sera un'altra volta.
Così. M'alzo. Il coraggio non vacilla.
Stanotte i manovali
lavoreranno al lume delle fiaccole.
Non lo sai? Tutta notte.
Anch'io anch'io laggiù, in qualche parte,
ho una fiaccola rossa
nascosta sotto il moggio,
sotto un moggio vecchissimo nascosta
che non misura più perché non tiene
più né grano né orzo.
Entro i cerchi di ferro rugginoso
ha le doghe sconnesse.
Quella terrò nel pugno, a rischiarare
il travaglio notturno
intorno alla ruina.
E se la casa crolla
io sono certa che una sepoltura
resterà ferma e immune.
Lo prometto.
Donna Aldegrina.
Gigliola, dove vai?
Gigliola.
A promettere.
Entra sotto l'arcata dei mausolei: sparisce per la porta
della cappella.
Donna Aldegrina.
Séguila, Annabella.
Séguila in ogni passo.
Non la lasciare mai.
Ho paura, ho paura.
Annabella.
Signorìa, non m'attento.
Vuol sempre stare sola quando scende
alla Cappella e s'inginocchia
a quella sepoltura.
Posso mettermi là, dietro la porta.
Donna Aldegrina.
Non la lasciare. Va. Tu, Benedetta,
guarda chi è su per la scala bassa.
Benedetta, origliando.
È la voce di Don Bertrando. Sale
col fratellastro. Sento anche la voce
di Don Tibaldo.
Donna Aldegrina.
Si sarà levato
Simonetto? Che ora
è?
Benedetta.
Quasi ventun'ora, Signorìa.
Donna Aldegrina.
Va, va di sopra. Guarda
se dorme ancóra. Non lo risvegliare
se dorme. Ma se è sveglio
fa che si levi, e prenda
la medicina.
Benedetta.
Signorìa, non vuole
la sorella che prenda medicina
se non glie la prepara
con le sue mani.
Donna Aldegrina.
Perché?
Benedetta.
Io non so.
Ha il suo pensiero.
Donna Aldegrina.
Salgo anch'io fra poco.
Annabella! Annabella!
La vecchia scompare sotto l'arcata chiamando
sommessamente la nutrice. Con lei entra nella cappella.
Benedetta si avvia su per la scala, sospirando.
SCENA TERZA.
Entrano, per la scala che dà su la loggetta, sotto l'armatura di travi e
di corde, Tibaldo de Sangro e Bertrando Acclozamòra, i fratellastri.
Bertrando.
Dunque rifiuti? È l'ultima parola?
Tibaldo.
Non ho manco un tornese!
Non so come farò
a pagar la giornata
dei manovali. E se non pago, Mastro
Domenico di Pace
lascia che tutto vada a precipizio:
leva i puntelli. Intendi?
Bertrando.
Tu mentisci.
Tibaldo.
Vedi: mia madre fruga
tutte le cartapecore
degli scaffali, mette sottosopra
l'archivio, lo riscontra a filza a filza,
ci si logora gli occhi...
Ah, se si ritrovasse l'istrumento
di quel vincolo fidecommissario,
nella lite che abbiamo coi Mormile!
Bertrando.
Non divagare. Ti domando ancóra
una volta: mi dài quella miseria?
Tibaldo.
Ma se ti dico che non ho un tornese!
Credimi.
Bertrando.
Tu mentisci.
Non riscotesti ieri
da Crescenzo Castoldo
centoventi ducati di caparra
pel grano che gli devi consegnare
dopo la mietitura?
Tibaldo.
Non è vero.
Bertrando.
Hai coraggio di negarlo!
Bene ti s'è indurato
il sangue su cotesto viso giallo,
come la sugna ràncida
nella vescica risecchita.
Tibaldo.
Ancóra
cerchi di sopraffarmi con l'ingiuria.
È il raccolto del campo di Malvese,
ch'è di mio figlio, dell'eredità
di sua madre.
Bertrando.
Ma il frutto è tuo.
Tibaldo.
Non posso
toccarlo.
Bertrando.
Tu! tu che conficchi ovunque
le tue granfie ed hai solo
lo scrupolo del tarlo
che ha roso il Cristo e non voleva rodere
il chiodo! Razza dei Sangro.
Tibaldo.
Ma chi,
ma chi è che mi succhia,
chi è che mi dissangua da vent'anni
senza tregua?
Bertrando.
Di tutto il mio ti sei
impossessato con l'usura.
Tibaldo.
Quali
erano i beni degli Acclozamòra?
Bertrando.
Incominciò tuo padre
a spogliarci.
Tibaldo.
Di che?
Fra la Serra dei Curti
e il Sirente avevate
i vostri latifondi?
Ovìndoli è paese
di pecorai.
Bertrando.
Avevamo Celano,
avevamo Paterno,
Aielli...
Tibaldo.
Al tempo degli Aragonesi,
sotto il buon re Alfonso.
Ti ripigliò mio padre nella casa,
te con tua moglie, quando
non t'era altro rimasto
se non un branco di cinquanta pecore,
le formelle di faggio e le casciaie.
Bertrando.
Nominarmi il tuo padre
tu osi e rinfacciarmi il benefizio!
Qual benefizio? A me restituire
doveva quel che a me minore avea
frodato. La tutela
fu il latrocinio guarentito. Parli,
parli quella che è vedova due volte...
Tibaldo.
Tu di tutte le infamie
ti lordi la tua bocca di mastino;
e sempre tu sei pronto
ad addentare fino al sangue e all'osso,
se non ricevi l'offa.
Bertrando.
Non aizzare il mastino, Tibaldo.
Tibaldo.
Che vuoi da me? ch'io mi ti dia legato
mani e piedi? vuoi darmi
la sorte di Giovanna? seppellirmi
vivo fra quattro mura?
e gavazzare poi con le tue scrofe
e coi tuoi bardassoni
su gli avanzi dei Sangro?
Metti almeno un bavaglio
alla vittima, ché troppo si sente
gridare; e v'è taluno
che volge il capo in su.
Bertrando.
Guardami fiso, guardami negli occhi,
tu che parli di vittime.
Ben una t'è stampata
in fondo alla pupilla,
o vedovo di Mònica, marito
della femmina marsa.
Tibaldo.
Oh! Oh! Una mi vedi
nella pupilla? Sono io stato fiso?
E certo m'hai veduto impallidire.
Ride sardonico.
Bertrando.
Sei la vescica di grassume smorto
che non si muta.
Tibaldo.
Almeno
tu mi vedi tremare.
Guarda come mi tremano
le due mani. Ho il parlético.
Bertrando.
La malattia ti rode
le vertebre. Finito sei.
Tibaldo.
O Giudice
profondo, e che farai
se l'assassino è pallido e tremante
anche quando gli dici che hai veduto
una milza di bue
penzolare alla porta d'un macello?
Bertrando.
Non ridere, non ridere così;
o ti schiaccio su i denti
il ghigno.
Tibaldo.
E che farai,
Giudice, se ogni sera l'assassino
scaccia di sotto al letto con la scarpa
il rimorso importuno?
Con una vecchia scarpa,
come si scaccia un sorcio.
Bertrando.
Ridi, ridi;
e nel bianco degli occhi hai lo spavento.
E il tuo riso di dentro
cigola, peggio che una vecchia imposta
sconquassata lassù
nell'ultima finestra
lassù perduta sotto la grondaia
rotta. Il vento la strappa dagli arpioni.
E ti casca sul collo e te lo stronca.
Bada che la tua beffa
non ti ritorni sopra
d'un colpo.
Tibaldo.
Sì, mi bado.
Non passo già per gli anditi
scuri né per le scale strette, quando
sei nella casa.
Bertrando.
T'odio,
con ogni goccia del mio sangue contro
ogni goccia del tuo.
Intendi? Tu m'ingombri.
Il tuo fiato m'attossica
l'aria che serve al mio polmone. Fino
nel ventre di mia madre
tu m'hai preso il mio posto: sei venuto
dopo di me nel conio
della mia razza, tu mollume senza
scheletro, nato dal seme d'un vecchio.
E l'essere tu nato
mi fu sempre un sopruso
che mai non seppi perdonarti. Intendi?
E di nessuna carne umana sento
ribrezzo come della tua; né so
perché. L'ho dentro le midolle, cieco
e bestiale. Tutto
di te m'offende: il passo, il gesto, il riso,
il respiro, lo sguardo.
Quella bolla bianchiccia di saliva
che ti nasce nel canto
delle labbra se ciarli, mi fa ira,
m'esaspera. Ho un rancore
mortale contro le tue mani flosce
che mostrano l'enfiore
del mal cardìaco...
Tibaldo subitamente s'accascia.
Tibaldo.
Ohimè! È vero, è vero.
È
È l'edema, è l'edema molle e freddo
che cede al dito e resta là col cavo.
Il mio cuore è ammalato. Morirò
di sùbito passando quella porta.
E tu prendilo e gettalo
nel letamaio, questo
mio cuore, come un fico putrefatto;
e una gallina lo trovi raspando
e se lo porti nel becco a pollaio...
Bertrando, io t'ho negato
quei cinquanta ducati,
mentre debbo morire!
Te li darò. Aspetta.
Bertrando gli si avvicina.
Bertrando.
Soffri? Hai tremor di cuore?
Io non voleva farti violenza.
Ma tu lo sai: mi lascio trascinare
dalla collera... Soffri?
Tibaldo.
Te li darò. Ma non li ho qui. Bisogna
che tu venga con me...
Bertrando.
Dove?
Tibaldo.
Dove ho
accumulato...
Bertrando.
Dove?
Tibaldo.
Ah, se potessi confidarmi in te
come nel mio fratello!
Bertrando.
Non sono il tuo fratello?
Tibaldo.
M'odii, con ogni goccia del tuo sangue.
L'hai detto.
Bertrando.
Sì, nell'impeto dell'ira.
Ti piaci d'aizzarmi: ti fai beffe
di me... Ma poi tu stesso
ridi della mia furia.
Tibaldo.
Non m'hai più odio! Posso confidarmi
dunque?
Bertrando.
Parla.
Tibaldo.
Il tesoro...
Bertrando.
Dov'è? Parla. T'ascolto. Non temere.
Tibaldo.
Tu sai la vecchia diceria che corre
tra la gente d'Anversa,
e per tutta la valle
del Sagittario, e dalla Forca d'oro
alla Terrata fra i pastori.
Bertrando.
Sì,
la so.
Tibaldo.
La casa magna
dei Sangro, quella delle cento stanze,
tutta crepacci e tutta ragnateli,
che da tutte le bande
si sgretola, e nessuno ci rimette
pur una mestolata di calcina...
Bertrando.
Si, sì, la so.
Tibaldo.
E la famiglia fa
magra cucina. E dentro un muro cieco
è nascosto il tesoro
di Don Simone; ed ogni primogenito
eredita il segreto e l'avarizia...
Bertrando.
Ebbene?
Tibaldo.
Quanto sei
impaziente, fratello!
Vuoi che ti dica come
stride ogni chiave arrugginita? come
cigola ogni uscio sgangherato? Vuoi
che ti nòveri tutto
quel che si macchia, quel che si scolora,
quel che si sloga, si curva, si sfalda,
s'ammolla, cola, marcisce?
Bertrando, oscurandosi.
Tibaldo,
non divagare.
Tibaldo.
Ascolta. Ho un po' d'affanno.
Ansa e soffia, simulando.
Ascolta. Il mio figliolo
Simonetto è infermiccio, ed è svanito,
anch'egli — ahimè — di vita troppo breve.
E se ne va la primogenitura...
Ah se tu non mi fossi
tanto nemico! Acclozamòra
contro Sangro.
Bertrando.
Io nemico? Oh no!
Tibaldo.
M'ingiurii
sempre.
Bertrando.
Ma senza fiele.
Per caldezza di sangue.
La stessa madre ci portò. Se tu
non mi rinneghi, io sono il tuo fratello,
a cuore aperto. Le parole volano.
Dimentica, ti prego. Ecco la mano.
Tibaldo rompe con uno scoppio di scherno la sua
simulazione.
Tibaldo.
Tieni: un ducato, un ducato! Non vale
di più questo tuo sùbito
amor fraterno. Tieni.
Per un ducato, lo compero.
Bertrando.
Ah mulo!
Tibaldo.
Prendilo dalla mano floscia. Ancóra
mi regge al riso il cuore
ammalato. Anzi questo
mi giova meglio che la digitale.
Bertrando.
Non ti giova. Ti metto sotto i piedi,
ti spezzo quel tuo dosso di buffone!
Ah, per dio, questa volta
non ti salvi da me. Ti faccio mordere,
giuro, i tuoi calcinacci.
Tibaldo.
Lasciami! Bruto! Bruto!
Bertrando.
Giù! La nuca
a terra! Acclozamòra
contro Sangro.
Tibaldo.
No! Lasciami! Assassino!
Bertrando.
Mordi come una femmina...
Tibaldo.
Assassino!
SCENA QUARTA.
Appare la madre, accorrendo dalla cappella. E dietro di lei viene
Gigliola, seguita da Annabella; e rimangono quivi in disparte.
Donna Aldegrina.
Figli! Figli! Bertrando!
Ah vergogna, vergogna! Forsennati!
Non avete onta? Mi volete morta
d'orrore? Su, gettatevi
contro me. Su, rompetemi il mio petto.
Su, squassatemi i miei capelli bianchi,
più bianchi di dolore
che di vecchiezza, e per voi, figli tristi,
per voi nati da me, dalle mie viscere
dilaniate. Ma che latte mai vi diedi
io, che latte malvagio,
perché me lo rendiate in stille e in sorsi
di tòssico, ogni giorno?
O Bertrando, o selvaggio,
che follìa t'ha invasato? Sempre in guerra
sei. Dove tu tocchi
lasci l'impronta dell'artiglio. Sempre
teso a nuocere. Metti
dunque la mano anche su me. Soltanto
questo ti resta.
Bertrando.
Taci, madre. So
che non m'ami, da quando ti fu grave
l'esser fedele ad una tomba, e guasto
mi fu il mio nido, e imposta
mi fu la servitù verso gli intrusi
sempre più dura; e il vecchio nome, il mio,
ti sonò male come una rampogna.
Donna Aldegrina.
Misero te! Non è la prima volta
che tu mordi tua madre alla mammella.
Bertrando.
Non mordo io già. Costui,
vedi, ha tentato di mordermi le dita
con i suoi denti di coniglio. E tu
proteggilo. Proteggi
costui che ha il viso smorto
e il fiato grosso. Ei n'ha bisogno. Ma
consiglialo a restar nascosto lungo
tempo sotto le coltri.
Donna Aldegrina.
O selvaggio, non vedi
che la sua figlia è là
con la faccia nascosta?
Bertrando.
Dille che, s'ella guarda
nella pupilla al vedovo
riammogliato, se gli guarda in fondo,
vedrà...
Donna Aldegrina.
Bertrando! Bertrando!
Bertrando.
Sì, taccio.
Addio, madre. O Tibaldo,
il tuo ducato, guarda,
è rimasto per terra:
mostra il rovescio. Bada!
Raccàttalo e sii cauto.
Spinge col piede la moneta verso il fratellastro; poi apre la
porta sinistra per uscire.
Addio, madre.
Donna Aldegrina, seguendolo.
Bertrando, non andartene
così. Ti prego! Torna in pace. Stendi
la mano al tuo fratello.
Bertrando.
Per un ducato?
Esce.
Donna Aldegrina.
Aspetta!
Ascolta la tua madre.
Ti prego!
Segue il figlio, che non si volge.
SCENA QUINTA.
Tibaldo de Sangro rimane seduto, tra le cartapecore, a capo chino,
ancora affannato dalla lotta e pallidissimo. Gigliola leva il capo,
guarda il padre, cammina verso di lui. S'odono le voci di fatica
lontane.
Gigliola.
Vattene, Annabella.
Si sofferma e segue con lo sguardo la nutrice che; se ne
va silenziosamente, su per l'ombra della scala. Poi
s'accosta al padre, e la voce le trema.
Padre,
son io. Non c'è nessuno più. Son io
sola, con te.
Egli si leva, timidamente, vacillando un poco, senza osare
di guardare in viso la figlia.
Tibaldo.
Gigliola!
Gigliola.
Oh no, non devi
sorridere così. Tu mi faresti
meno male, se tu mi calpestassi.
Tibaldo.
Non ti devo sorridere... Perché?
Ti faccio male... Non so... Lascia allora
ch'io mi metta in ginocchio avanti a te,
figlia. Non so che altro potrei, figlia,
ora. Tu no, non mi faresti male
se tu mi calpestassi.
Ma ti benedirei.
Gigliola.
No, no, non in ginocchio. Sta diritto.
Una pausa. Corruga le ciglia.
Chi ti voleva piegare la nuca
a terra?
Tibaldo.
Figlia, abbi pietà del tuo
padre se tu sei stata testimone
della vergogna.
Gigliola.
Tremi tutto. Sei
più bianco della tua camicia.
Tibaldo.
Soffro
un poco.
Gigliola.
Certo, tu non tremi... è vero?
tu non tremi... per quello.
Tibaldo.
Per quello?
Una pausa.
Gigliola.
Padre!
Tibaldo.
Di': che hai? che vuoi,
Gigliola? Parla.
Gigliola.
Tu non hai paura.
Tibaldo.
Di chi?
Una pausa.
Gigliola.
Gli hai morso la mano.
Tibaldo.
Gigliola...
Gigliola.
Forte?
Tibaldo.
Che mi domandi!
Gigliola.
Forte dovevi. Tu non hai paura;
è vero?
Tibaldo, balbettando.
Ma che hai?
Che mi domandi! Se tu hai veduto
quello che non doveva esser veduto
dagli occhi tuoi, perdónami, perdónami.
Gigliola.
Tutto ho veduto, veggo.
Non ho più ciglia: sono senza pàlpebre:
gli occhi miei non si serrano
più, non battono più.
Veggo, terribilmente.
Tibaldo.
Gigliola sei? Che mai
avvenne? Chi ti dà
questa forza? Che gridi, quanti gridi
nella tua voce sorda!
Gigliola.
Dimenticato avevi
il suono della mia gola ferita.
Tibaldo.
Rimasta eri velata
per me, tutta velata
dal tuo lutto, in disparte.
Gigliola.
T'è nuova la mia voce?
Per un anno in silenzio
ho portata la piaga
senza sangue, la piaga
che fu fatta anche a me
in un punto, lo sai,
qui d'intorno al respiro...
Tibaldo.
Come ti guarderò?
Eri velata. Vivere ho potuto,
esiliato dall'anima tua,
con l'amore dell'esule
pel piccolo giardino ove non entra
più...
Gigliola.
Tutto è arso. Non aver parole
di tenerezza per la creatura
abbandonata nell'orrore, sola,
come in fondo al burrone,
come in mezzo al ghiacciaio.
Ma guardami; ma leva gli occhi. Guardami
quale sono: non più
piccola e neppure più
dolce... Nulla di giovine è rimasto
in me. Passata in un anno è la mia
primavera. Mi sono maturata
non al sole ma all'ombra,
all'ombra d'una sepoltura. Guardami;
ché devo interrogarti,
e il tempo incalza. Ho fretta.
Con uno sforzo angoscioso il padre solleva le palpebre, la
fisa.
Tibaldo.
Oh, l'orrore, l'orrore
nella tua faccia, gli occhi senza pàlpebre!
Figlia, e m'odii anche tu?
E chi t'ha fatta così dura? Dimmi.
Gigliola.
Ti ricordi? Fra poche
ore viene quell'ora:
verso sera. Mia madre fu chiamata;
e la povera entrò
nella stanza già scura.
E, poco dopo, quell'altra, la serva
tortuosa, la femmina di Luco,
escì gridando. E già
la vittima non si moveva più...
Tibaldo.
No, no, non seguitare!
Gigliola.
Bisogna che tu m'oda,
e che tu mi risponda.
Quell'altra è la tua moglie
oggi. Tu me l'hai data per padrona.
Mi fu tolta la madre e mi fu data
per padrona colei che con lo straccio
lavava il pavimento.
Non è vero? Ma guardami!
Tibaldo.
Non posso più. Non ho più forza.
Gigliola.
Eppure
bisogna che, con gli occhi
negli occhi, a viso a viso,
tu mi risponda.
Tibaldo.
Sùbito
parla. Dimmi che vuoi.
Ti guardo.
Gigliola.
Sai la verità?
Tibaldo.
Ma quale?
Gigliola.
No, padre, no, non mi sfuggire. Tieni
ferma l'anima tua nella pupilla
come ho ferma la mia.
Chi la fece morire?
La verità! La verità!
Tibaldo.
Non fu
la sorte iniqua? la percossa cieca?
Gigliola.
Oh ti supplico, padre!
Non mi mentire. Parlami
come s'io fossi moribonda, come
se dopo io mi dovessi
avere negli orecchi e nella bocca
il suggello per sempre. Non lo sai?
Non sospetti? Quell'altra
che uscì gridando...
Tibaldo.
No, no!
Gigliola.
Ma sei tutto
bianco.
Tibaldo.
Oh! Oh! E tu pensi,
figlia, tu pensi di me questa infàmia:
ch'io t'avrei sottoposta
a tanto orrore nella casa dove
mi nascesti, ch'io complice
avrei congiunto col legame orrendo
la bestia criminosa
e la tua purità,
qui nella casa dov'è custodita
quella che fu sepolta...
Gigliola.
Silenziosamente
sepolta fu, silenziosamente:
ed ogni viso intorno
era come la pietra sepolcrale,
come la pietra che si pone sopra
la cosa buia e segreta. E il tuo viso...
Tibaldo.
Il mio viso...
Gigliola.
Pareva
che avesse un marchio d'onta.
Oh che pietà di te, padre! Ma tutto
dire debbo. Pareva
che già lo difformasse
l'obliquità che poi ho riveduta
mille volte, la maschera convulsa
che t'ha messa la femmina e che tu
non puoi strapparti...
Tibaldo.
Me la vedi? qui?
l'ho qui? Se piango, non si fende? Ma
chi t'ha fatta così crudele? Chi
t'ha mutata, anche te?
t'ha convulsa, anche te?
Tu non sei più Gigliola.
Gigliola.
Non sono più Gigliola. Maturata
sono, disfatta, e non dall'ombra sola
di quel sepolcro ma dal fiato impuro
che m'alita su l'anima continuo,
e da quel tuo sorriso, dal sorriso
di vergogna, che per un anno fu
il segno della tua bontà paterna!
Tibaldo.
Mi struggevo d'amore
per te, con un rimpianto senza fine,
esiliato dall'anima tua,
esiliato da tutte le dolci
cose che conoscevo
in te che m'eri il fiore
di questo tronco guasto.
Gigliola.
E perché l'hai gittato,
il fiore, sotto i piedi assuefatti
a camminare scalzi
nell'immondezza?
Tibaldo.
Come
potresti tu comprendere il mio male
disperato, la mia miseria senza
riparo?
Gigliola.
Ah che pietà di te! Non sono
crudele.
Tibaldo.
Me n'andrò, scomparirò.
Non mi vedrai. Vuoi questo?
Gigliola.
Scàcciala.
Tibaldo.
Tu non puoi, non puoi comprendere!
Gigliola.
Scàcciala.
Tibaldo.
Me n'andrò.
Gigliola.
Scàcciala. Il laccio è teso anche per te.
Cieco tu sei. Io vedo.
Tibaldo.
Il ribrezzo ti va
innanzi alla parola. Di': che vedi?
Gigliola.
La turpitudine ovunque, la frode
servile, il tradimento. Profanàti
sono i miei occhi; e chiuderli non posso.
Tibaldo.
Con ogni tua parola
come con una branca
m'afferri il cuore e me lo serri. Dimmi
tutto.
Gigliola.
Sì, tutto debbo dire come
chi sta per trapassare.
Di tutte queste cose che m'insozzano
mi purificherò.
Una pausa.
Scàcciala. L'uomo
che ti voleva piegare la nuca
a terra, e tu l'hai morso
alla mano... Oh sozzura!
Si copre la faccia.
Tibaldo.
No, no, no!... Che sai tu? Come sai tu?
O figlia, tu vedere... No, no. L'odio...
l'odio t'abbaglia.
La voce di Angizia, nell'ombra della scala.
Tibaldo! Tibaldo!
SCENA SESTA.
La femmina appare.
Angizia.
Non rispondi? Che hai?
Ma sei di sasso? È vero
che c'è stato litigio
col fratellastro? che siete venuti
alle mani?
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!
testbankfan.com

Java Software Solutions 8th Edition Lewis Test Bank

  • 1.
    Java Software Solutions8th Edition Lewis Test Bank download pdf https://testbankfan.com/product/java-software-solutions-8th-edition- lewis-test-bank/ Visit testbankfan.com today to download the complete set of test banks or solution manuals!
  • 2.
    We believe theseproducts will be a great fit for you. Click the link to download now, or visit testbankfan.com to discover even more! Java Software Solutions 8th Edition Lewis Solutions Manual https://testbankfan.com/product/java-software-solutions-8th-edition- lewis-solutions-manual/ Java Software Solutions 9th Edition Lewis Test Bank https://testbankfan.com/product/java-software-solutions-9th-edition- lewis-test-bank/ Java Software Solutions 9th Edition Lewis Solutions Manual https://testbankfan.com/product/java-software-solutions-9th-edition- lewis-solutions-manual/ Essentials of Psychiatric Mental Health Nursing 1st Edition Varcarolis Test Bank https://testbankfan.com/product/essentials-of-psychiatric-mental- health-nursing-1st-edition-varcarolis-test-bank/
  • 3.
    Discrete Mathematics withApplications 4th Edition Susanna Solutions Manual https://testbankfan.com/product/discrete-mathematics-with- applications-4th-edition-susanna-solutions-manual/ Law for Business 11th Edition Barnes Test Bank https://testbankfan.com/product/law-for-business-11th-edition-barnes- test-bank/ Understanding Cross Cultural Management 2nd Edition Browaeys Solutions Manual https://testbankfan.com/product/understanding-cross-cultural- management-2nd-edition-browaeys-solutions-manual/ Organizational Behavior A Critical Thinking Approach 1st Edition Neck Solutions Manual https://testbankfan.com/product/organizational-behavior-a-critical- thinking-approach-1st-edition-neck-solutions-manual/ Principles of Leadership International 7th Edition DuBrin Test Bank https://testbankfan.com/product/principles-of-leadership- international-edition-7th-edition-dubrin-test-bank/
  • 4.
    Sociology in OurTimes 9th Edition Diana Test Bank https://testbankfan.com/product/sociology-in-our-times-9th-edition- diana-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.
    Random documents withunrelated content Scribd suggests to you:
  • 36.
    i passi ei balzi e i gridi sordi conta, ch'ella fa per sfuggire a quello sconosciuto ch'è rinchiuso con lei, a quell'essere enorme e beffardo ch'è nato a poco a poco dalla malattia, che s'è nutrito e ha fatto l'ossa ed ora è il compagno e il nemico, il custode e il padrone; che ha più carne di lei, che ha più soffio di lei, che la guarda, le parla, le s'accosta, la tocca, le rifiata vicino intollerabilmente, visibile e palpabile per lei sola... Donna Aldegrina. No, no! Taci. Ella pone le sue mani scarne su la bocca di Gigliola. Sei devastata, sei disperata fino a dentro, sei bruciata fino alta radice. Tutto quel che è misero e offeso e rotto e agonizzante parla per la tua bocca. Sei la voce della nostra ruina, di tutte le ruine senza scampo. O mia povera povera
  • 37.
    povera creatura, piccola animamia, per me piccola sempre, chi ti consolerà? chi t'inumidirà un'altra volta queste pàlpebre secche? Ahimè! Ahimè! Una pietra, una terra calcinata, una stoppia riarsa. E che farò per te io vecchia e lógora? Chi mai chi mai farà per te nel mondo alcuna cosa, o piccola mia sola? Gigliola. Io, io farò. Fare bisogna, fare bisogna. Alzarmi debbo, restar diritta in piedi fino all'ora di coricarmi. Baciami la fronte. Mi bacerai a sera un'altra volta. Così. M'alzo. Il coraggio non vacilla. Stanotte i manovali lavoreranno al lume delle fiaccole. Non lo sai? Tutta notte. Anch'io anch'io laggiù, in qualche parte, ho una fiaccola rossa nascosta sotto il moggio, sotto un moggio vecchissimo nascosta che non misura più perché non tiene più né grano né orzo. Entro i cerchi di ferro rugginoso ha le doghe sconnesse. Quella terrò nel pugno, a rischiarare il travaglio notturno intorno alla ruina. E se la casa crolla io sono certa che una sepoltura
  • 38.
    resterà ferma eimmune. Lo prometto. Donna Aldegrina. Gigliola, dove vai? Gigliola. A promettere. Entra sotto l'arcata dei mausolei: sparisce per la porta della cappella. Donna Aldegrina. Séguila, Annabella. Séguila in ogni passo. Non la lasciare mai. Ho paura, ho paura. Annabella. Signorìa, non m'attento. Vuol sempre stare sola quando scende alla Cappella e s'inginocchia a quella sepoltura. Posso mettermi là, dietro la porta. Donna Aldegrina. Non la lasciare. Va. Tu, Benedetta, guarda chi è su per la scala bassa. Benedetta, origliando. È la voce di Don Bertrando. Sale
  • 39.
    col fratellastro. Sentoanche la voce di Don Tibaldo. Donna Aldegrina. Si sarà levato Simonetto? Che ora è? Benedetta. Quasi ventun'ora, Signorìa. Donna Aldegrina. Va, va di sopra. Guarda se dorme ancóra. Non lo risvegliare se dorme. Ma se è sveglio fa che si levi, e prenda la medicina. Benedetta. Signorìa, non vuole la sorella che prenda medicina se non glie la prepara con le sue mani. Donna Aldegrina. Perché? Benedetta. Io non so. Ha il suo pensiero. Donna Aldegrina.
  • 40.
    Salgo anch'io frapoco. Annabella! Annabella! La vecchia scompare sotto l'arcata chiamando sommessamente la nutrice. Con lei entra nella cappella. Benedetta si avvia su per la scala, sospirando. SCENA TERZA. Entrano, per la scala che dà su la loggetta, sotto l'armatura di travi e di corde, Tibaldo de Sangro e Bertrando Acclozamòra, i fratellastri. Bertrando. Dunque rifiuti? È l'ultima parola? Tibaldo. Non ho manco un tornese! Non so come farò a pagar la giornata dei manovali. E se non pago, Mastro Domenico di Pace lascia che tutto vada a precipizio: leva i puntelli. Intendi? Bertrando. Tu mentisci. Tibaldo. Vedi: mia madre fruga tutte le cartapecore
  • 41.
    degli scaffali, mettesottosopra l'archivio, lo riscontra a filza a filza, ci si logora gli occhi... Ah, se si ritrovasse l'istrumento di quel vincolo fidecommissario, nella lite che abbiamo coi Mormile! Bertrando. Non divagare. Ti domando ancóra una volta: mi dài quella miseria? Tibaldo. Ma se ti dico che non ho un tornese! Credimi. Bertrando. Tu mentisci. Non riscotesti ieri da Crescenzo Castoldo centoventi ducati di caparra pel grano che gli devi consegnare dopo la mietitura? Tibaldo. Non è vero. Bertrando. Hai coraggio di negarlo! Bene ti s'è indurato il sangue su cotesto viso giallo, come la sugna ràncida nella vescica risecchita.
  • 42.
    Tibaldo. Ancóra cerchi di sopraffarmicon l'ingiuria. È il raccolto del campo di Malvese, ch'è di mio figlio, dell'eredità di sua madre. Bertrando. Ma il frutto è tuo. Tibaldo. Non posso toccarlo. Bertrando. Tu! tu che conficchi ovunque le tue granfie ed hai solo lo scrupolo del tarlo che ha roso il Cristo e non voleva rodere il chiodo! Razza dei Sangro. Tibaldo. Ma chi, ma chi è che mi succhia, chi è che mi dissangua da vent'anni senza tregua? Bertrando. Di tutto il mio ti sei impossessato con l'usura. Tibaldo.
  • 43.
    Quali erano i benidegli Acclozamòra? Bertrando. Incominciò tuo padre a spogliarci. Tibaldo. Di che? Fra la Serra dei Curti e il Sirente avevate i vostri latifondi? Ovìndoli è paese di pecorai. Bertrando. Avevamo Celano, avevamo Paterno, Aielli... Tibaldo. Al tempo degli Aragonesi, sotto il buon re Alfonso. Ti ripigliò mio padre nella casa, te con tua moglie, quando non t'era altro rimasto se non un branco di cinquanta pecore, le formelle di faggio e le casciaie. Bertrando. Nominarmi il tuo padre tu osi e rinfacciarmi il benefizio!
  • 44.
    Qual benefizio? Ame restituire doveva quel che a me minore avea frodato. La tutela fu il latrocinio guarentito. Parli, parli quella che è vedova due volte... Tibaldo. Tu di tutte le infamie ti lordi la tua bocca di mastino; e sempre tu sei pronto ad addentare fino al sangue e all'osso, se non ricevi l'offa. Bertrando. Non aizzare il mastino, Tibaldo. Tibaldo. Che vuoi da me? ch'io mi ti dia legato mani e piedi? vuoi darmi la sorte di Giovanna? seppellirmi vivo fra quattro mura? e gavazzare poi con le tue scrofe e coi tuoi bardassoni su gli avanzi dei Sangro? Metti almeno un bavaglio alla vittima, ché troppo si sente gridare; e v'è taluno che volge il capo in su. Bertrando. Guardami fiso, guardami negli occhi, tu che parli di vittime. Ben una t'è stampata
  • 45.
    in fondo allapupilla, o vedovo di Mònica, marito della femmina marsa. Tibaldo. Oh! Oh! Una mi vedi nella pupilla? Sono io stato fiso? E certo m'hai veduto impallidire. Ride sardonico. Bertrando. Sei la vescica di grassume smorto che non si muta. Tibaldo. Almeno tu mi vedi tremare. Guarda come mi tremano le due mani. Ho il parlético. Bertrando. La malattia ti rode le vertebre. Finito sei. Tibaldo. O Giudice profondo, e che farai se l'assassino è pallido e tremante anche quando gli dici che hai veduto una milza di bue penzolare alla porta d'un macello?
  • 46.
    Bertrando. Non ridere, nonridere così; o ti schiaccio su i denti il ghigno. Tibaldo. E che farai, Giudice, se ogni sera l'assassino scaccia di sotto al letto con la scarpa il rimorso importuno? Con una vecchia scarpa, come si scaccia un sorcio. Bertrando. Ridi, ridi; e nel bianco degli occhi hai lo spavento. E il tuo riso di dentro cigola, peggio che una vecchia imposta sconquassata lassù nell'ultima finestra lassù perduta sotto la grondaia rotta. Il vento la strappa dagli arpioni. E ti casca sul collo e te lo stronca. Bada che la tua beffa non ti ritorni sopra d'un colpo. Tibaldo. Sì, mi bado. Non passo già per gli anditi scuri né per le scale strette, quando sei nella casa.
  • 47.
    Bertrando. T'odio, con ogni gocciadel mio sangue contro ogni goccia del tuo. Intendi? Tu m'ingombri. Il tuo fiato m'attossica l'aria che serve al mio polmone. Fino nel ventre di mia madre tu m'hai preso il mio posto: sei venuto dopo di me nel conio della mia razza, tu mollume senza scheletro, nato dal seme d'un vecchio. E l'essere tu nato mi fu sempre un sopruso che mai non seppi perdonarti. Intendi? E di nessuna carne umana sento ribrezzo come della tua; né so perché. L'ho dentro le midolle, cieco e bestiale. Tutto di te m'offende: il passo, il gesto, il riso, il respiro, lo sguardo. Quella bolla bianchiccia di saliva che ti nasce nel canto delle labbra se ciarli, mi fa ira, m'esaspera. Ho un rancore mortale contro le tue mani flosce che mostrano l'enfiore del mal cardìaco... Tibaldo subitamente s'accascia. Tibaldo. Ohimè! È vero, è vero. È
  • 48.
    È l'edema, èl'edema molle e freddo che cede al dito e resta là col cavo. Il mio cuore è ammalato. Morirò di sùbito passando quella porta. E tu prendilo e gettalo nel letamaio, questo mio cuore, come un fico putrefatto; e una gallina lo trovi raspando e se lo porti nel becco a pollaio... Bertrando, io t'ho negato quei cinquanta ducati, mentre debbo morire! Te li darò. Aspetta. Bertrando gli si avvicina. Bertrando. Soffri? Hai tremor di cuore? Io non voleva farti violenza. Ma tu lo sai: mi lascio trascinare dalla collera... Soffri? Tibaldo. Te li darò. Ma non li ho qui. Bisogna che tu venga con me... Bertrando. Dove? Tibaldo. Dove ho accumulato...
  • 49.
    Bertrando. Dove? Tibaldo. Ah, se potessiconfidarmi in te come nel mio fratello! Bertrando. Non sono il tuo fratello? Tibaldo. M'odii, con ogni goccia del tuo sangue. L'hai detto. Bertrando. Sì, nell'impeto dell'ira. Ti piaci d'aizzarmi: ti fai beffe di me... Ma poi tu stesso ridi della mia furia. Tibaldo. Non m'hai più odio! Posso confidarmi dunque? Bertrando. Parla. Tibaldo. Il tesoro...
  • 50.
    Bertrando. Dov'è? Parla. T'ascolto.Non temere. Tibaldo. Tu sai la vecchia diceria che corre tra la gente d'Anversa, e per tutta la valle del Sagittario, e dalla Forca d'oro alla Terrata fra i pastori. Bertrando. Sì, la so. Tibaldo. La casa magna dei Sangro, quella delle cento stanze, tutta crepacci e tutta ragnateli, che da tutte le bande si sgretola, e nessuno ci rimette pur una mestolata di calcina... Bertrando. Si, sì, la so. Tibaldo. E la famiglia fa magra cucina. E dentro un muro cieco è nascosto il tesoro di Don Simone; ed ogni primogenito eredita il segreto e l'avarizia...
  • 51.
    Bertrando. Ebbene? Tibaldo. Quanto sei impaziente, fratello! Vuoiche ti dica come stride ogni chiave arrugginita? come cigola ogni uscio sgangherato? Vuoi che ti nòveri tutto quel che si macchia, quel che si scolora, quel che si sloga, si curva, si sfalda, s'ammolla, cola, marcisce? Bertrando, oscurandosi. Tibaldo, non divagare. Tibaldo. Ascolta. Ho un po' d'affanno. Ansa e soffia, simulando. Ascolta. Il mio figliolo Simonetto è infermiccio, ed è svanito, anch'egli — ahimè — di vita troppo breve. E se ne va la primogenitura... Ah se tu non mi fossi tanto nemico! Acclozamòra contro Sangro. Bertrando.
  • 52.
    Io nemico? Ohno! Tibaldo. M'ingiurii sempre. Bertrando. Ma senza fiele. Per caldezza di sangue. La stessa madre ci portò. Se tu non mi rinneghi, io sono il tuo fratello, a cuore aperto. Le parole volano. Dimentica, ti prego. Ecco la mano. Tibaldo rompe con uno scoppio di scherno la sua simulazione. Tibaldo. Tieni: un ducato, un ducato! Non vale di più questo tuo sùbito amor fraterno. Tieni. Per un ducato, lo compero. Bertrando. Ah mulo! Tibaldo. Prendilo dalla mano floscia. Ancóra mi regge al riso il cuore ammalato. Anzi questo mi giova meglio che la digitale.
  • 53.
    Bertrando. Non ti giova.Ti metto sotto i piedi, ti spezzo quel tuo dosso di buffone! Ah, per dio, questa volta non ti salvi da me. Ti faccio mordere, giuro, i tuoi calcinacci. Tibaldo. Lasciami! Bruto! Bruto! Bertrando. Giù! La nuca a terra! Acclozamòra contro Sangro. Tibaldo. No! Lasciami! Assassino! Bertrando. Mordi come una femmina... Tibaldo. Assassino! SCENA QUARTA. Appare la madre, accorrendo dalla cappella. E dietro di lei viene Gigliola, seguita da Annabella; e rimangono quivi in disparte.
  • 54.
    Donna Aldegrina. Figli! Figli!Bertrando! Ah vergogna, vergogna! Forsennati! Non avete onta? Mi volete morta d'orrore? Su, gettatevi contro me. Su, rompetemi il mio petto. Su, squassatemi i miei capelli bianchi, più bianchi di dolore che di vecchiezza, e per voi, figli tristi, per voi nati da me, dalle mie viscere dilaniate. Ma che latte mai vi diedi io, che latte malvagio, perché me lo rendiate in stille e in sorsi di tòssico, ogni giorno? O Bertrando, o selvaggio, che follìa t'ha invasato? Sempre in guerra sei. Dove tu tocchi lasci l'impronta dell'artiglio. Sempre teso a nuocere. Metti dunque la mano anche su me. Soltanto questo ti resta. Bertrando. Taci, madre. So che non m'ami, da quando ti fu grave l'esser fedele ad una tomba, e guasto mi fu il mio nido, e imposta mi fu la servitù verso gli intrusi sempre più dura; e il vecchio nome, il mio, ti sonò male come una rampogna. Donna Aldegrina. Misero te! Non è la prima volta
  • 55.
    che tu morditua madre alla mammella. Bertrando. Non mordo io già. Costui, vedi, ha tentato di mordermi le dita con i suoi denti di coniglio. E tu proteggilo. Proteggi costui che ha il viso smorto e il fiato grosso. Ei n'ha bisogno. Ma consiglialo a restar nascosto lungo tempo sotto le coltri. Donna Aldegrina. O selvaggio, non vedi che la sua figlia è là con la faccia nascosta? Bertrando. Dille che, s'ella guarda nella pupilla al vedovo riammogliato, se gli guarda in fondo, vedrà... Donna Aldegrina. Bertrando! Bertrando! Bertrando. Sì, taccio. Addio, madre. O Tibaldo, il tuo ducato, guarda, è rimasto per terra: mostra il rovescio. Bada!
  • 56.
    Raccàttalo e siicauto. Spinge col piede la moneta verso il fratellastro; poi apre la porta sinistra per uscire. Addio, madre. Donna Aldegrina, seguendolo. Bertrando, non andartene così. Ti prego! Torna in pace. Stendi la mano al tuo fratello. Bertrando. Per un ducato? Esce. Donna Aldegrina. Aspetta! Ascolta la tua madre. Ti prego! Segue il figlio, che non si volge. SCENA QUINTA. Tibaldo de Sangro rimane seduto, tra le cartapecore, a capo chino, ancora affannato dalla lotta e pallidissimo. Gigliola leva il capo, guarda il padre, cammina verso di lui. S'odono le voci di fatica lontane.
  • 57.
    Gigliola. Vattene, Annabella. Si soffermae segue con lo sguardo la nutrice che; se ne va silenziosamente, su per l'ombra della scala. Poi s'accosta al padre, e la voce le trema. Padre, son io. Non c'è nessuno più. Son io sola, con te. Egli si leva, timidamente, vacillando un poco, senza osare di guardare in viso la figlia. Tibaldo. Gigliola! Gigliola. Oh no, non devi sorridere così. Tu mi faresti meno male, se tu mi calpestassi. Tibaldo. Non ti devo sorridere... Perché? Ti faccio male... Non so... Lascia allora ch'io mi metta in ginocchio avanti a te, figlia. Non so che altro potrei, figlia, ora. Tu no, non mi faresti male se tu mi calpestassi. Ma ti benedirei. Gigliola.
  • 58.
    No, no, nonin ginocchio. Sta diritto. Una pausa. Corruga le ciglia. Chi ti voleva piegare la nuca a terra? Tibaldo. Figlia, abbi pietà del tuo padre se tu sei stata testimone della vergogna. Gigliola. Tremi tutto. Sei più bianco della tua camicia. Tibaldo. Soffro un poco. Gigliola. Certo, tu non tremi... è vero? tu non tremi... per quello. Tibaldo. Per quello? Una pausa. Gigliola.
  • 59.
    Padre! Tibaldo. Di': che hai?che vuoi, Gigliola? Parla. Gigliola. Tu non hai paura. Tibaldo. Di chi? Una pausa. Gigliola. Gli hai morso la mano. Tibaldo. Gigliola... Gigliola. Forte? Tibaldo. Che mi domandi! Gigliola. Forte dovevi. Tu non hai paura; è vero?
  • 60.
    Tibaldo, balbettando. Ma chehai? Che mi domandi! Se tu hai veduto quello che non doveva esser veduto dagli occhi tuoi, perdónami, perdónami. Gigliola. Tutto ho veduto, veggo. Non ho più ciglia: sono senza pàlpebre: gli occhi miei non si serrano più, non battono più. Veggo, terribilmente. Tibaldo. Gigliola sei? Che mai avvenne? Chi ti dà questa forza? Che gridi, quanti gridi nella tua voce sorda! Gigliola. Dimenticato avevi il suono della mia gola ferita. Tibaldo. Rimasta eri velata per me, tutta velata dal tuo lutto, in disparte. Gigliola. T'è nuova la mia voce? Per un anno in silenzio
  • 61.
    ho portata lapiaga senza sangue, la piaga che fu fatta anche a me in un punto, lo sai, qui d'intorno al respiro... Tibaldo. Come ti guarderò? Eri velata. Vivere ho potuto, esiliato dall'anima tua, con l'amore dell'esule pel piccolo giardino ove non entra più... Gigliola. Tutto è arso. Non aver parole di tenerezza per la creatura abbandonata nell'orrore, sola, come in fondo al burrone, come in mezzo al ghiacciaio. Ma guardami; ma leva gli occhi. Guardami quale sono: non più piccola e neppure più dolce... Nulla di giovine è rimasto in me. Passata in un anno è la mia primavera. Mi sono maturata non al sole ma all'ombra, all'ombra d'una sepoltura. Guardami; ché devo interrogarti, e il tempo incalza. Ho fretta. Con uno sforzo angoscioso il padre solleva le palpebre, la fisa.
  • 62.
    Tibaldo. Oh, l'orrore, l'orrore nellatua faccia, gli occhi senza pàlpebre! Figlia, e m'odii anche tu? E chi t'ha fatta così dura? Dimmi. Gigliola. Ti ricordi? Fra poche ore viene quell'ora: verso sera. Mia madre fu chiamata; e la povera entrò nella stanza già scura. E, poco dopo, quell'altra, la serva tortuosa, la femmina di Luco, escì gridando. E già la vittima non si moveva più... Tibaldo. No, no, non seguitare! Gigliola. Bisogna che tu m'oda, e che tu mi risponda. Quell'altra è la tua moglie oggi. Tu me l'hai data per padrona. Mi fu tolta la madre e mi fu data per padrona colei che con lo straccio lavava il pavimento. Non è vero? Ma guardami! Tibaldo. Non posso più. Non ho più forza.
  • 63.
    Gigliola. Eppure bisogna che, congli occhi negli occhi, a viso a viso, tu mi risponda. Tibaldo. Sùbito parla. Dimmi che vuoi. Ti guardo. Gigliola. Sai la verità? Tibaldo. Ma quale? Gigliola. No, padre, no, non mi sfuggire. Tieni ferma l'anima tua nella pupilla come ho ferma la mia. Chi la fece morire? La verità! La verità! Tibaldo. Non fu la sorte iniqua? la percossa cieca? Gigliola. Oh ti supplico, padre! Non mi mentire. Parlami
  • 64.
    come s'io fossimoribonda, come se dopo io mi dovessi avere negli orecchi e nella bocca il suggello per sempre. Non lo sai? Non sospetti? Quell'altra che uscì gridando... Tibaldo. No, no! Gigliola. Ma sei tutto bianco. Tibaldo. Oh! Oh! E tu pensi, figlia, tu pensi di me questa infàmia: ch'io t'avrei sottoposta a tanto orrore nella casa dove mi nascesti, ch'io complice avrei congiunto col legame orrendo la bestia criminosa e la tua purità, qui nella casa dov'è custodita quella che fu sepolta... Gigliola. Silenziosamente sepolta fu, silenziosamente: ed ogni viso intorno era come la pietra sepolcrale, come la pietra che si pone sopra la cosa buia e segreta. E il tuo viso...
  • 65.
    Tibaldo. Il mio viso... Gigliola. Pareva cheavesse un marchio d'onta. Oh che pietà di te, padre! Ma tutto dire debbo. Pareva che già lo difformasse l'obliquità che poi ho riveduta mille volte, la maschera convulsa che t'ha messa la femmina e che tu non puoi strapparti... Tibaldo. Me la vedi? qui? l'ho qui? Se piango, non si fende? Ma chi t'ha fatta così crudele? Chi t'ha mutata, anche te? t'ha convulsa, anche te? Tu non sei più Gigliola. Gigliola. Non sono più Gigliola. Maturata sono, disfatta, e non dall'ombra sola di quel sepolcro ma dal fiato impuro che m'alita su l'anima continuo, e da quel tuo sorriso, dal sorriso di vergogna, che per un anno fu il segno della tua bontà paterna! Tibaldo.
  • 66.
    Mi struggevo d'amore perte, con un rimpianto senza fine, esiliato dall'anima tua, esiliato da tutte le dolci cose che conoscevo in te che m'eri il fiore di questo tronco guasto. Gigliola. E perché l'hai gittato, il fiore, sotto i piedi assuefatti a camminare scalzi nell'immondezza? Tibaldo. Come potresti tu comprendere il mio male disperato, la mia miseria senza riparo? Gigliola. Ah che pietà di te! Non sono crudele. Tibaldo. Me n'andrò, scomparirò. Non mi vedrai. Vuoi questo? Gigliola. Scàcciala. Tibaldo.
  • 67.
    Tu non puoi,non puoi comprendere! Gigliola. Scàcciala. Tibaldo. Me n'andrò. Gigliola. Scàcciala. Il laccio è teso anche per te. Cieco tu sei. Io vedo. Tibaldo. Il ribrezzo ti va innanzi alla parola. Di': che vedi? Gigliola. La turpitudine ovunque, la frode servile, il tradimento. Profanàti sono i miei occhi; e chiuderli non posso. Tibaldo. Con ogni tua parola come con una branca m'afferri il cuore e me lo serri. Dimmi tutto. Gigliola. Sì, tutto debbo dire come chi sta per trapassare. Di tutte queste cose che m'insozzano
  • 68.
    mi purificherò. Una pausa. Scàcciala.L'uomo che ti voleva piegare la nuca a terra, e tu l'hai morso alla mano... Oh sozzura! Si copre la faccia. Tibaldo. No, no, no!... Che sai tu? Come sai tu? O figlia, tu vedere... No, no. L'odio... l'odio t'abbaglia. La voce di Angizia, nell'ombra della scala. Tibaldo! Tibaldo! SCENA SESTA. La femmina appare. Angizia. Non rispondi? Che hai? Ma sei di sasso? È vero che c'è stato litigio col fratellastro? che siete venuti alle mani?
  • 69.
    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! testbankfan.com