Test Bank For Introduction To Java Programming Comprehensive Version 9th Edition Liang 9780132936521 Download PDF
Test Bank For Introduction To Java Programming Comprehensive Version 9th Edition Liang 9780132936521 Download PDF
http://testbankpack.com/download/test-bank-for-introduction-to-java-
programming-comprehensive-version-9th-edition-liang-9780132936521/
https://testbankpack.com/download/test-bank-for-introduction-to-java-
programming-brief-version-10th-edition-liang-0133592200-9780133592207/
https://testbankpack.com/download/test-bank-for-introduction-to-
programming-using-visual-basic-2012-9th-edition-
schneider-0133378500-9780133378504/
Test Bank for Java Programming 8th Edition Farrell
1285856910 9781285856919
https://testbankpack.com/download/test-bank-for-java-programming-8th-
edition-farrell-1285856910-9781285856919/
https://testbankpack.com/download/test-bank-for-java-programming-7th-
edition-farrell-1285081951-9781285081953/
https://testbankpack.com/download/test-bank-for-introduction-to-
programming-using-python-1st-edition-
schneider-0134058224-9780134058221/
https://testbankpack.com/download/test-bank-for-introduction-to-
programming-with-c-4th-edition-diane-zak-0619217111-9780619217112/
https://testbankpack.com/download/test-bank-for-introduction-to-
programming-using-visual-basic-10th-edition-
schneider-0134542789-9780134542782/
Test Bank for Introduction to Java
Programming Comprehensive Version 9th
Edition Liang 9780132936521
https://testbankpack.com/p/test-bank-for-introduction-to-java-
programming-comprehensive-version-9th-edition-liang-9780132936521/
Name: CSCI 1301 Introduction to Programming
Covers Chapters 1-3 Armstrong Atlantic State University
50 mins Instructor: Dr. Y. Daniel Liang
I pledge by honor that I will not discuss this exam with anyone until my
instructor reviews the exam in the class.
Signed by Date
Part I. (10 pts) Show the output of the following code: (write the output
next to each println statement if the println statement is executed in
the program).
System.out.println((int)(Math.random()));
System.out.println(Math.pow(2, 3));
System.out.println(34 % 7);
int number = 4;
if (number % 3 == 0)
System.out.println(3 * number);
System.out.println(4 * number);
int x = 943;
System.out.println(x / 100);
System.out.println(x % 100);
int y = -1;
y++;
System.out.println(y);
}
}
Part II:
1
Chinese RMB or US dollars, respectively. Here are the
sample runs:
<Output>
Enter the exchange rate from dollars to RMB: 6.81
Enter 0 to convert dollars to RMB and 1 vice versa: 0
Enter the dollar amount: 100
$100.0 is 681.0 Yuan
<End Output>
<Output>
Enter the exchange rate from dollars to RMB: 6.81
Enter 0 to convert dollars to RMB and 1 vice versa: 1
Enter the RMB amount: 10000
10000.0 Yuan is $1468.43
<End Output>
<Output>
Enter the exchange rate from dollars to RMB: 6.81
Enter 0 to convert dollars to RMB and 1 vice versa: 5
Incorrect input
<End Output>
2
2. (10 pts) Write a program that prompts the user to enter an integer. If
the number is a multiple of 5, print HiFive. If the number is divisible
by 2 or 3, print Georgia. Here are the sample runs:
<Output>
Enter an integer: 6
Georgia
<End Output>
<Output>
Enter an integer: 15
HiFive Georgia
<End Output>
<Output>
Enter an integer: 25
HiFive
<End Output>
<Output>
Enter an integer: 1
<End Output>
3
Name:
a. 76
b. 76.0252175
c. 76.03
d. 76.02
#
2. What is y after the following switch statement?
int x = 0;
int y = 0;
switch (x + 1) {
case 0: y = 0;
case 1: y = 1;
default: y = -1
}
a. 2
b. 1
c. 0
d. -1
#
3. Assume x is 0. What is the output of the following statement?
if (x > 0)
System.out.print("x is greater than 0");
else if (x < 0)
System.out.print("x is less than 0");
else
System.out.print("x equals 0");
a. x is less than 0
b. x is greater than 0
c. x equals 0
d. None
4
4. Analyze the following code:
Code 1:
boolean even;
if (number % 2 == 0)
even = true;
else
even = false;
Code 2:
#
5. What is the output of the following switch statement?
char ch = 'a';
switch (ch) {
case 'a':
case 'A':
System.out.print(ch); break;
case 'b':
case 'B':
System.out.print(ch); break;
case 'c':
case 'C':
System.out.print(ch); break;
case 'd':
case 'D':
System.out.print(ch);
}
a. ab
b. a
c. aa
d. abc
e. abcd
5
#
6. What is x after evaluating
x = (2 > 3) ? 2 : 3;
a. 5
b. 2
c. 3
d. 4
#
7. Analyze the following code.
int x = 0;
if (x > 0);
{
System.out.println("x");
}
#
8. To declare a constant MAX_LENGTH inside a method with value 99.98, you write
#
9. Which of the following is a constant, according to Java naming conventions?
a. read
b. MAX_VALUE
c. ReadInt
d. Test
#
10. What is y after the following switch statement is executed?
x = 3;
switch (x + 3) {
case 6: y = 0;
case 7: y = 1;
default: y += 1;
}
6
a. 1
b. 4
c. 3
d. 2
e. 0
#
11. Which of the following code displays the area of a circle if the radius is
positive.
7
Sample Final Exam for CSCI 1302
Here is a mapping of the final comprehensive exam against the course outcomes:
1
Name: CSCI 1302 Introduction to Programming
Covers chs8-19 Armstrong Atlantic State University
Final Exam Instructor: Dr. Y. Daniel Liang
Please note that the university policy prohibits giving the exam score by email. If you need to know your
final exam score, come to see me during my office hours next semester.
I pledge by honor that I will not discuss the contents of this exam with
anyone.
Signed by Date
Design a class named Person and its two subclasses named Student and
Employee. Make Faculty and Staff subclasses of Employee. A person has a
name, address, phone number, and email address. A student has a class
status (freshman, sophomore, junior, or senior). Define the status as a
constant. An employee has an office, salary, and date hired. Define a
class named MyDate that contains the fields year, month, and day. A
faculty member has office hours and a rank. A staff member has a title.
Override the toString method in each class to display the class name
and the person's name.
Draw the UML diagram for the classes. Write the code for the Student
class only.
2
2. Design and use interfaces (10 pts)
3
3. Design and create GUI applications (10 pts)
Write a Java applet to add two numbers from text fields, and
displays the result in a non-editable text field. Enable your applet
to run standalone with a main method. A sample run of the applet is
shown in the following figure.
4
4. Text I/O (10 pts)
5
5. Multiple Choice Questions: (1 pts each)
(1. Mark your answers on the sheet. 2. Login and click Take
Instructor Assigned Quiz for QFinal. 3. Submit it online
within 5 mins. 4. Close the Internet browser.)
#
2. An attribute that is shared by all objects of the class is coded
using .
a. an instance variable
b. a static variable
c. an instance method
d. a static method
#
3. If a class named Student has no constructors defined explicitly,
the following constructor is implicitly provided.
a. public Student()
b. protected Student()
c. private Student()
d. Student()
#
4. If a class named Student has a constructor Student(String name)
defined explicitly, the following constructor is implicitly provided.
a. public Student()
b. protected Student()
c. private Student()
d. Student()
e. None
#
5. Suppose the xMethod() is invoked in the following constructor in
a class, xMethod() is in the class.
public MyClass() {
xMethod();
a. a static method
b. an instance method
c. a static method or an instance method
#
6. Suppose the xMethod() is invoked from a main method in a class as
follows, xMethod() is in the class.
6
xMethod();
}
a. a static method
b. an instance method
c. a static or an instance method
#
7. What would be the result of attempting to compile and
run the following code?
public class Test {
static int x;
#
8. Analyze the following code:
#
9. Suppose s is a string with the value "java". What will be
assigned to x if you execute the following code?
char x = s.charAt(4);
a. 'a'
b. 'v'
c. Nothing will be assigned to x, because the execution causes the
runtime error StringIndexOutofBoundsException.
d. None of the above.
#
10. What is the printout for the following code?
class Test {
7
public static void main(String[] args) {
int[] x = new int[3];
System.out.println("x[0] is "+x[0]);
}
}
a. The program has a syntax error because the size of the array
wasn't specified when declaring the array.
b. The program has a runtime error because the array elements are
not initialized.
c. The program runs fine and displays x[0] is 0.
d. None of the above.
#
11. How can you get the word "abc" in the main method from the
following call?
a. args[0]
b. args[1]
c. args[2]
d. args[3]
#
12. Which code fragment would correctly identify the number of
arguments passed via the command line to a Java application,
excluding the name of the class that is being invoked?
#
13. Show the output of running the class Test in the following code
lines:
interface A {
void print();
}
class C {}
class Test {
public static void main(String[] args) {
B b = new B();
if (b instanceof A)
System.out.println("b is an instance of A");
if (b instanceof C)
System.out.println("b is an instance of C");
}
}
8
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.
#
14. When you implement a method that is defined in a superclass, you
the original method.
a. overload
b. override
c. copy
d. call
#
15. What modifier should you use on a variable so that it can only be
referenced inside its defining class.
a. public
b. private
c. protected
d. Use the default modifier.
#
16. 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() {
System.out.println(
"The default constructor of B is invoked");
}
}
public class C {
public static void main(String[] args) {
B b = new B();
}
}
a. none
b. "The default constructor of B is invoked"
c. "The default constructor of A is invoked" followed by "The
default constructor of B is invoked"
d. "The default constructor of A is invoked"
#
17. Analyze the following program.
class Test {
9
public static void main(String[] args) {
try {
String s = "5.6";
Integer.parseInt(s); // Cause a NumberFormatException
int i = 0;
int y = 2 / i;
System.out.println("Welcome to Java");
}
catch (Exception ex) {
System.out.println(ex);
}
}
}
a. An exception is raised due to Integer.parseInt(s);
b. An exception is raised due to 2 / i;
c. The program has a compilation error.
d. The program compiles and runs without exceptions.
#
18. What is displayed on the console when running the following
program?
class Test {
public static void main(String[] args) {
try {
System.out.println("Welcome to Java");
int i = 0;
int y = 2/i;
System.out.println("Welcome to Java");
}
catch (RuntimeException ex) {
System.out.println("Welcome to Java");
}
finally {
System.out.println("End of the block");
}
}
}
a. The program displays Welcome to Java three times followed by End
of the block.
b. The program displays Welcome to Java two times followed by End of
the block.
c. The program displays Welcome to Java three times.
d. The program displays Welcome to Java two times.
#
19. 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")
10
#
20. After the following program is finished, how many bytes are written to the
file t.dat?
import java.io.*;
11
Random documents with unrelated
content Scribd suggests to you:
N.o 210. Morte eterna.
É a consequencia necessaria do peccado. Rom. vi, 16, 21; viii, 13;
Thia. i, 15.
É o estipendio do peccado. Rom. vi, 23.
A sorte dos impios. Matt. xxv, 41, 46; Rom. i, 32.
O caminho está descripto. Ps. ix (1.a parte) 18; Matt. vii, 13.
A justiça propria leva-nos á morte eterna. Prov. xiv, 12.
Só Deus a póde infligir. Matt. x, 28; Thia. iv, 12.
§ é chamada:
§ abunda:
§ conduz:
Á
Á presença de Christo. 2 Cor. v, 8; Filip. i, 23.
A uma corôa de justiça. 2 Tim. iv, 8.
A uma corôa da vida. Apoc. ii, 10.
A uma resurreição jubilosa. Isa. xxvi, 19; Dan. xii, 2.
O impio não a considera. Isa. lvii; 1.
Consolação, para os sobreviventes. 1 Thes. iv, 12-17.
Os impios desejam que a sua morte seja como a dos justos. Num.
xxiii, 10.
Elucidação. Luc. xvi, 22.
Exemplos: Abrahão, Gen. xxv, 8; Isaac, Gen. xxxv, 29; Jacob, Gen.
xlix, 33; Arão, Num. xx, 28; Moysés, Deut. xxxiv, 5; Josué,
Jos. xxiv, 29; Elyseu, 4 Reis, xiii, 14, 20; O bom ladrão, Luc.
xxiii, 43; Dorcas, Act. ix,37.
N.o 212. Morte dos impios.
É na sua iniquidade. Ezeq. iii, 19; João, viii, 21.
É sem esperança. Prov. xi, 7.
Algumas vezes effectua-se sem medo. Jer. xxxiv, 5 com 2 Paral.
xxxvi, 11-13.
Frequentemente é subita e inesperada, Job, xxi, 13, 23; xxvii, 21;
Prov. xxix, 1.
Não raras vezes conspicua pelo terror. Job, xviii, 11-15; xxvii, 19-
21; Ps. lxxii, 19.
Segue-se-lhe o castigo. Isa. xiv, 9; Act. i, 25.
A lembrança d’elles acaba com a morte. Job, xviii, 17; Ps. xxxiii,
17; Prov. x, 7.
Não é da vontade de Deus. Ezeq. xviii, 23, 32.
É como a morte dos brutos. Ps. xlviii, 15.
Illustrada. Luc. xii, 20; xvi, 22, 23.
Exemplificada. Coré, etc. Num. xvi, 32; Absalão, 2 Reis, xviii, 9,
10; Acab, 3 Reis, xxii, 34; Jesabel, 4 Reis, ix, 33; Athalia, 2
Paral. xxiii, 15; Aman, Est. vii, 10; Balthazar, Dan. v, 30;
Judas, Matt. xxvii, 5 com Act. i, 18; Ananias, etc. Act. v, 5, 9,
10; Herodes, Act. xii, 23.
N.o 213. Murmuração.
É prohibida. 1 Cor. x, 10; Filip. ii, 14.
§ contra:
§ inclue:
§ deve proceder:
De coração. Deut. xi, 13; Rom. vi, 17.
Voluntariamente. Ps. xvii, 45; Isa. i, 19.
Com exactidão. Jos. xxii, 2, 3.
Sem desvio. Deut. xxviii, 14.
Constantemente. Filip. ii, 12.
Resolvei fazer tudo o que o Senhor manda. Ex. xxiv, 7; Jos. xxiv,
24.
Confessae que tendes faltado a escutar a voz do Senhor. Dan. ix,
10.
Preparae os vossos corações para o Senhor. 1 Reis, vii, 3; 1 Esd.
vii, 10.
Pedi que vos guie. Ps. cxviii, 35; cxlii, 10.
Promessas aos obedientes. Ex. xxiii, 22; 1 Reis, xii, 14; Isa. i, 19;
Jer. vii, 23.
A obediencia ha de ser universal nos ultimos dias. Dan. vii, 27.
Benção para os que obedecerem. Deut. xi, 27; xxviii, 1-13; Luc. xi,
28; Thia. i, 25.
Os impios recusam obedecer. Ex. v, 2; 2 Esd. ix, 17.
Castigo dos que recusam. Deut. xi, 28; xxviii, 15-68; Jos. v, 6; Isa.
i, 20.
Exemplos: Noé, Gen. vi, 22; Abrahão, Gen. xii, 1-4 com Heb. xi, 8;
Gen. xxii, 3, 12; Os israelitas, Ex. xii, 28; xxiv, 7; Caleb, etc.
Num. xxxii, 12; Asa, 3 Reis, xv, 11; Elias, 3 Reis, xvii, 5;
Ezequias, 4 Reis, xviii, 6; Josias, 4 Reis, xxii, 2; David, Ps.
cxviii, 106; Zorobabel, etc. Ag. i, 12; José, Matt. i, 24; Os
Magos, Matt. ii, 12; Zacharias, etc. Luc. i, 6; Paulo, Act. xxvi,
19; Os justos de Roma, Rom. xvi, 19.
N.o 215. Odio.
É probibido. Lev. xix, 17; Col. iii, 8.
O que odeia os seus proximos é homicida. 1 João, iii, 15.
As inimisades são obra da carne. Gal. v, 20.
Muitas vezes encobre-o a mentira. Prov. x, 18; xxvi, 26.
Palavras humildes o occultam. Prov. xxvi, 24, 25.
Excita rixas. Prov. x, 12.
Amargura a vida. Prov. xv, 17.
§ é inconsistente:
§ os impios manifestam-o:
§ os justos:
São odiados por causa do nome do Senhor. Matt. x, 22; João, xv,
18, 19.
Não devem admirar. 1 João, iii, 13.
Não dão mal por mal. Ex. xxiii, 5; Matt. v, 44.
Não folgam com a ruina dos que lhes tem odio. Job, xxxi, 29, 30;
Ps. xxxiv, 13, 14.
Evitam que o proximo os venha a aborrecer. Prov. xxv, 17.
Castigos. Ps. xxxiii, 22; xliii, 8; lxxxviii, 24; Amos, i, 11.
§ devemos aborrecer:
§ encerra:
§ manifestam-se:
Tentando-o. Act. v, 9.
Vexando-o. Isa. lxiii, 10.
Entristecendo-o. Ef. iv, 30.
Extinguindo-o. 1 Thes. v, 19.
Mentindo-lhe. Act. v, 3, 4.
Resistindo-lhe. Act. vii, 51.
Menospreciando os seus dons. Act. viii, 19, 20.
Os que cairem depois de terem sido illuminados pelo Espirito
Santo, não serão renovados. Heb. vi, 4-6.
Aquelle que o ultrajar será castigado severamente. Heb. x, 29.
Aquelle que desprezar o seu testemunho será castigado. 2 Esd. ix,
30.
Não será perdoada a blasphemia contra elle. Matt. xii, 31, 32; 1
João, v, 16.
N.o 218. Olvidar a Deus.
É caracteristico dos impios. Prov. ii, 17; Isa. lxv, 11.
É crime dos apostatas. Jer. iii, 21, 22.
§ é esquecer-se:
§ faz-se:
§ o espirito santo:
§ apoiae-vos:
Nas promessas de Deus. Gen. xxxii, 9-12; Ex. xxxii, 13; 3 Reis, viii,
26; Ps. cxviii, 49.
Na sua alliança. Jer. xiv, 21.
Na sua verdade. Ps. clxii, 1.
Na sua misericordia. Ps. l, 3; Dan. ix, 18.
Na sua justiça. Dan. ix, 16.
Orae de manhã. Ps. v, 4; cxviii, 147.
Supplicae-lhe que vos ensine. Luc. xi, 1.
Importa orar sempre. Luc. xviii, 1.
Perseverar. Rom. xii, 12.
Evitae que vos impidam nas vossas orações. 1 Ped. iii, 7.
É saudavel invocar a Deus na tribulação. Isa. xxvi, 16; Thia. v, 13.
Orae; o tempo é curto. 1 Ped. iv, 7.
§ christo:
§ a resposta é concedida:
§ a promessa é feita:
§ os justos:
§ não é attendida:
§ deus ha de:
§ os impios:
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
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.
testbankpack.com