Introduction to Java Programming Brief Version 10th Edition Liang Test Bankpdf download
Introduction to Java Programming Brief Version 10th Edition Liang Test Bankpdf download
https://testbankfan.com/product/introduction-to-java-programming-
brief-version-10th-edition-liang-test-bank/
https://testbankfan.com/product/introduction-to-java-programming-
comprehensive-version-10th-edition-liang-test-bank/
https://testbankfan.com/product/introduction-to-java-programming-
comprehensive-version-10th-edition-liang-solutions-manual/
https://testbankfan.com/product/introduction-to-java-programming-
comprehensive-version-9th-edition-liang-test-bank/
https://testbankfan.com/product/fundamentals-of-management-essential-
concepts-and-applications-5th-edition-robbins-test-bank/
Business Ethics Decision Making for Personal Integrity and
Social Responsibility 3rd Edition Hartman Solutions Manual
https://testbankfan.com/product/business-ethics-decision-making-for-
personal-integrity-and-social-responsibility-3rd-edition-hartman-
solutions-manual/
https://testbankfan.com/product/criminal-behavior-a-psychological-
approach-11th-edition-bartol-test-bank/
https://testbankfan.com/product/digital-business-networks-1st-edition-
dooley-test-bank/
https://testbankfan.com/product/new-perspectives-on-microsoft-
excel-2013-comprehensive-1st-edition-parsons-test-bank/
https://testbankfan.com/product/financial-statement-analysis-and-
valuation-4th-edition-easton-test-bank/
South-Western Federal Taxation 2015 Corporations
Partnerships Estates and Trusts 38th Edition Hoffman
Solutions Manual
https://testbankfan.com/product/south-western-federal-
taxation-2015-corporations-partnerships-estates-and-trusts-38th-
edition-hoffman-solutions-manual/
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
Yhä vain myyjiä tuli. Denise kuuli heidän laskevan leikkiä
vilkaistessaan häneen. Hän kiusaantui yhä enemmän huomatessaan
olevansa huomion kohteena ja päätti vielä kerran mennä puoleksi
tunniksi kävelemään, mutta sitten hän pysähtyi nähdessään nuoren
miehen kävelevän erityisen tarmokkaan näköisenä Port-Mahonilta
päin. Varmaan tämä oli osastonjohtaja, sillä kaikki tervehtivät häntä.
Hän oli kookas, vaalea ja hänen partansa oli hyvin hoidettu.
Kulkiessaan torin poikki hänen tummankullanväriset silmänsä
sattuivat hetkeksi tyttöön. Sitten hän välinpitämättömästi meni
sisälle taloon Denisen seisoessa liikkumattomana miehen katseen
vaikutuksen alaisena ja tuntien pikemmin vastenmielisyyttä kuin
mielihyvää. Nyt hän todenteolla pelästyi ja lähti hitaasti
Gailloninkatua, josta hän kääntyi Saint-Rochinkadulle saadakseen
aikaa rauhoittua.
— Huonoa terveydenhoitoa.
Mouret kiivastui:
— Naiset tietysti.
— Kyllä kai minä sen tiedän, ja siksi juuri tahdon pitää hinnan
alhaalla. Ette tosiaankaan, kunnon ystävä, opi koskaan
ymmärtämään naista. Ettekö käsitä, että he tulevat kilvan
hyökkäämään tämän silkkikankaan kimppuun…
Albertin isä tuli paikalle. Kassaltaan, joka oli oven vieressä, hän
saattoi valvoa poikaansa, joka istui kopissa käsineosastolla.
Harmaapäisellä, paikallaan istumisen veltostuttamalla vanhuksella oli
höllät, ajan hivuttamat kasvot, ikäänkuin hänen lakkaamatta
laskemansa rahat olisivat kuluttaneet niistä pois kaiken ilmeen.
Häneltä puuttui toinen käsi, mutta se ei haitannut häntä lainkaan
työssä; päinvastoin kolikot ja setelit pyörivät niin ketterästi hänen
vasemmassa ja ainoassa kädessään, että moni uteliaisuudesta kävi
katsomassa, kun hän tarkisti tuloja. Hän oli veronkantajan poika
Chablista ja joutunut Pariisiin erään Port-aux-Vins'in viinikauppiaan
kirjeenvaihtajana. Cuvier'nkadulla asuessaan hän oli nainut
ovenvartijansa, elsassilaisen nurkkaräätälin, tyttären. Ja siitä lähtien
hän oli ollut vaimonsa nöyrä palvelija ja ihaili sydämensä pohjasta
tämän etevyyttä kauppa-alalla. Rouva nimittäin ansaitsi valmiiden
vaatteiden osastolla yli kahdentoistatuhannen frangin vuodessa, kun
taas hänellä itsellään ei ollut kuin viisituhatta frangia kiinteää
palkkaa. Hänen kunnioituksensa vaimoa kohtaan, joka osasi lisätä
talouskassaa tällaisilla summilla ulottui poikaankin, joka oli syntynyt
hänestä.
Juuri kun hän palasi Bourdonclen luo tuli paikalle nuori nainen ja
jäi muutamaksi hetkeksi seisomaan asetelman eteen aivan
huumaantuneena. Se oli Denise. Epäröityään lähes tunnin ajan
kadulla sietämättömän ujouden vallassa hän oli vihdoinkin päättänyt
mennä sisään. Mutta hänen päänsä oli niin pyörällä, ettei hän
pystynyt tajuamaan yksinkertaisimpiakaan selityksiä. Turhaan
kauppa-apulaiset, joilta hän tiedusteli rouva Aurélieta, osoittivat
hänelle välikerroksen portaita. Hän kiitti ja kääntyi vasemmalle, kun
hänet oli neuvottu oikealle, eksyen osastolta osastolle ja saaden
osakseen myyjien uteliaita, äreitä ja välinpitämättömiä katseita. Hän
halusi sekä paeta että jäädä ihailemaan. Hän tunsi olevansa pienen
pieni hiukkanen hirviömäisen, vielä liikkumattoman koneen vallassa,
jonka rattaat uhkasivat tempaista hänet mukaansa kohta alkavaan,
seiniä tärisyttävään kiertoon. Ja verratessaan tätä laajaa tavarataloa
Vanhan Elbeufin ahtaaseen ja pimeään puotiin se tuntui hänestä
vieläkin isommalta ja valoisammalta, muistutti kokonaista kaupunkia
patsaineen, toreineen, katuineen, sekavaa sokkeloa, jossa hänen oli
mahdotonta koskaan löytää tietään.
— Välikerroksessa.
Ja Denise, jolla oli kiire paeta kaikkien noiden miesten katseita,
kiitti ja kääntyi taas kerran selin porraskäytävään. Silloin Hutin tuli
hänen luokseen synnynnäisen kohteliaisuutensa pakosta. Äskeisestä
pilkastaan huolimatta hän puhutteli tyttöä hienoon käytökseen
tottuneen myyjän tavoin sanoen:
— On siinäkin avuton!
testbankfan.com