Download all chapters of Test Bank for Java Programming, 9th Edition, Joyce Farrell, ISBN-10: 1337397075, ISBN-13: 9781337397070 as a single PDF instantly.
Download all chapters of Test Bank for Java Programming, 9th Edition, Joyce Farrell, ISBN-10: 1337397075, ISBN-13: 9781337397070 as a single PDF instantly.
com
https://testbankmall.com/product/test-bank-for-java-
programming-9th-edition-joyce-farrell-
isbn-10-1337397075-isbn-13-9781337397070/
OR CLICK HERE
DOWLOAD NOW
Visit now to discover comprehensive Test Banks for All Subjects at testbankmall.com
Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...
https://testbankmall.com/product/java-programming-9th-edition-joyce-
farrell-solutions-manual/
testbankmall.com
https://testbankmall.com/product/java-programming-8th-edition-joyce-
farrell-solutions-manual/
testbankmall.com
https://testbankmall.com/product/test-bank-for-chemistry-9th-edition-
zumdahl-isbn-10-1133611095-isbn-13-9781133611097/
testbankmall.com
https://testbankmall.com/product/test-bank-for-organic-chemistry-9th-
edition-leroy-g-wade-isbn-10-032197137x-isbn-13-9780321971371/
testbankmall.com
https://testbankmall.com/product/solution-manual-for-programming-
logic-design-comprehensive-9th-edition-joyce-farrell/
testbankmall.com
8. A compiler ignores whitespace (that is, any combination of nonprinting characters) between words and lines.
a. True
b. False
ANSWER: True
9. Dots (or periods) in a Java statement are used to separate the names of the components that make up the statement.
a. True
b. False
ANSWER: True
10. Using the void keyword in the main() method header indicates that a value will be returned by the main()
method is called.
a. True
b. False
ANSWER: False
Multiple Choice
12. Locating and repairing all syntax errors is part of the process of ____ a program.
a. interpreting b. compiling
c. debugging d. executing
ANSWER: c
13. ____ are also called modules, methods, functions, and subroutines. Java programmers most frequently use the term
“method.”
a. Procedures b. Calls
c. Classes d. Applications
ANSWER: a
14. ____ refers to the hiding of data and methods within an object.
a. Instance b. Inheritance
c. Passed d. Encapsulation
ANSWER: d
15. ____ describes the feature of languages that allows the same word to be interpreted correctly in different situations
based on the context.
a. Polymorphism b. Architecturally neutral
c. Source code d. Insulation
Copyright Cengage Learning. Powered by Cognero. Page 2
Name: Class: Date:
17. ____ are pieces of information that are sent into, or passed to, a method, usually because the method requires the
information to perform its task or carry out its purpose.
a. Applets b. Methods
c. Arguments d. Objects
ANSWER: c
18. A(n) ____ defines the circumstances under which a class can be accessed and the other classes that have the right to
use a class.
a. identifier b. access specifier
c. parameter d. Pascal casing
ANSWER: b
19. In Java, the reserved keyword ____ means that a method is accessible and usable even though no objects of the class
exist.
a. active b. undefined
c. static d. void
ANSWER: c
21. In a ____ environment, you can change directories using the cd command. For example, to change to a directory
named MyClasses, you type cd MyClasses and press Enter.
a. Windows b. Java
c. graphical d. DOS
ANSWER: d
22. After a successful compile, you can run the class file on any computer that has a ____.
a. Java language interpreter b. Web browser
c. text editor d. DOS
ANSWER: a
23. Java contains a class named ____ that allows you to produce dialog boxes.
a. JBox b. JOptionPane
c. JDialog d. JGUI
Copyright Cengage Learning. Powered by Cognero. Page 3
Name: Class: Date:
24. Whenever a method requires multiple arguments, the arguments are always separated with ____.
a. commas b. periods
c. forward slashes d. brackets
ANSWER: a
25. If a compiler detects a violation of language rules, it refuses to translate the class to ____.
a. an application b. a logic error
c. machine code d. Java
ANSWER: c
26. ____ is the process the compiler uses to divide your source code into meaningful portions; the message means that the
compiler was in the process of analyzing the code when the end of the file was encountered prematurely.
a. Running b. Debugging
c. Compiling d. Parsing
ANSWER: d
27. A ____ is an error not detected until the program asks the computer to do something wrong, or even illegal, while
executing.
a. syntax error b. run-time error
c. package d. Java API
ANSWER: b
28. It is best to use the ____ available text editor when writing Java programs.
a. most complex b. simplest
c. best d. latest
ANSWER: b
29. It is a tradition among programmers that the first program you write in any language produces “____” as its output.
a. Hi, your name! b. Hello, world!
c. My first program! d. Hello, your name!
ANSWER: b
30. When you run a Java application using the ____ command, do not add the .class extension to the filename.
a. class b. static
c. java d. output
ANSWER: c
31. If you receive an error that states, “Exception in thread ‘main’ java.lang.NoClassDefFoundError,” when you try to
execute the application, you probably do not have your ____ set correctly.
a. class length b. class path
c. java d. object
ANSWER: b
Given the above code, which item identifies the access specifier?
a. public b. static
c. void d. First
ANSWER: a
Given the above code, which item identifies the name of the class?
a. public b. static
c. void d. First
ANSWER: d
Given the above code, which item identifies the method’s return type?
a. public b. static
c. void d. println
ANSWER: c
Given the above code, which item identifies that the method will work without instantiating an object of the class?
a. public b. static
c. void d. println
Copyright Cengage Learning. Powered by Cognero. Page 5
Name: Class: Date:
36. In programming, named computer memory locations are called ____because they hold values that might vary.
a. constants b. variables
c. strings d. addresses
ANSWER: b
37. ____ comments are a special case of block comments that are used to generate documentation.
a. Line comments b. Doc comments
c. JDoc d. Javadoc
ANSWER: d
38. You use an import statement when you want to access a built-in Java class that is contained in a group of classes
called a(n) ____.
a. JGroup b. JImport
c. package d. GUI
ANSWER: c
39. A(n) ____ error occurs when the syntax of the program is correct and the program compiles but produces incorrect
results when you execute it.
a. logic b. syntax
c. JVM d. class
ANSWER: a
40. The ____ is also called the Java class library; it contains information about how to use every prewritten Java class,
including lists of all the methods you can use with the classes.
a. Java package b. Java Interface
c. Java SDK d. Java API
ANSWER: d
41. A class named first is different from a class named FIRST because ____.
a. Java is case insensitive b. it is confusing to have two names that look the same
c. Java is case sensitive d. first and FIRST are different literal strings
ANSWER: c
42. Programmers use ____ to organize program code and make it easier to read.
a. literal strings b. whitespace
c. headings d. FAQs
ANSWER: b
43. What is the purpose of the argument "null" in the statement below:
JOptionPane.showMessageDialog(null, “Show my message”);
a. This argument is ignored by Java. b. The output message will be placed in the upper left
corner of the screen.
44. Using the given code, which statement in the main() method body will produce the output “Hello to all!”.
public class Hello
{
public static void main(String[] args)
{
____
}
{
a. System.out(“Hello to all!”); b. System.println(“Hello to all!”);
c. println(“Hello to all!”); d. System.out.println(“Hello to all!”);
ANSWER: d
45. A(n) ____ is a GUI object resembling a window in which you can place messages you want to display.
a. JDK b. dialog box
c. variable d. argument
ANSWER: b
Matching
54. A GUI object resembling a window in which you can place messages you want to display
ANSWER: c
61. Why is creating a GUI environment for users a natural use for object orientation?
ANSWER: Creating a GUI environment for users also is a natural use for object orientation. It is easy to think of the
components a user manipulates on a computer screen, such as buttons and scroll bars, as similar to real-world
objects. Each GUI object contains data—for example, a button on a screen has a specific size and color. Each
object also contains behaviors—for example, each button can be clicked and reacts in a specific way when
clicked. Some people consider the term object-oriented programming to be synonymous with GUI
programming, but object-oriented programming means more.
Copyright Cengage Learning. Powered by Cognero. Page 8
Name: Class: Date:
62. Describe the components (objects and classes) that are used in the statement System.out.println().
ANSWER: Within the statement System.out.println("First Java application");, the method to which
you are passing "First Java application" is named println(). The Java methods println() and
print() both produce output. With println(), after the output is displayed, the insertion point moves to
the following line so that subsequent output appears on a new line. With print(), however, the insertion
point does not advance to a new line, so subsequent output appears at the end of the current line.
Within the statement System.out.println("First Java application");, out is an object that
is a property of the System class that refers to the standard output device for a system, normally the monitor.
The out object itself is an instance of the PrintStream class, which contains several methods, including
println().
Within the statement System.out.println("First Java application");, System is a
class. Therefore, System defines attributes for System objects, just as the Dog class defines the attributes
for Dog objects. One of the System attributes is out. The dots (periods) in System.out.println() are
used to separate the names of the components in the statement.
63. When you define a Java class using an identifier, what are the requirements you need to know?
ANSWER: You can define a Java class using any name or identifier you need, as long as it meets the following
requirements:
• A Java identifier must begin with a letter of the English alphabet, a non-English letter (such as α or π),
an underscore, or a dollar sign. A class name cannot begin with a digit.
• A Java identifier can contain only letters, digits, underscores, or dollar signs.
• A Java identifier cannot be a reserved keyword, such as public or class.
• A Java identifier cannot be one of the following values: true, false, or null. These are not keywords
(they are primitive values), but they are reserved and cannot be used.
64. Regarding code layout, write the following Java code using a common alternate placement of the first curly brace:
public static void main(String[] args)
{
System.out.println("First Java application");
}
ANSWER: public static void main(String[] args) {
System.out.println("First Java application");
}
66. What are some of the reasons the javac command might not be recognized?
ANSWER: You made a typo error when typing the command javac.
You misspelled the filename.
You are not within the correct subfolder or subdirectory on your command line.
Copyright Cengage Learning. Powered by Cognero. Page 9
Name: Class: Date:
67. What happens after a programmer successfully compiles a Java program named “First.java”?
ANSWER: If you receive no error messages after compiling the code in a file named First.java, the application compiled
successfully. In that case, a file named First.class is created and saved in the same folder as the text file that
holds the source code. After a successful compile, you can execute the program (run the class file) on any
computer that has a Java language interpreter.
68. If you modify a class, what are the steps you must take to see your changes in the executing program?
ANSWER: 1. Save the file with the changes (using the same filename).
2. Recompile the class with the javac command.
3. Interpret the class bytecode and execute the class using the java command.
69. Provide examples of logic errors. How do programmers minimize logic errors in their code?
ANSWER: Examples of logic errors include multiplying two values when you meant to add, printing one copy of a report
when you meant to print five, or forgetting to produce a total at the end of a business report when a user
has requested one. Errors of this type must be detected by carefully examining the program output. It is the
responsibility of the program author to test programs and find any logic errors. Good programming practices
can help to minimize errors.
70. Explain the purpose of arguments and why it is necessary to pass arguments to a method.
ANSWER: Arguments are pieces of information that are sent to a method. The act of sending arguments to a method is
called passing arguments to the method. You pass methods to arguments so they know what information to
work with.
72. Once an application is written and saved, the Java class must be compiled. Describe what two procedures must occur
in order to view the output of the application.
ANSWER:
1. You must compile the class you wrote (called the source code) into bytecode.
2. You must use the Java interpreter to translate the bytecode into executable statements.
74. Write a line comment and block comment for the following line of code identifying the author, date, and purpose of
the method. In addition, explain the difference between comments that consist of a double-slash (//) and those that have a
starting and ending slash asterisk (/* .. */).
System.out.println(“Hello Students”);
ANSWER: Possible comments include:
// Written by <your name>
// Written on <date>
/* The println method will output “Hello Students” */
// - used for line comments
/* - used for block comments */
Given the above code, identify and describe the use of a literal string and the use of parentheses.
ANSWER: A literal string is a series of characters that will appear exactly as entered. Any literal string in Java is written
between double quotation marks. The string “First Java application” appears within parentheses because the
string is an argument to a method, and arguments to methods always appear within parentheses.
76. What are the differences between K & R style and Allman style? Which one is used in this textbook?
ANSWER: The indent style in which opening braces do not stand alone on separate lines, is known as the K & R style and
is named for Kernighan and Ritchie, who wrote the first book about the C programming language. The indent
style in which curly braces are aligned and each occupies its own line, is called the Allman style and is named
for Eric Allman, a programmer who popularized the style. The Allman style is used throughout this book.
Moore.
——Know ye not
Who would be free, themselves must strike the blow.
Childe Harold.
men unaccused of crime, and eating the daily bread of honest labour
—consigning them, I say, and their posterity to hopeless vassalage,
and degrading chattelhood, by a process, too, which tramples under
foot the most ancient and sacred guarantees of my own and my
neighbour’s rights. When I see this great nation lay its terrible grasp
upon the throat of a feeble, unoffending man, and thrust him back
to worse than a felon’s fate for doing that which no casuistry can
torture into a crime, I am compelled to feel that it is myself engaged
in this atrocious business; and no one but myself can rid me of the
responsibility. I can no longer be silent; I dare no longer be silent; I
will no longer be silent. I will remonstrate and cry, shame! I will
refuse to obey the law; I will demand to be released, and to have
my country released, from its odious requirements. I will vote, and
influence voters, and use every prerogative of freedom, to throw at
least from off my conscience a burden that it cannot bear. And who
that is worthy to be free himself, will blame me? To speak is no
longer a mere right; it has become a religious duty.
Let no man tell me, that this law is a mere dead letter. The old
Fugitive Law, had, indeed, become so; and so would any other be
likely to become, which, while grasping after the slave, should pay a
decent respect to the rights of the free. But slavery cannot subsist
on any such condition; and this law was framed to supply the
deficiencies of the old law, and to accomplish the thing. It is based
on the assumption that the government of the United States is
bound to effect the rendition of fugitives, if possible at all, at
whatever cost. And, if this law is insufficient, the assumption is
equally good for still more stringent measures. But I repeat it, let no
man tell me it is now a nullity. Have we not seen it executed in our
streets, and at our very doors? I chanced to be in the city of New
York at the time when, I think, its first victim, Henry Long, was torn
from his family, and from a reputable and profitable business, and
sent back,—limbs, and brain, and throbbing, loving heart—the
husband, father, friend, the peaceful and industrious member of
society, all, to be the property of a fellow-mortal in a hostile land.
Could I look upon this crimeless man, thus in the grasp of the
officers of my country’s laws, my own representatives, and hurried
unresisting to that dreadful doom; and ever be able to believe the
law innocuous, and myself guiltless while I acquiesced in silence?
The rabble followed him along the streets, shouting in exultation at
the negro’s fate. Them I must acknowledge as my fellows and
brethren, but him—on him I must put my heel, with theirs, to crush
him out of manhood! And the morrow’s papers, edited by professed
Christians, heralded the occurrence, with not even a decent pretence
of pity and regret, but as a triumph of LAW, (O sacred name
profaned!) in which all good men should rejoice. That day I felt a
stifling sensation settling down upon me, of which my previous
experience had afforded no precedent, and with an oppressive
weight which no language can describe. I felt that I no longer
breathed the air of liberty; that slavery was spreading her upas
branches athwart my sky also. The convenient apology that the sin
was not mine, but another’s, no longer stood me in stead; and I
have wondered ever since to hear any honest Northern man employ
it. There are Northern men, from whom nothing could surprise me.
And what have we since witnessed? The inferior officers of the law
prowling throughout the North for victims on whom to enforce it.
Their superiors, even to the highest, labouring by speeches and
proclamations and journeyings to an fro in the land (is it too much to
say?) to dragoon the people into its support. The national treasury
thrown wide open to meet its “extraordinary expenses.” Fanueil Hall
hung in chains, to ensure its execution. Presidential candidates
vieing with each other in expressions of attachment and fidelity to it.
Able men, in Church and State, spotted for proscription for no other
sin than hating that law, and daring to declare that hatred. And to
crown the whole, the wisdom of the nation, in Baltimore
Conventions once and again assembled, pronouncing the new
doctrines of constitutional responsibility, with the law that embodies
it, not only a certainty, but—(hear it, O heavens!) a finality! A new
word in the political vocabulary, and verily a new thing in the earth!
“Finality,” in the legislation of freemen! A finality, that for ever
precludes reconsideration, amendment, or repeal! When such things
are said, and gravely said, by men professing to be American
statesmen, I can almost imagine the fathers of my country turning
painfully in their graves. And can it be possible, that in the same
breath with which men assume to roll political responsibilities on
freemen, they dare require perpetual silence and unconsidering
submission thereto? Then, what is it to be free?
But let no one dream that these formidable pronouncements have
any enduring force. It is natural, that Southern statesmen should
seek, by every possible expedient, to keep out the flood of
discussion from a system which can so illy bear it. And it is not
strange, that Northern politicians should, for temporary purposes,
assist them in the effort. This is for a day; but the great tide of
human thought flows on for ever, and there is no spot from which it
will be shut out. I remember when the right of petition was denied