9.9 MC Answers and Review

5 min readdecember 26, 2021

AP Computer Science A 💻

130 resources
See Units

Answers and Review for Multiple Choice Practice on Inheritance

Image From Wikipedia.

⛔STOP!⛔ Before you look at the answers make sure you gave this practice quiz a try so you can assess your understanding of the concepts covered in unit 9. Click here for the practice questions: AP CSA Unit 9 Multiple Choice Questions.
Facts about the test: The AP Computer Science A exam has 40 multiple choice questions and you will be given 90 minutes to complete the section. That means it should take you around 23 minutes to complete 10 questions.
*The following questions were not written by CollegeBoard and although they cover information outlined in the AP Computer Science A Course and Exam Description the formatting on the exam may be different.

1. Which one of these is the correct way to make a subclass?

A. public class SubClass extends SuperClass {}
B. public class SubClass {}
C. public class SubClass parent SuperClass {}
D. public class SubClass super SuperClass {}
Answer: proper syntax
📄 Study AP CSA, Unit 9.1: Creating Superclasses and Subclasses

2. What keyword is used to call objects in the parent class including constructors, variables, methods, etc.?

A. this
B. extends
C. requires
D. ​​super
Answer: definition as parent class is also known as the superclass, therefore the super keyword is used to call objects from the parent class
📄 Study AP CSA, Unit 9.4: Super Keyword

3. Given the code below, which method successfully overloads the getItem method in the parent class?

Answer: Definiton: Overloading a method requires that the method has the same name, same return type, but has to have different parameters, whether that would be the number of parameters, the types of the parameters, or the order of the parameters
📄 Study AP CSA, Unit 9.3: Overriding Methods

4. Given the code below, which method successfully overrides the getItem method in the parent class?

Answer: Definiton: Definiton: Overriding a method requires that the method has the same name, same return type, and same parameters. The only difference is whatever is in the method can be different from the method in the parent class
📄 Study AP CSA, Unit 9.3: Overriding Methods

5. Given the code below, which one would result in the code not compiling?

Answer: Width is a private variable in the parent class, which is not visible to the subclass, so using the public setWidth method would work instead. 
📄 Study AP CSA, Unit 9.1: Creating Superclasses and Subclasses

6. Given the classes and subclasses created below, which object creation results in an exception when it executes?


AnswerPolymorphism definition. Since Three is a subclass of One and Two, object1 and object2 are objects of One and Two. However, an object of One or Two or Three (being the superclasses of Four) is not always an object of Four. 
📄 Study AP CSA, Unit 9.6: Polymorphism

7. Given the code below, what will be printed out if the code in another class is called?

A. OneTwo
B. Three
C. OneTwoFourThree
D. OneTwoThreeFour
AnswerSince the object created is a Two object, this means that the method called will be the printMethod1 in the Two class. So, printMethod1 in the Two class is called, which calls the superclass method printMethod1 in One. That prints out “One”, and then calls printMethod2 in the Two class, which then calls the superclass method printMethod2 in One. That prints out “Two”, and then goes back to the printMethod2 in Two. That prints out “Four”, and then goes back to the printMethod1 in the Two class, which prints out “Three”, ending the code. 

8. What methods are usually inherited from the Object superclass that are often overriden?

A. I
C. I, II
AnswerBasic knowledge, the toString() method is often overriden to explain what the specific object is and does in text form. The equals() method compares two objects to see if they are the same, which is often overriden as for different objects, sometimes the features within it are what should determine equality, and it will differ. The toFinalize() method doesn't exist in the Object class.
📄 Study AP CSA, Unit 9.3: Overriding Methods

9. What does the keyword static mean when used?

A. This variable/method belongs to the class and is not specific for each instance created of that class.
B. This variable/method belongs to an object created of the class and is specific for each instance created of that class.
C. This variable/method belongs to the class and is specific for each instance created of that class.
D. This variable/method belongs to an object created of the class and is not specific for each instance created of that class.
📄 Study AP CSA, Unit 9.6: Polymorphism

10. Given the classes below, what will be returned if the following main method is called?

A. 25.25
B. 30.75
C. compiler error due to a CottonPillow object created in place of a Pillow object
D. compiler error due to CottonPillow not having a getActualCost() method
AnswerAn object can be created as its subclass. Since CottonPillow is a subclass of the superclass Pillow, it inherits its methods. Despite CottonPillow not having its own getActualCost() method, the call to the getActualCost() method calls the getActualCost() method in Pillow. However, this.getCost() will call the getCost() method in CottonPillow because the object is a CottonPillow object, and not a Pillow object. 

What can we help you do now?

🔍 Study for Unit 10
🦘 Jump to AP CSA Unit 10 Multiple Choice Questions
🤝 Connect with other students studying AP CSA with Hours
Browse Study Guides By Unit
Unit 1 – Primitive Types
📱Unit 2 – Using Objects
🖥Unit 3 – Boolean Expressions & if Statements
🕹Unit 4 – Iteration
⚙️Unit 5 – Writing Classes
⌚️Unit 6 – Array
💾Unit 7 – ArrayList
💻Unit 8 – 2D Array
🖲Unit 9 – Inheritance
🖱Unit 10 – Recursion
🙏Exam Reviews

Stay Connected

© 2023 Fiveable Inc. All rights reserved.

© 2023 Fiveable Inc. All rights reserved.