0% found this document useful (0 votes)
159 views

Unit 9 AP Computer Science Practice Exam

The document is a practice exam for an AP Computer Science A class covering inheritance. It contains 9 multiple choice questions about inheritance concepts like extends, subclasses, superclasses, calling superclass constructors and methods, and overriding methods.

Uploaded by

shandilyaabhijay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
159 views

Unit 9 AP Computer Science Practice Exam

The document is a practice exam for an AP Computer Science A class covering inheritance. It contains 9 multiple choice questions about inheritance concepts like extends, subclasses, superclasses, calling superclass constructors and methods, and overriding methods.

Uploaded by

shandilyaabhijay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Unit 9 AP Computer Science A Practice Exam

Inheritance

Section I – Multiple Choice


Optional Time – 18 minutes
9 Questions

1) Which of the following are true 4) Which of the following code inside
about the concept of inheritance? of the constructor of a subclass calls
the constructor of the superclass?
I. By extending a subclass from a
superclass, an “is-a” relationship (A) super();
is established. (B) init();
II. The super keyword is used to (C) constructor();
call the constructor of a subclass. (D) this();
III. The extends keyword is used
to establish an inheritance 5) In a subclass that extends a
relationship. superclass, how would a method be
called?
(A) I only
(B) I and II (A) super.this.method();
(C) I and III (B) super().method();
(D) II and III (C) method();
(E) I, II, and III No change, (D) extends.method();
method is already inherited
2) Classes that extend a superclass can 6) When a subclass has a method with
draw upon ______ from that the same signature (but different
superclass. body) than a method in its
superclass, the method is being:
(A) Fields only (A) Overdone
(B) Methods only (B) Overloaded
(C) Fields and methods only (C) Supered
(D) Fields, methods, and (D) Overridden
constructors
7) Given the following class header,
3) When writing a subclass, the only which is the superclass?
part required is the subclass’s ____
public A extends B
(A) Constructor
(B) Methods (E) A
(C) Fields (F) B
(D) Constructor and fields (G) Neither
(H) Both

This practice test was created by Ajay Gandecha.


This test and I are not affiliated with, or endorsed by, the College Board.
No questions are copied from the College Board and were made on my own for you to prepare.
Good luck!
8) A class is created using the following
header:

public X extends Y

Which of the following lines of code


cannot be executed, given the
following code?

ArrayList<Y> myYList =
new ArrayList<Y>;
ArrayList<X> myXList =
new ArrayList<X>;

X xObj = new X();


Y yObj = new Y();

(A) myYList.add(xObj);
(B) myYList.add(yObj);
(C) myXList.add(xObj);
(D) myXList.add(yObj);

9) Which of the following classes are


the superclass of all other classes in
Java?
(E) Class;
(F) Object;
(G) Lang;
(H) Interface;

END OF SECTION I

This practice test was created by Ajay Gandecha.


This test and I are not affiliated with, or endorsed by, the College Board.
No questions are copied from the College Board and were made on my own for you to prepare.
Good luck!

You might also like