Download Study Resources for Introduction to Java Programming Brief Version 10th Edition Liang Test Bank
Download Study Resources for Introduction to Java Programming Brief Version 10th Edition Liang Test Bank
com
https://testbankfan.com/product/introduction-to-java-
programming-brief-version-10th-edition-liang-test-bank/
OR CLICK HERE
DOWLOAD NOW
https://testbankfan.com/product/introduction-to-java-programming-
comprehensive-version-10th-edition-liang-test-bank/
testbankfan.com
https://testbankfan.com/product/introduction-to-java-programming-
comprehensive-version-10th-edition-liang-solutions-manual/
testbankfan.com
https://testbankfan.com/product/introduction-to-java-programming-
comprehensive-version-9th-edition-liang-test-bank/
testbankfan.com
https://testbankfan.com/product/income-tax-fundamentals-2019-37th-
edition-whittenburg-solutions-manual/
testbankfan.com
Algebra and Trigonometry Graphs and Models 5th Edition
Bittinger Test Bank
https://testbankfan.com/product/algebra-and-trigonometry-graphs-and-
models-5th-edition-bittinger-test-bank/
testbankfan.com
https://testbankfan.com/product/introduction-to-audiology-13th-
edition-martin-solutions-manual/
testbankfan.com
https://testbankfan.com/product/introduction-to-managerial-accounting-
canadian-5th-edition-brewer-solutions-manual/
testbankfan.com
https://testbankfan.com/product/ethics-for-the-information-age-7th-
edition-quinn-solutions-manual/
testbankfan.com
https://testbankfan.com/product/accounting-principles-13th-edition-
weygandt-solutions-manual/
testbankfan.com
SELL 3rd Edition Ingram Test Bank
https://testbankfan.com/product/sell-3rd-edition-ingram-test-bank/
testbankfan.com
Name:_______________________ CSCI 1302 OO Programming
Armstrong Atlantic State University
(50 minutes) Instructor: Dr. Y. Daniel Liang
Part I:
A. (2 pts)
What is wrong in the following code?
public class Test {
public static void main(String[] args) {
Number x = new Integer(3);
System.out.println(x.intValue());
System.out.println(x.compareTo(new Integer(4)));
}
}
B. (3 pts)
statement4;
}
1
C. (2 pt)
d. (2 pt)
of object?
import java.io.*;
output.writeObject(t);
output.close();
System.out.println(t1.a);
System.out.println(t1.b);
System.out.println(t1.m);
input.close();
}
}
(5 pts) Write a program that stores an array of the five int values 1, 2, 3, 4 and 5, a Date object
for the current time, and the double value 5.5 into the file named Test.dat.
2
(10 pts) Write a class named Hexagon that extends GeometricObject and
implements the Comparable interface. Assume all six sides of the
hexagon are of equal size. The Hexagon class is defined as
follows:
@Override
public double getArea() {
// Implement it ( area = 3* 3 * side * side )
@Override
public double getPerimeter() {
// Implement it
@Override
public int compareTo(Hexagon obj) {
// Implement it (compare two Hexagons based on their sides)
@Override
public Object clone() {
// Implement it
3
}
}
4
Part III: Multiple Choice Questions: (1 pts each)
(Please circle your answers on paper first. After you
finish the test, enter your choices online to LiveLab. Log
in and click Take Instructor Assigned Quiz. Choose Quiz2.
You have 5 minutes to enter and submit the answers.)
a. [New York]
b. [New York, Atlanta]
c. [New York, Atlanta, Dallas]
d. [New York, Dallas]
#
2. Show the output of running the class Test in the following code:
interface A {
void print();
}
class C {}
a. Nothing.
b. b is an instance of A.
c. b is an instance of C.
d. b is an instance of A followed by b is an instance of C.
5
3. Suppose A is an interface, B is an abstract class that partial
implements A, and A is a concrete class with a default constructor that
extends B. Which of the following is correct?
a. A a = new A();
b. A a = new B();
c. B b = new A();
d. B b = new B();
Key:c
#
4. Which of the following is correct?
a. An abstract class does not contain constructors.
b. The constructors in an abstract class should be protected.
c. The constructors in an abstract class are private.
d. You may declare a final abstract class.
e. An interface may contain constructors.
Key:b
#
5. What is the output of running class C?
class A {
public A() {
System.out.println(
"The default constructor of A is invoked");
}
}
class B extends A {
public B(String s) {
System.out.println(s);
}
}
public class C {
public static void main(String[] args) {
B b = new B("The constructor of B is invoked");
}
}
a. none
b. "The constructor of B is invoked"
c. "The default constructor of A is invoked" "The constructor of B
is invoked"
d. "The default constructor of A is invoked"
#
6. Analyze the following code:
6
}
a. The program has a syntax error because Test1 does not have a main
method.
b. The program has a syntax error because o1 is an Object instance
and it does not have the compareTo method.
c. The program has a syntax error because you cannot cast an Object
instance o1 into Comparable.
d. The program would compile if ((Comparable)o1.compareTo(o2) >= 0)
is replaced by (((Comparable)o1).compareTo(o2) >= 0).
e. b and d are both correct.
#
7. Which of the following statements regarding abstract methods is not
true?
a. An abstract class can have instances created using the constructor
of the abstract class.
b. An abstract class can be extended.
c. A subclass of a non-abstract superclass can be abstract.
d. A subclass can override a concrete method in a superclass to declare
it abstract.
e. An abstract class can be used as a data type.
#
8. Which of the following possible modifications will fix the errors in
this code?
#
9. Analyze the following code.
class Test {
public static void main(String[] args) {
Object x = new Integer(2);
System.out.println(x.toString());
}
}
7
c. When x.toString() is invoked, the toString() method in the
Integer class is used.
d. None of the above.
#
10. What exception type does the following program throw?
public class Test {
public static void main(String[] args) {
Object o = new Object();
String d = (String)o;
}
}
a. ArithmeticException
b. No exception
c. StringIndexOutOfBoundsException
d. ArrayIndexOutOfBoundsException
e. ClassCastException
#
11. What exception type does the following program throw?
public class Test {
public static void main(String[] args) {
Object o = null;
System.out.println(o.toString());
}
}
a. ArrayIndexOutOfBoundsException
b. ClassCastException
c. NullPointerException
d. ArithmeticException
e. StringIndexOutOfBoundsException
#
12. To append data to an existing file, use _____________ to construct a
FileOutputStream for file out.dat.
a. new FileOutputStream("out.dat")
b. new FileOutputStream("out.dat", false)
c. new FileOutputStream("out.dat", true)
d. new FileOutputStream(true, "out.dat")
#
13. After the following program is finished, how many bytes are written to the file t.dat?
import java.io.*;
8
public class Test {
public static void main(String[] args) throws IOException {
DataOutputStream output = new DataOutputStream(
new FileOutputStream("t.dat"));
output.writeInt(1234);
output.writeShort(5678);
output.close();
}
}
a. 2 bytes.
b. 4 bytes.
c. 6 bytes.
d. 8 bytes.
e. 12 bytes
#
14. Which of the following statements is not true?
a. ObjectInputStream/ObjectOutputStream enables you to perform I/O for objects in
addition for primitive type values and strings.
b. Since ObjectInputStream/ObjectOutputStream contains all the functions of
DataInputStream/DataOutputStream, you can replace
DataInputStream/DataOutputStream completely by
ObjectInputStream/ObjectOutputStream.
c. To write an object, the object must be serializable.
d. The Serializable interface does not contain any methods. So it is a mark interface.
e. If a class is serializable, all its data fields are seriablizable.
9
Other documents randomly have
different content
The Project Gutenberg eBook of Extracts from
the Diary and Correspondence of the Late
Amos Lawrence; with a brief account of some
incidents of his life
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.
Language: English
FROM THE
DIARY AND
CORRESPONDENCE
OF THE LATE
AMOS LAWRENCE;
WITH A
WILLIAM R. LAWRENCE, M. D.
———
BOSTON:
G O U L D A N D L I N C O L N,
59 WASHINGTON STREET.
NEW YORK: SHELDON, LAMPORT & BLAKEMAN.
LONDON: TRUBNER & CO.
1856.
WILLIAM R. LAWRENCE,
BOSTON:
Stereotyped by
HOBART & ROBBINS,
New England Type and Stereotype Foundery.
———
Press of George C. Rand & Avery.
To his
ONLY SURVIVING BROTHER,
A M O S A. L A W R E N C E,
OF BOSTON,
This Volume is Affectionately Inscribed,
BY
THE EDITOR.
PREFACE.
Among the papers of the late Amos Lawrence were found copies of
a large number of letters addressed to his children.
With the hope that the good counsels there given, during a
succession of years, extending from their childhood to adult age,
might still be made profitable to their descendants, he had caused
them to be carefully preserved.
These letters, as well as an irregular record of his daily experience,
were scattered through many volumes, and required arrangement
before they could be of use to those for whom they were intended.
As no one else of the immediate family could conveniently undertake
the task, the editor considered it his duty to do that which could not
properly be committed to one less nearly connected with the
deceased.
The present volume, containing what was thought most interesting
among those letters and extracts, was accordingly prepared for
private circulation; and an edition of one hundred copies was printed
and distributed among the nearest relatives and friends.
It has been thought by many that the record of such a life as is here
portrayed would be useful to other readers, and especially to young
men,—a class in whom Mr. Lawrence was deeply interested, and
with whom circumstances in his own life had given him a peculiar
bond of sympathy.
Although many, among both friends and strangers, have urged the
publication of the present memorial, and some have even
questioned the moral right of withholding from the view of others
the light of an example so worthy of imitation, much hesitation has
been felt in submitting to the public the recital of such domestic
incidents as are treasured in the memory of every family; those
incidents which cast a sunbeam or a shadow across every fireside,
and yet possess little or no interest for the busy world without.
At the solicitation of the "Boston Young Men's Christian Union," the
"Boston Young Men's Christian Association," and the students of
Williams College, through their respective committees, and at the
request of many esteemed citizens, the pages which were prepared
for the eye of kindred and friends alone are now submitted to the
public. Personal feeling is forgotten in the hope that the principles
here inculcated may tend to promote the ends for which the subject
of this memorial lived and labored.
The interest manifested in his life, and the tributes rendered to his
memory, have been a source of sincere gratification to his family;
and they would here tender their acknowledgments to all those who
have expressed their interest and their wishes in regard to this
publication.
The present volume is submitted with a few unimportant omissions,
and with the addition of some materials, received after the issue of
the first edition, which will throw light upon the character and
principles of Mr. Lawrence during his early business career.
His course was that of a private citizen, who took but little part in
public measures or in public life.
To the general reader, therefore, there may be but little to amuse in
a career so devoid of incident, and so little connected with the
stirring events of his times; but there cannot fail to be something to
interest those who can appreciate the spirit which, in this instance,
led to a rare fidelity in the fulfilment of important trusts, and the
consecration of a life to the highest duties.
Mr. Lawrence was eminently a religious man, and a deep sense of
accountability may be discovered at the foundation of those acts of
beneficence, which, during his lifetime, might have been attributed
to a less worthy motive.
It has been the object of the editor to allow the subject of this
memorial to tell his own story, and to add merely what is necessary
to preserve the thread of the narrative, or to throw light upon the
various matters touched upon in the correspondence.
It is designed to furnish such materials as will afford a history of Mr.
Lawrence's charitable efforts, rather than give a detailed account of
what was otherwise an uneventful career.
Such selections from his correspondence are made as seemed best
adapted to illustrate the character of the man; such as exhibit his
good and valuable traits, without attempting to conceal those
imperfections, an exemption from which would elevate him above
the common sphere of mortals.
Most of his letters are of a strictly private nature, and involve the
record of many private details. His domestic tastes, and his affection
for his family, often led him to make mention of persons and events
in such a way that few letters could be wholly given without invading
the precincts of the family circle.
The engraving at the commencement of the volume is from an
original portrait, by Harding, in the possession of the editor, a copy
of which hangs in the library of Williams College.
It seems also fitting to include a portrait of the Hon. Abbott
Lawrence, who, for forty-three years, was so intimately associated
with the subject of this memorial in all the trials, as well as in the
triumphs, of business life, and who was still more closely connected
by the bonds of fraternal affection and sympathy. A few days only
have elapsed since he was removed from the scene of his earthly
labors.
The grave has rarely closed over one who to such energy of
character and strength of purpose united a disposition so gentle and
forbearing. Amidst the perplexities attending his extended business
relations, and in the excitement of the political struggles in which he
was called to take part, he was never tempted to overstep the
bounds of courtesy, or to regard his opponents otherwise than with
feelings of kindness.
His wealth was used freely for the benefit of others, and for the
advancement of all those good objects which tended to promote the
welfare of his fellow-men.
That divine spark of charity, which burned with such ceaseless
energy in the bosom of his elder brother, was caught up by him, and
exhibited its fruits in those acts of munificence which will make him
long remembered as a benefactor of his race.
Boston, September 1st, 1855.
LETTERS,
REQUESTING PUBLICATION.
Rooms of the Boston Young Men's Christian Union,
6 Bedford-street, Boston, June 22, 1855.
William R. Lawrence, Esq.
Dear Sir: The undersigned, members of the Government of the
Boston Young Men's Christian Union, some of whom have perused
the excellent memoir of your honored father, feel deeply impressed
with the desire that it should be published and circulated, knowing
that its publication and perusal would greatly benefit the young, the
old, and all classes of our busy mercantile community.
Remembering with pleasure the friendship which your father
expressed, not only in kind words, but in substantial offerings to the
treasury and library of our Society, the Union would be most happy,
should it comport with your feelings, to be made the medium of the
publication and circulation of the memoir, which you have compiled
with so much ability and faithfulness.
Hoping to receive a favorable response to our desire,
We are most truly yours,
THOMAS GAFFIELD,
JOHN SWEETSER,
JOSEPH H. ALLEN,
CHAS. C. SMITH,
C. J. BISHOP,
F. H. PEABODY,
W. IRVING SMITH,
ARTHUR W. HOBART.
H. K. WHITE,
J. F. AINSWORTH,
W. H. RICHARDSON,
FRANCIS S. RUSSELL,
FREDERIC H.
HENSHAW,
CHARLES F. POTTER,
THORNTON K.
LOTHROP,
GEO. S. HALE.
BIRTH.—ANCESTRY.—PARENTS, 15
CHAPTER II.
CHAPTER III.
ARRIVAL IN BOSTON.—CLERKSHIP.—COMMENCES
28
BUSINESS.—HABITS,
CHAPTER IV.
CHAPTER V.
CHAPTER VI.
DEATH OF SISTER.—LETTERS, 54
CHAPTER VIII.
CHAPTER IX.
CHAPTER X.
MARRIAGE.—ELECTED TO LEGISLATURE.—ENGAGES
77
IN MANUFACTURES.—REFLECTIONS,
CHAPTER XI.
CHAPTER XII.
JOURNEY TO CANADA.—LETTERS.—DIARY.—
89
CHARITIES,
CHAPTER XIII.
CHAPTER XIV.
CHAPTER XV.
JOURNEY TO NEW HAMPSHIRE.—LETTERS.—RESIGNS
109
OFFICE OF TRUSTEE AT HOSPITAL.—LETTERS,
CHAPTER XVI.
CHAPTER XVII.
REFLECTIONS.—VISIT TO WASHINGTON.—VISIT TO
RAINSFORD ISLAND.—REFLECTIONS.—VIEW OF 137
DEATH.—REFLECTIONS,
CHAPTER XVIII.
BROTHER'S DEATH.—LETTERS.—GIFTS.—LETTERS.—
BIRTH-PLACE.—DIARY.—APPLICATIONS FOR AID.—
147
REFLECTIONS.—LETTER FROM REV. DR. STONE.—
DIARY,
CHAPTER XIX.
REFLECTIONS.—LETTERS.—ACCOUNT OF EFFORTS TO
165
COMPLETE BUNKER HILL MONUMENT,
CHAPTER XX.
CHAPTER XXI.
ACQUAINTANCE WITH PRESIDENT HOPKINS.—
LETTERS.—AFFECTION FOR BRATTLE-STREET
182
CHURCH.—DEATH OF MRS. APPLETON.—LETTERS.—
AMESBURY CO.,
CHAPTER XXII.
CHAPTER XXIII.
CHAPTER XXIV.
REFLECTIONS.—EXPENDITURES.—LETTERS.—
DONATION FOR LIBRARY AT WILLIAMS COLLEGE.— 212
VIEWS ON STUDY OF ANATOMY,
CHAPTER XXV.
CHAPTER XXVI.
CHAPTER XXVII.