Complete Answer Guide for Introduction to Java Programming Brief Version 10th Edition Liang Test Bank
Complete Answer Guide for Introduction to Java Programming Brief Version 10th Edition Liang Test Bank
https://testbankdeal.com/product/introduction-to-java-programming-
comprehensive-version-10th-edition-liang-test-bank/
https://testbankdeal.com/product/introduction-to-java-programming-
comprehensive-version-10th-edition-liang-solutions-manual/
https://testbankdeal.com/product/introduction-to-java-programming-
comprehensive-version-9th-edition-liang-test-bank/
https://testbankdeal.com/product/financial-and-managerial-
accounting-6th-edition-wild-solutions-manual/
Hazard Mitigation in Emergency Management 1st Edition
Islam Test Bank
https://testbankdeal.com/product/hazard-mitigation-in-emergency-
management-1st-edition-islam-test-bank/
https://testbankdeal.com/product/foundations-of-operations-management-
canadian-4th-edition-ritzman-solutions-manual/
https://testbankdeal.com/product/organizational-behaviour-concepts-
controversies-applications-canadian-7th-edition-langton-solutions-
manual/
https://testbankdeal.com/product/strategic-staffing-3rd-edition-
phillips-test-bank/
https://testbankdeal.com/product/economics-of-money-banking-and-
financial-markets-10th-edition-mishkin-test-bank/
Human Relations for Career and Personal Success Concepts
Applications and Skills 11th Edition DuBrin Test Bank
https://testbankdeal.com/product/human-relations-for-career-and-
personal-success-concepts-applications-and-skills-11th-edition-dubrin-
test-bank/
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
Exploring the Variety of Random
Documents with Different Content
panes, bringing with it the wild crash of the Christmas bells, a tumult
of voices, and Daphne's thrilling scream.
Peril makes some men mad. It made Angelo sane. He realised the
situation—realised that his hated rival was slipping from his power;
but the knowledge of this fact only made him more desperate.
"Damn you! you shall not escape!" he cried fiercely. "I'll have your
life, though I die the next moment for it!"
With the dagger gleaming aloft, he darted on me. Measuring him
with my eye, I swung the chair round, and tried to bring it down on
his head, but he eluded the blow by springing deftly to one side.
The robe of tragedy is often sewn with the threads of comedy. The
chair intended for the artist lighted instead on his unfinished picture,
and went sheer through the canvas, overturning the easel, and
inflicting more damage to the painted Colosseum in two seconds
than old Time has been able to inflict on the solid original in well-
nigh two millenniums.
"My picture! Oh, my picture!" cried the artist. "You have destroyed
it!"
Petrified with dismay, he gazed on the ruins of his work of art,
oblivious for the moment of everything else. Taking advantage of his
surprise, I sprang forward, and seized him by the throat with such
force and energy that he toppled backwards, and measured his
length on the floor of the cell. I fell with him.
"That's it! Bravo! Hold him down!" cried a voice, which I recognised
as the Baronet's. "We'll be with you in an instant."
Sir Hugh, my uncle, and some others were standing on the window-
ledge, striving to effect an entrance by forcing asunder the slender
cross-bars of the casement.
The artist lay extended on the floor of the cell. My knee was on his
chest, and with one hand I grasped him by the throat, and with the
other pinioned to the floor his hand that held the dagger. I tried to
keep him in this position till aid should come, but with a strength
almost superhuman he rose to his feet, dragging me with him, and,
grappling with each other, we swayed backwards and forwards in the
moonlit cell.
"I always hated you," he gasped. "But for you I might have won the
love of Daphne. You shall not escape me!"
He made frantic efforts to reach me with the dagger, but I clung
heavily to the arm that held it, impeding his power of action. At
length with a sudden effort of strength he flung me off, but as he did
so the cross-bars of the casement gave way, and three human
bodies were projected through it in a most ungraceful fashion, and
fell on all-fours to the floor.
For one second the artist stood irresolute, and then darting towards
the secret opening, he disappeared from view.
The cell seemed to swim around me, a mist passed before my eyes,
and then dimly as in a dream I became conscious that I was
reclining in an oaken chair, supported on one side by my uncle and
on the other by Daphne. The door of the tower was wide open,
hanging obliquely on one hinge. Someone was putting a lighted
match to the wick in the antique iron lamp, and its bright flame lit up
a crowd of faces that were bent upon me with wondering looks. At
one end of the cell some men, a helmeted police-officer among the
number, were kneeling, fingering and clawing at the stone slab
which the artist had pulled down after him to cover his retreat.
"It must be chained down," I heard the Baronet saying. "Pass the
crowbar. Damn it! the fellow will escape."
"His eyes are open," I heard Daphne saying. "Oh, Frank, you are not
hurt, are you?"
She was now kneeling beside me, her lovely eyes full of tenderness
and sympathy. It was worth all the agony I had endured to be the
object of her sweet pity. I tried to speak, but emotion checked my
utterance, and I could reply to her question only by an assuring
smile.
"You are looking like the very dead," said the doctor. "Here, take a
drop of this. This will revive you."
"Is my hair grey?" I murmured, putting my hand to my head, as if it
were possible to ascertain by the sense of touch. "Do I look old? I
feel like a captive liberated from the Bastile. How long have I been in
this prison? Years upon years?"
In a few words I told my shuddering listeners of the artist's designs
on me. From regard to Daphne, I reserved the story of George's end
for another occasion.
"Ay, ay," remarked the doctor, gravely shaking his head. "I saw this
morning that he exhibited all the symptoms of insanity. Genius and
madness are often allied."
"Well, thank Heaven you are safe!" exclaimed my uncle fervently;
"though more by your own efforts than by ours," he added.
"Have you only just returned from the magistrate's?" I asked him.
There is a good deal of ingratitude in human nature, and even in the
first joy of my deliverance I felt a disposition to reproach my uncle
for what I considered a very tardy rescue, totally forgetful of the fact
that if my rescuers had appeared earlier on the scene there would
have been an end of me, for the artist at sight of them would have
effected his deadly purpose without my being able to offer any
resistance.
"Yes, we have only just returned," he answered, understanding the
motive of my question. "Everything that possibly could went wrong.
The carriage broke down half way from the Manse, and when we set
off to finish the journey on foot we missed our way on the moors
and were a long time in finding it again. When we did reach the
Abbey and did not see you about we guessed where you were and
came at once to the tower. We heard enough to assure us that
something very serious was the matter, and as we could not hope to
make our way in empty handed we ran back for—"
He was interrupted by a shout coming from outside of the cell, and
turning quickly I saw that the slab had been lifted up revealing a
stairway beneath.
"Turn your lantern down here, Wilson," cried the Baronet excitedly,
"and lead the way. Look sharp, or he'll escape after all."
The constable obediently went down the opening, followed by Sir
Hugh, my uncle and two or three other men. Thinking that I had as
good a right as any to join the pursuit, I rose with the intention of
following them, but at Daphne's entreaty, I forbore, and, leaving the
cell, we both walked across the lawn to the Abbey, all unconscious of
the tragedy that was happening under our very feet.
For the steps down which the artist had fled opened into a stone
passage, the walls of which were dripping with moisture and stained
with horrid fungi. At the foot of the steps Sir Hugh came upon a
recess, where they found a grey cloak, and a gentleman's dress suit.
The Baronet, with a look of inquiry on his face, pointed out these
things to my uncle.
"Yes," said my uncle, "those are his clothes right enough. They are
what he wore the last time we saw him alive. It is clear that Vasari
murdered him that night, and he has kept these clothes by him ever
since. Look," he went on, "this is where he was stabbed," and he
pointed to a cut in the back of the coat. As he was handling the
garment something bright fell from the breast pocket, and stooping
to pick it up he recognised the ring which Daphne had thrown into
the well at Rivoli.
"We mustn't stop," the Baronet said. "Hold up the light, Wilson," and
the whole party again stumbled forward along the passage.
"Where does it lead to?" the constable asked, peering cautiously into
the darkness before him.
"I wish I could tell you," Sir Hugh replied. "I have never seen the
place before. It must be the nuns' corridor of ancient days. I always
understood it had been bricked up. By the way, we must go
carefully. If I'm right, there must be a deep chasm ahead—the Nuns'
Shaft, and if—hullo, what's that?"
Distant a few paces in front was a human figure crouching low
against the wall.
"There he is," several voices cried at once.
"Take care," said my uncle. "Remember, he is a madman!"
At this, the whole party came to a sudden halt.
"Yield in the King's name," shouted the constable. But whatever
effect the King's name may have upon the sane it cannot be
expected to exercise much influence upon a maniac. Rising to his
feet, with a wild laugh that sounded unearthly in the echoing
passage, the madman ran on into the darkness, with the pursuit hot
behind him.
Suddenly he checked his headlong pace, and, turning swiftly,
confronted his pursuers. The light held aloft by the constable fell full
on his despairing face, and to their dying day those who saw Angelo
Vasari at that moment will never forget the sight.
With a gesture in which rage, defiance and hopelessness were all
mingled, he sprang into the air. For one moment he was visible, in
the next he had vanished. No sound broke from him. In absolute
silence, more terrible than any cry, he was swallowed by the
blackness beneath him.
"By God, he's gone!" the Baronet shouted, and there was fear in his
voice. "Stop, stop, for Heaven's sake, or you are all dead men."
"What is it?" shouted some, catching the infection of his fear.
"He has leaped down the shaft of the old silver mine."
Thus died Angelo Vasari, and perhaps it was better that he should
perish by suicide than be taken alive only to fall into the hangman's
hands or drag out a long life in some asylum for the insane. That the
story could be kept from the general public was, of course,
impossible, and the sensation caused at the inquest by the telling of
the manner of his death was enhanced by the account I had to
repeat of how my brother came by his. Vasari's studio in London was
examined, and evidence was discovered in the cellar corroborating
his assertion that he had burnt the body of the man whom he had
sacrificed to his insane desire for fame.
As for the picture itself, Sir Hugh at first thought of destroying it, but
finally decided to keep it on account of its marvellous merit as a
work of art. It was removed from the gallery, and hung by itself in a
room where it could be inspected by the privileged few. Daphne
could never bring herself to look at it. She did not want the idealised
image of her lover to be marred by the ghastly presentment of his
dead likeness.
Whose wife Daphne is now, it is hardly necessary to say. We were
married in the spring at Silverdale, and quiet though we wished the
wedding to be, the church was crowded with people from far and
wide who were eager to see the girl whose beauty had been the
cause of such a tragedy. To efface from her mind as far as possible
the memory of that tragedy is the chief object of my life and I am
glad to think I do not wholly fail. She wears in addition to her
wedding ring a second golden band, the ring that she threw into the
well at Rivoli. It is to be buried with her, she says. May that day be
far distant, is my constant prayer.
THE END
*** END OF THE PROJECT GUTENBERG EBOOK THE WEIRD
PICTURE ***
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
testbankdeal.com