You are on page 1of 15

This is a collection of programming statements that specify the fields and

methods that a particular type of object may have.


a. class
b. method
c. parameter
d. instance
a. class
A class is analogous to a(n) ______.
a. house
b. blueprint
c. drafting table
d. architect
b. blueprint
An object is a(n) ______.
a. blueprint
b. primitive data type
c. variable
d. instance of a class
d. instance of a class
This is a class member that holds data.
a. method
b. instance
c. field
d. constructor
c. field
This key word causes an object to be create in memory.
a. create
b. new
c. object
d. construct
b. new
This is a method that gets a value from a class's field, but does not change it.
a. accessor
b. constructor
c. void
d. mutator
a. accessor
This is a method that stores a value in a field or in some other way changes
the value of a field.
a. accessor
b. constructor
c. void
d. mutator
d. mutator
When the value of an item is dependent on other data, and that item is not
updated when the other data is changed, what has the value become?
a. bitter
b. stale
c. asynchronous
d. moldy
b. stale
This is a method that is automatically called when an instance of a class is
created.
a. accessor
b. constructor
c. void
d. mutator
b. constructor
When a local variable has the same name as a field, the local variable's name
does this to the field's name.
a. shadows
b. complements
c. deletes
d. merges with
a. shadows
This is automatically provided for a class if you do not write one yourself.
a. accessor method
b. default instance
c. default constructor
d. variable declaration
c. default constructor
Two or more methods in a class may have the same name, as long as this is
different.
a. their return values
b. their access specifier
c. their parameter lists
d. their memory address
c. their parameter lists
The process of matching a method call with the correct method is known as
______.
a. matching
b. binding
c. linking
d. connecting
b. binding
A class's responsibilities are ______.
a. the objects created from the class
b. things the class knows
c. actions the class performs
d. both b and c
d. both b and c
T/F: The new operator creates an instance of a class.
True
Each instance of a class has its own set of instance fields
True
When you write a constructor for a class, it still has the default constructor that
Java automatically provides.
False
A class may not have more than one constructor.
False
To find the classes needed for an object-oriented application, you identify all
of the verbs in a description of the problem domain.
False
In an array declaration, this indicates the number of elements that the array
will have.
a. subscript
b. size declarator
c. element sum
d. reference variable
b.size declarator
Each element of an array is accessed by a number known as a(n) ______.
a. subscript
b. size declarator
c. address
d. specifier
a. subscript
The first subscript in an array is always ______.
a. 1
b. 0
c. -1
d. 1 less than the number of elements
b. 0
The last subscript in an array is always ______.
a. 1
b. 0
c. -1
d. 1 less than the number of elements
d. 1 less than the number of elements
Array bounds checking happens ______.
a. when the program is compiled
b. when the program is saved
c. when the program runs
d. when the program is loading into memory
c. when the program runs
This array field hold the number of elements that the array has.
a. size
b. elements
c. length
d. width
c. length
When initializing a two-dimensional array, you enclose each row's initialization
list in ______.
a. braces
b. parentheses
c. brackets
d. quotation marks
a. braces
To insert an item at a specific location in an ArrayList object, you use this
method.
a. store
b. insert
c. add
d. get
c. add
To delete an item from an ArrayList object, you use this method.
a. remove
b. delete
c. erase
d. length
a. remove
To determine the number of items stored in an ArrayList object, you ue this
method.
a. size
b. capacity
c. items
d. length
a. size
T/F: Java does not allow a statement to use a subscript that is outside the
range of valid subscripts for an array.
True
T/F: An array's size declarator can be a negative integer expression.
False
T/F: Both of the following declarations are legal and equivalent:
int [ ] numbers;
int numbers [ ];
True
T/F: The subscript of the last element in a single-dimensional array is one less
than the total number of elements in the array.
True
T/F: The values in an initialization list are stored in the array in the order that
they appear in the list
True
T/F: The Java compiler does not display an error message when it processes
a statement that uses an invalid subscript.
True
T/F: When an array is passed to a method, the method has access to the
original array.
True
T/F: The first size declarator in the declaration of a two-dimensional array
represents the number of columns. The second size declarator represents the
number of rows.
False
T/F: An ArrayList automatically expands in size to accommodate the items
stores in it
True
This type of method cannot access any non-static member variables in its
own class.
a. instance
b. void
c. static
d. non-static
c. static
When an object is passed as an argument to a method, this is typically
passed.
a. a copy of the object
b. the name of the object
c. a reference to the object
d. none of these; you can pass an object
c. a reference to the object
If you write this method for a class, Java will automatically call it any time you
concatenate an object of the class with a string.
a. toString
b. plusString
c. stringConvert
d. concatString
a. toString
This is the name of a reference variable that is always available to an instance
method and refers to the object that is calling the method.
a. callingObject
b. this
c. me
d. instance
b. this
The Java Virtual Machine periodically performs this process, which
automatically removes unreferenced objects from memory.
a. memory clensing
b. member deallocation
c. garbage collection
d. object expungement
c. garbage collection
If a class has this method, it is called automatically just before an instance of
the class is destroyed by the Java Virtual Machine.
a. finalize
b. destroy
c. remove
d. housekeeping
a. finalize
CRC stands for
a. Class, Return Value, Composition
b. Class, Responsibilities, Collaborations
c. Class, Responsibilities, Composition
d. Compar, Return, Continue
b. Class, Responsibilities, Collaborations
T/F: A static member method may refer to non-static member variable of the
same class, but only after an instance of the class has been defined.
False
T/F: All static member variables are initialized to -1 by default.
False
T/F: When an object is passed as an argument to a method, the method can
access the argument
True
T/F: A method cannot return a reference to an object.
False
This type of method cannot access any non-static member variables in its
own class.
a. instance
b. void
c. static
d. non-static
c. static
When an object is passed as an argument to a method, this is typically
passed.
a. a copy of the object
b. the name of the object
c. a reference to the object
d. none of these; you can pass an object
c. a reference to the object
If you write this method for a class, Java will automatically call it any time you
concatenate an object of the class with a string.
a. toString
b. plusString
c. stringConvert
d. concatString
a. toString
Making an instance of one class a field in another class is called
a. nesting
b. class fielding
c. aggregation
d. concatenation
c. aggregation
This is the name of a reference variable that is always available to an instance
method and refers to the object that is calling the method.
a. callingObject
b. this
c. me
d. instance
b. this
This enum method returns the position of an enum constant in the declaration.
a. position
b. location
c. ordinal
d. toString
c. ordinal
Assuming the following declaration exists:
enum Seasons {spring, winter, summer, fall}
what is the fully qualified name of the fall constant?
a. fall
b. enum.fall
c. fall.Seasons
d. Seasons.fall
d. Seasons.fall
You cannot use the fully qualified name of an enum constant for this.
a. a switch expression
b. a case expression
c. an argument to a method
d. all of these
b. a case expression
The Java Virtual Machine periodically performs this process, which
automatically removes unreferenced objects from memory.
a. memory clensing
b. member deallocation
c. garbage collection
d. object expungement
c. garbage collection
If a class has this method, it is called automatically just before an instance of
the class is destroyed by the Java Virtual Machine.
a. finalize
b. destroy
c. remove
d. housekeeping
a. finalize
CRC stands for
a. Class, Return Value, Composition
b. Class, Responsibilities, Collaborations
c. Class, Responsibilities, Composition
d. Compar, Return, Continue
b. Class, Responsibilities, Collaborations
T/F: A static member method may refer to non-static member variable of the
same class, but only after an instance of the class has been defined.
False
T/F: All static member variables are initialized to -1 by default.
False
T/F: When an object is passed as an argument to a method, the method can
access the argument
True
T/F: A method cannot return a reference to an object.
False
T/F: You can declare an enumerated data type inside a method.
False
T/F: Enumerated data types are actually special types of classes.
True
T/F: enum constants have a toString method.
True
The isDigit , isLetter , and isLetterOrDigit methods are members of this class.

a. String
b. Char
c. Character
d. StringBuilder
c. Character
This method converts a character to uppercase.

a. makeUpperCase
b. toUpperCase
c. isUpperCase
d. upperCase
b. toUpperCase
The startsWith , endsWith , and regionMatches methods are members of this
class.

a. String
b. Char
c. Character
d. Wrapper
a. String
The indexOf and lastIndexOf methods are members of this class.

a. String
b. Integer
c. Character
d. Wrapper
a. String
The substring , getChars , and toCharArray methods are members of this
class.

a. String
b. Float
c. Character
d. Wrapper
a. String
This String class method performs the same operation as the + operator when
used on strings.

a. add
b. join
c. concat
d. plus
c. concat
The String class has several overloaded versions of a method that accepts a
value of any primitive data type as its argument and returns a string
representation of the value. The name of the method is ___________.

a. stringValue
b. valueOf
c. getString
d. valToString
b. valueOf
If you do not pass an argument to the StringBuilder constructor, the object will
have enough memory to store this many characters.

a. 16
b. 1
c. 256
d. Unlimited
a. 16
This is one of the methods that are common to both the String and
StringBuilder classes.

a. append
b. insert
c. delete
d. length
d. length
To change the value of a specific character in a StringBuilder object, use this
method.

a. changeCharAt
b. setCharAt
c. setChar
d. change
b. setCharAt
To delete a specific character in a StringBuilder object, use this method.

a. deleteCharAt
b. removeCharAt
c. removeChar
d. expunge
a. deleteCharAt
The character that separates tokens in a string is known as a __________.

a. separator
b. tokenizer
c. delimiter
d. terminator
c. delimiter
This String method breaks a string into tokens.

a. break
b. tokenize
c. getTokens
d. split
d. split
These static final variables are members of the numeric wrapper classes and
hold the minimum and maximum values for a particular data type.

a. MIN_VALUE and MAX_VALUE


b. MIN and MAX
c. MINIMUM and MAXIMUM
d. LOWEST and HIGHEST
a. MIN_VALUE and MAX_VALUE
True or False: Character testing methods, such as isLetter , accept strings as
arguments and test each character in the string.
false
True or False: If the toUpperCase method's argument is already uppercase, it
is returned as is, with no changes.
true
True or False: If toLowerCase method's argument is already lowercase, it will
be inad-vertently converted to uppercase.
false
True or False: The startsWith and endsWith methods are case-sensitive.
true
True or False: There are two versions of the regionMatches method: one that
is case-sensitive and one that can be case-insensitive.
true
True or False: The indexOf and lastIndexOf methods can find characters, but
cannot find substrings.
false
True or False: The String class's replace method can replace individual
characters, but cannot replace substrings.
true
True or False: The StringBuilder class's replace method can replace individual
char-acters, but cannot replace substrings.
false
True or False: You can use the = operator to assign a string to a StringBuilder
object.
false
Find the error
1. In an inheritance relationship, this is the general class.

a. subclass
b. superclass
c. derived class
d. child class
b. superclass
2. In an inheritance relationship, this is the specialized class.

a. superclass
b. base class
c. subclass
d. parent class
c. subclass
3. This key word indicates that a class inherits from another class.

a. derived
b. specialized
c. based
d. extends
d. extends
4. In a subclass does not have access to these superclass member
...
5. This key word refers to an object's superclass.

a. super
b. base
c. this
d. parent
super
6. In a subclass constructor, a call to the superclass constructor must
Very first statement
The following is an explicit call to the superclass's default constructor.

a. default();
b. class();
c. super();
d. base();
super()
8. A method in a subclass having the same signature as a method in the
superclass is an
example of

a. overloading
b. overriding
c. composition
d. an error
b. overriding
9. A method in a subclass having the same name as a method in the
superclass but a
different signature, is an example of

a. overloading
b. overriding
c. composition
d. an error
a. overloading
10. These superclass members are accessible to subclasses and classes in
the same packet.
Protected
11. all classes directly or indirectly inherit from this class.
object
12. With this type of binding, the Java Virtual Machine determines at runtime
which
method to call, depending on the type of the object that a variable references.
a. static
b. early
c. flexible
d. dynamic
d. dynamic
13. When a class implements an interface, it must

a. overload all of the methods listed in the interface


b. provide all of the methods that are listed in the interface, with the exact
signatures
specified
c. not have a constructor
d. be an abstract class
b. provide all of the methods that are listed in the interface, with the exact
signatures
specified
14. Fields in an interface are

a. final
b. static
c. both final and static
d. not allowed
c. both final and static
15. Abstract methods must be

a. overridden
b. overloaded
c. deleted and replaced with real methods
d. declared as private
a. overridden
16. Abstract classes cannot

a. be used as superclasses
b. have abstract methods
c. be instantiated
d. have fields
c. be instantiated
17. Constructor are not inherited.
False
18. In a subclass, a call to the superclass constructor can be written only in
the subclass constructor
True
19. True or False: If a subclass constructor does not explicitly call a
superclass constructor,
Java will not call any of the superclass's constructors.
False
20. True or False: An object of a superclass can access members declared in
a subclass.
False
21. True or False: The superclass constructor always executes before the
subclass constructor.
True
22. True or False: When a method is declared with the final modifier, it must
be overridden
in a subclass.
False
23. True or False: A superclass has a member with package access. A class
that is outside
the superclass's package but inherits from the superclass can access this
member.
False
24. a superclass reference variable can reference an object of a class that
inherits from the superclass.
...
25. True or False: A subclass reference variable can reference an object of
the superclass.
True
26. True or False: When a class contains an abstract method, the class
cannot be instantiated.
True
27. True or False: A class can implement only one interface.
False
28. By default all members of an interface are public
False
this type of method does not return a value.
a. null
b. void
c. empty
d. anonymous
b. void
This appears at the beginning of a method definition.
a. semicolon
b. parentheses
c. body
d. header
d. header
The body of a method is enclosed in ________.
a. curly braces {}
b. square brackets []
c. parentheses ()
d. quotation marks ""
a. curly braces {}
a method header can contain __________.
a. method modifiers
b. the method return type
c. the method name
d. a list of parameter declarations
e. all of theses
f. none of these
e. all of these
A value that is passed into a method when it is called is known as a(n)______.
a. parameter
b. argument
c. signal
d. return value
b. argument
a variable that receives a value that is passed into a method is known as a(n) _______.
a. parameter
b. argument
c. signal
d. return value
a. parameter
This javadoc tag is used to document a parameter variable.
a. @parameter
b. @para
c. @paramvar
d. @arg
b. @para
This statement causes a method to end and sends a value back to the statement that
called the method.
a. end
b. send
c. exit
d. return
d. return
this javadoc tag is used to document a method's return value
a. @methodreturn
b. @ret
c. @return
d. @returnval
c. @return
true or false. you terminate a method header with a semicolon.
false
true or false. when passing an argument to a method, java will automatically perform
a widening conversion, if necessary
true
true or false. when passing an argument to a method, java will automatically perform
a narrowing conversion when necessary.
false
true or false. a parameter variable's scope is the entire program that contains the
method in which the parameter is declared
false
true or false. when code in a method changes the value of a parameter, it also changes
the value of the argument that was passed into the parameter.
false
true or false. when an object, such as String, is passed as an argument, it is actually a
reference to the object that is passed.
true
true or false. the contents of a string object cannot be changed
true
true or false. when passing multiple arguments to a method, the order in which the
arguments are passed is not important.
false
true or false. no two methods in the same program can have a local variable with the
same name.
false
true or false. it is possible for one method to access a local variable that is declared in
another method.
false
true or false. you must have a return statement in a value-returning method
true

You might also like