Introduction to Java Programming Comprehensive Version 9th Edition Liang Test Bank download
Introduction to Java Programming Comprehensive Version 9th Edition Liang Test Bank download
https://testbankdeal.com/product/introduction-to-java-programming-
comprehensive-version-9th-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-
brief-version-10th-edition-liang-test-bank/
https://testbankdeal.com/product/window-on-humanity-a-concise-
introduction-to-general-anthropology-6th-edition-kottak-test-bank/
Computed Tomography Physical Principles Clinical
Applications and Quality Control 3rd Edition Seeram Test
Bank
https://testbankdeal.com/product/computed-tomography-physical-
principles-clinical-applications-and-quality-control-3rd-edition-
seeram-test-bank/
https://testbankdeal.com/product/canadian-organizational-
behaviour-8th-edition-mcshane-solutions-manual/
https://testbankdeal.com/product/canadian-advertising-in-action-
canadian-10th-edition-tuckwell-test-bank/
https://testbankdeal.com/product/economy-today-13th-edition-schiller-
solutions-manual/
https://testbankdeal.com/product/preface-to-marketing-management-15th-
edition-peter-test-bank/
Accounting Information Systems 2nd Edition Richardson Test
Bank
https://testbankdeal.com/product/accounting-information-systems-2nd-
edition-richardson-test-bank/
Name:_______________________ CSCI 1302 OO Programming
Armstrong Atlantic State University
(50 minutes) Instructor: Y. Daniel Liang
Part I:
(A)
B’s constructor is invoked
A’s constructor is invoked
(B)
(a) The program has a syntax error because x does not have the compareTo
method.
(b) The program has a syntax error because the member access operator (.) is
executed before the casting operator.
(C)
(1) false
(2) true
(3) false (because they are created at different times)
(4) true
(E) The method throws a checked exception. You have to declare to throw
the exception in the method header.
Part II:
1
return result;
}
a. private method
b. protected method
c. public method
d. a and c
e. b and c
Key:e
2
#
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.
Key:d
#
3. When you implement a method that is defined in a superclass, you
__________ the original method.
a. overload
b. override
c. copy
d. call
Key:b
#
4. What is the output of running the class C.
public class C {
public static void main(String[] args) {
Object[] o = {new A(), new B()};
System.out.print(o[0]);
System.out.print(o[1]);
}
}
class A extends B {
public String toString() {
return "A";
}
}
3
class B {
public String toString() {
return "B";
}
}
a. AB
b. BA
c. AA
d. BB
e. None of above
Key:a
#
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"
Key:c
#
6. Analyze the following code:
a. The program has a syntax error because Test1 does not have a main
method.
4
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.
Key:e
#
7. The method _____ overrides the following method:
#
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());
}
}
5
Key:c
#
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
Key:e
#
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
Key:c
6
Random documents with unrelated
content Scribd suggests to you:
with active links or immediate access to the full terms of the Project
Gutenberg™ License.
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.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
testbankdeal.com