5 min read•june 18, 2024
⛔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: [object Object].
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 [object Object] the formatting on the exam may be different.
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
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
A.
B.
C.
D.
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
A.
B.
C.
D.
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
A.
B.
C.
D.
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
-----
A.
B.
C.
D.
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
-----
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
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
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
-----
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
🔍 Study for Unit 10
🦘 Jump to AP CSA Unit 10 Multiple Choice Questions
🤝 Connect with other students studying AP CSA with [object Object]