Assignment 3 Questions
Which symbol indicates that a member is public in a UML diagram? Select one: A. # B. * C. + D. -
C. +
Which symbol indicates that a member is private a UML diagram? Select one: A. - B. + C. # D. *
A. -
One or more objects may be created from a(n) Select one: A. field. B. method. C. class. D. instance
C. class
The scope of a local variable is Select one: A. inside the class but not inside any method. B. the method in which it is defined. C. inside the parentheses of a method header. D. the entire class.
B. the method in which it is defined
Another term for an object of a class is a(n) Select one: A. method. B. access specifier. C. member. D. instance.
D. instance
The public access specifier for a field indicates that the field may not be accessed by statements outside the class. Select one: True False
False
The term "default constructor" is applied to the first constructor written by the author of the class. Select one: True False
False
The term "no-arg constructor" is applied to any constructor that does not accept arguments. Select one: True False
True
A method Select one: A. may not have only one parameter variable. B. never has parameter variables. C. may have zero or more parameters. D. must have at least two parameter variables.
C. may have zero or more parameters.
A group of related classes is called aNo Select one: A. collection. B. archive. C. package. D. attachment.
C. package
What is the following statement an example of? import java.util.*; Select one: A. an unconditional import statement B. a wildcard import statement C. a conditional import statement D. an explicit import statement
B. a wildcard import statement
The key word new Select one: A. creates a new Java byte code file. B. creates an object in memory. C. creates a new variable in memory. D. creates a new class.
B. creates an object in memory.
A constructor Select one: A. has the return type of void. B. has the same name as the class. C. always accepts two arguments. D. always has a private access specifier.
B. has the same name as the class.
Methods that operate on an object's fields are called Select one: A. private methods. B. instance methods. C. instance variables. D. public methods.
B. instance methods.
When an argument is passed by value Select one: A. changes can be made to the argument variable. B. the parameter variable holds the address of the argument. C. the parameter variable holds a copy of the value passed to it. D. the parameter variable cannot be changed.
B. the parameter variable holds the address of the argument.
To indicate the data type of a variable in a UML diagram you specify Select one: A. the variable name followed by the data type. B. the variable name followed by a colon and the data type. C. the class name followed by the variable name followed by the data type. D. the data type followed by the variable name.
B. the variable name followed by a colon and the data type.
Which of the following is not involved in identifying the classes to be used when developing an object-oriented application? Select one: A. Identify all the nouns. B. Write the code. C. Refine the list of nouns to include only those relevant to the problem. D. Describe the problem domain.
B. write the code
For the following code, which statement is not true? public class Circus { private double radius; public double x; private double y; private double z; } Select one: A. The radius field is not available to code written outside the Sphere class. B. The x field is available to code that is written outside the Sphere class. C. The z field is available to code written outside the Sphere class. D. The radius, x, y, and z fields are members of the Sphere class.
C. The z field is available to code written outside the Sphere class.
What does the following UML diagram entry mean? + setHeight(h : double) : void Select one: A. a private method with no parameters that returns a double data type B. a public field called Height that is a double data type C. a public method with a parameter of data type double that does not return a value D. a private field called setHeight that is a double data type
C. a public method with a parameter of data type double that does not return a value
What is the following statement an example of? import java.util.Scanner; Select one: A. a wildcard import statement B. a conditional import statement C. an explicit import statement D. an unconditional import statement
C. an explicit import statement
A class's responsibilities include Select one: A. the things a class is responsible for doing. B. the things a class is responsible for knowing. C. both of these. D. neither of these.
C. both of these
You should not define a class that is dependent on the values of other class fields Select one: A. because it is redundant. B. in order to keep it current. C. in order to avoid having stale data. D. because it should be defined in another class.
C. in order to avoid having stale data.
When an object is created, the attributes associated with the object are called Select one: A. fixed attributes. B. class instances. C. instance fields. D. instance methods.
C. instance fields.
Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by Select one: A. using the private access specifier on the class fields. B. using the private access specifier on the class methods. C. using the private access specifier on the class definition. D. using the public access specifier on the class methods.
C. using the private access specifier on the class fields.
For the following code, which statement is not true? public class Circus { private double radius; public double x; private double y; } Select one: A. The x field is available to code that is written outside the Circle class. B. The radius, x, and y fields are members of the Circle class. C. The radius field is not available to code written outside the Circle class. D. The y field is available to code written outside the Circle class.
D. The y field is available to code written outside the Circle class.
If you do not provide initialization values for a class's numeric fields, they will Select one: A. cause a runtime error. B. contain an unknown value. C. cause a compiler error. D. be automatically initialized to 0.
D. be automatically initialized to 0.
After the header, the body of the method appears inside a set of Select one: A. double quotes, " " B. parentheses, ( ) C. brackets, [ ] D. braces, { }
D. braces, { }
It is common practice in object-oriented programming to make all of a class's Select one: A. methods private. B. fields public. C. fields and methods public. D. fields private.
D. fields private
Which is the key word used to import a class? Select one: A. use B. assume C. link D. import
D. import
Class objects normally have ________ that perform useful operations on their data, but primitive variables do not. Select one: A. fields B. relationships C. instances D. methods
D. methods
UML diagrams do not contain Select one: A. class names. B. fields. C. methods. D. object names.
D. object names
Using the blueprint/house analogy, you can think of a class as a blueprint that describes a house and ________ as instances of the house built from the blueprint. Select one: A. fields B. attributes C. methods D. objects
D. objects
A constructor is a method that Select one: A. removes the object from memory. B. returns an object of the class. C. never receives any arguments. D. performs initialization or setup operations.
D. performs initialization of setup operations.
A method that gets a value from a class's field but does not change it is known as a mutator method. Select one: True False
False
When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable. Select one: True False
False
"Shadowing" is the term used to describe how the field name is hidden by the name of a local or parameter variable. Select one: True False
True
A constructor is a method that is automatically called when an object is created. Select one: True False
True
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. Select one: True False
True
An access specifier indicates how a class may be accessed. Select one: True False
True
The java.lang package is automatically imported into all Java programs. Select one: True False
True