πŸ“š

Β >Β 

πŸ’»Β 

Β >Β 

πŸ–²

9.9 MC Answers and Review

5 min readβ€’december 26, 2021


AP Computer Science AΒ πŸ’»

130Β resources
See Units

Answers and Review for Multiple Choice Practice on Inheritance
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-GzCNhwUn3IW7.png?alt=media&token=ecb58ab1-80f8-40d4-b84a-a01f4b666cd6

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?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-IF5EvxQvTj1h.png?alt=media&token=44350807-53ac-4212-ae87-cd413f0337bd
A.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-QHzIxr7LxEZh.png?alt=media&token=1312ee24-1e89-4556-9bb4-64ceac9a8853
B.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-COsnAPoQnijm.png?alt=media&token=9c807581-dd60-433c-8946-b4a56fc082cf
C.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-tyV31kAOpJTS.png?alt=media&token=adad99ce-6363-42af-998c-d8e40459dfda
D.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-F3lfeaEoUDIU.png?alt=media&token=3b1c2bc6-afb8-49ad-b585-a8a820263766
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?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-5HIWGl693HFV.png?alt=media&token=e97658b6-4123-499b-8fc4-928acc3b255a
A.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-rZCZgBaZILku.png?alt=media&token=3cefc247-31be-4070-8d2e-6bc17deae4d2
B.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-pbXLcl1VO1Ab.png?alt=media&token=7a21b926-2af2-494f-86e2-b39e546e2266
C.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-5yJWS8SRtsLg.png?alt=media&token=e329f1f7-d687-48d8-b387-bfbbc7c0d84b
D.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-wmJPbOpHRvxp.png?alt=media&token=7697b5a2-fe52-4bef-b61f-b9efc7059068
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?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-lMMML9h4AlCt.png?alt=media&token=e3ec5336-0a88-4121-9e5f-8d27992b9aff
A.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-Pza2Dbcnb4kC.png?alt=media&token=26eec346-0492-4304-871c-1524b41a67ca
B.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-wVG86Cjynaeu.png?alt=media&token=34b58571-8b9d-4367-8c27-0547ae235aa6
C.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-X2YmsnJmUes0.png?alt=media&token=4d1618d4-1f83-4452-a41d-82c9eef278e2
D.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-HgHfwodBc28O.png?alt=media&token=7a610733-dfd7-4157-939e-1d7083f2e55a
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?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-7MiaMyCdiPLk.png?alt=media&token=6e22ccb7-7ce1-4bd4-b86e-0b13ebf452d7

A.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-b6fcYjJivw1v.png?alt=media&token=c9321585-5213-4bae-be60-0e3345ddbe90
B.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-3IqZBIRYv7kr.png?alt=media&token=f5ac73b1-906a-4e3a-9677-326969f51bdf
C.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-lWVJG9wt45VH.png?alt=media&token=ac7a5e0a-c6b7-44e2-8e3a-ba431d87f699
D.Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-GPegHSkkbKTk.png?alt=media&token=c76d1d24-f602-479a-88da-54424088575e
Answer:Β Polymorphism 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?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-GMrKKy5eSMcx.png?alt=media&token=03cb73ed-9ff5-412e-80c4-52940a95891c
A. OneTwo
B. Three
C. OneTwoFourThree
D. OneTwoThreeFour
Answer:Β Since 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.Β 
πŸ“„ Study AP CSA, Unit 9.5:Β Creating References Using Inheritance Hierarchies

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

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-PMNtmtWjPtje.png?alt=media&token=297db4e4-b1d1-4417-a10b-37a202e8c56a
A. I
B. II
C. I, II
D. I, II, III
Answer:Β Basic 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.
Answer:Β Definition
πŸ“„ Study AP CSA, Unit 9.6:Β Polymorphism

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

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-5cNzZ9RKzctA.png?alt=media&token=473a7cf6-9db7-4c8a-a712-18c5bb09a90d
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
Answer:Β An 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.Β 
πŸ“„ Study AP CSA, Unit 9.5:Β Creating References Using Inheritance Hierarchies

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 10 – Recursion
πŸ™Exam Reviews