1. One or more objects may be created from a(n)_____.
2. Class objects normally have _____ that perform useful operations on their data, but primitive variables do not. a.fields
3. In the cookie cutter method: Think of the _____ as a cookie cutter and _____ as the cookies. a.object; classes
4. A UML diagram does not contain _____.
5. An access specifier indicates how the class may be accessed. a.True
6. Data hiding, which means that critical data stored inside the object is protected from code outside the object is accomplished in Java by _____. a.using the public access specifier on the class methods
b.using the private access specifier on the class methods
c.using the private access specifier on the class definition d.using the private access specifier on the class fields
7. For the following code, which statement is not true?
public class Sphere
private double radius;
public double x;
private double y;
private double z;
a.x is available to code that is written outside the Sphere class. b.radius is not available to code written outside the Sphere class. c.radius, x, y, and z are called members of the Sphere class. d.z is available to code that is written outside the Sphere class.
8. Which of the following is not part of the method header?
d.Parameter variable declaration
e.All of the above are parts of the method header
9. A method that stores a value in a class’s field or in some other way changes the value of a field is known as a mutator method. a.True
10. You should not define a class field that is dependent upon the values of other class fields _____. a.in order to avoid having stale data
b.because it is redundant
c.because it should be defined in another class
d.in order to keep it current
11. The following UML diagram entry means _____
+ setHeight(h : double) : void
a.this is a public field called Height and is a double data type b.this is a private method with no parameters and returns a double data type c.this is a private field called Height and is a double data type d.this is a public method with a parameter of data type double and does not return a value
12. Instance methods should be declared static.
13. Methods that operate on an object’s fields are called
14. The scope of a private instance field is
a.the instance methods of the same class
b.inside the class, but not inside any method
c.inside the parentheses of a method header
d.the method in which they are defined
15. A constructor is a method that is automatically called when an object is created. a.True
16. A constructor
a.always accepts two arguments
b.has return type of void
c.has the same name as the class
d.always has an access specifier of private
17. Shadowing is the term used to describe where the field name is hidden by the name of a local or parameter variable. a.True
18. Which of the following statements will create a reference, str, to the String, “Hello, World”? a.String str = “Hello, World”;
b.string str = “Hello, World”;
c.String str = new “Hello, World”;
d.str = “Hello, World”;
19. Two or more methods in a class may have the same name as long as a.they have different return types
b.they have different parameter lists