Homework and Problems for Groton AP Computer Science
// See all files in 'src' folder
9/16/14 Chapter 2
-
C++, Ruby, Python, JavaScript
-
A
-
a) I get "error: illegal character: ''"
b) They are used to document comments.
-
See HomeworkFace9.java
-
a) See DoubleIntegers11a.java
b) It concatenates strings and numbers. The extra set of parentheses specify that it is a mathematical operation.
-
See HWBanner15.java
9/20/14 Chapter 3
-
a) True, a class "Flower" must be stored in a file named "Flower.java".
b) True, in Java all names are case-sensitive.
c) False, the "import" statement tells the compiler which other classes this class uses.
-
a) True, you should only allow access to what users need.
b) True, you can't refer to something that doesn't exist.
c) True, you can have multiple constructors with arguments or no arguments.
d) True, the names are used to refer to specific objects.
e) False, some objects do not even have init methods.
-
i) It is easier to modify. You do not have to manually change every reference in the source code. The getter can access the one changed field.
ii) Users cannot access and change a field's value directly. They will only receive values through a getter. This enhances security.
iii) You can document a class for other programmers who want to use the class by describing all its constructors and public methods; there is no need to document the implementation details.
-
For (a, b) in GridWorld, a is the row and b is the column. Rows and columns are counted from 0.
-
See BookTestPackage folder and Book11.java
-
a) True
b) False
-
a) Yes, Actor to Actor (Superclass to Class)
b) Yes, Actor to Bug (Superclass to Class)
c) Yes, Actor to Flower (Superclass to Class)
d) No, Bug to Actor (Subclass down to Superclass)
e) No, Flower to Actor (Subclass down to Superclass)
f) No, Wrong variable entered in field
g) Yes, Class to Class
h) Yes, Class to Class and valid variable
i) Yes, Bug to Boxbug (Superclass to Class)
See BugRunner16.java and BoxBugRunner16.java
Questions from Chapter 3:
-How do you complete the program on page 69?
-How do you change an object or class from public to private and keep the program functional?
-Can we review Exercise 11 on page 74?