Unit 4 Summative Assessment Review (2023-2024) (Part 1)
Unit 4 Summative Assessment Review (2023-2024) (Part 1)
AP Computer Science A
Unit 4 Summative Review
References, Assignment, Polymorphism, Abstract Classes, and Instance Variables
storm = cyclops;
beast.move();
beast.putBeeper(); // St: __________ Ave: __________
storm.move();
storm.putBeeper(); // St: __________ Ave: __________
cyclops.move();
cyclops.putBeeper(); // St: __________ Ave: __________
cyclops = beast;
beast = storm;
beast.move();
beast.putBeeper(); // St: __________ Ave: __________
storm.move();
storm.putBeeper(); // St: __________ Ave: __________
cyclops.move();
cyclops.putBeeper(); // St: __________ Ave: __________
beast.turnOff();
storm.turnOff();
cyclops.turnOff();
}
}
2. Refer to Runner2.java given below. (Assume all imports)
1 public class Runner2
2 {
3 public static void main(String[] args)
4 {
5 World.setVisible(true);
6 World.setDelay(10);
7
8 UrRobot amy = new UrRobot(3, 2, Directions.East, 0);
9 amy = null;
10
11 amy.move();
12 amy.putBeeper();
13 }
14 }
2a. Identify the line where an error first appears. 2a. ______________________
2b. What type of error can this error be classified as? 2b. ___________________________
e. After being initialized, how many times does the reference 3e. ______________________
brenda get reassigned?
4. Given the following code, change the assignment of the reference below three times to a robot
and increase the street and avenue by one for each change in assignment.
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
}
}
5. Refer to the following simplified UML (Unified Modeling Language) Class Diagram.
BeeperLayer
+putBeepers() : void
+layBeepers() : void
+putAndMove() : void
a. What do you think the "+" sign signifies in front of the method names?
b. What benefits are provided by creating a common superclass for a set of closely related
classes?
7. Refer to the following class headers to determine which of the following are valid instantiations.
(Assume each class has a constructor that accepts four parameters: int, int, Direction, int)
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
For 11-12, refer to the simplified UML (Unified Modeling Language) Class Diagram
shown below. Assume the ShapeBot class extends the UrRobot class.
ShapeBot
+getArea() : double
+getPerimeter() : double
+createShape() : void
-putAndMove() : void
-turnRight() : void
-turnAround() : void
11. Determine whether each of the following statements are valid or not valid. Circle your answer.
12. Determine whether each of the following statements are valid or not valid. Circle your answer.
Class: 1 2 3 4 5
Method: 1 2 3 4 5
Object: 1 2 3 4 5
Reference: 1 2 3 4 5
Assignment: 1 2 3 4 5
Inheritance: 1 2 3 4 5
extends: 1 2 3 4 5
Superclass: 1 2 3 4 5
Subclass: 1 2 3 4 5
IS-A Relationship: 1 2 3 4 5
Polymorphism: 1 2 3 4 5
private: 1 2 3 4 5
public: 1 2 3 4 5
constructor: 1 2 3 4 5
Parameter: 1 2 3 4 5
Argument: 1 2 3 4 5
Abstract Class: 1 2 3 4 5
Instance Variable: 1 2 3 4 5
Initialize: 1 2 3 4 5
Local Variable: 1 2 3 4 5