Uploaded by 1806967389

EXAM

advertisement
A(n) ____ is simply a folder that provides a convenient grouping for classes.
d. package
The Character class ____ from java.lang.Object.
d. inherits
You can use the ____ modifier with methods when you don't want the method to be overridden.
b. final
When you employ ____, your data can be altered only by the methods you choose and only in
ways that you can control.
a. information hiding
When you create any subclass object, the subclass constructor must execute first, and then
the superclass constructor executes.
False
The compiler determines which version of a method to call by the method's ____.
d. signature
____ describes the feature of languages that allows the same word to be interpreted correctly
in different situations based on the context.
b. Polymorphism
When an application contains an array and you want to use every element of the array in some
task, it is common to perform loops that vary the loop control variable from 0 to one less than
the size of the array.
True
To use a method to its full potential, you must know the method name, return type, type and
number of arguments required, and type and number of exceptions the method throws.
True
When you create an array of objects, each reference is assigned the value ____.
Null
Which of the following println statements will display the last myScores element in an
array of 10?
c. System.out.println(vals[9]);
Sometimes the superclass data fields and methods are not entirely appropriate for the subclass
objects; in these cases, you want to ____ the parent class members.
c. override
____ polymorphism is the ability of one method to work appropriately for subclasses of the
same parent class.
a. Subtype
When you declare int[]someNums = new int[10];, each element of someNums has
a value of ____.
d. 0
The ____ class comprises less serious errors that represent unusual conditions that arise while
a program is running and from which the program can recover.
c. Exception
A(n) ____ method is a method that creates and initializes class objects.
b. constructor
You can write your own constructor methods; but when you don't write a constructor method
for a class object, Java writes one for you.
True
____ is a mechanism that enables one class to acquire all the behaviors and attributes of another
class.
b. Inheritance
When you use a(n) ____ statement, you state a condition that should be true, and Java throws
an AssertionError when it is not.
b. assert
Each primitive type in Java has a corresponding class contained in the java.lang package.
These classes are called ____ classes.
b. type-wrapper
Consider the statement:
int anInt = Integer.parseInt("649");
You can tell that parseInt() is a(n) ____ method because you use it with the class name
and not with an object.
b. static
If you want all objects to share a single nonchanging value, then the field is static and
______.
c. final
The code within a finally block cannot execute if the preceding try block identifies an
exception.
False
Normally, you declare constructors to be ____so that other classes can instantiate objects that
belong to the class.
b. public
Due to automatic type promotion, when a method with a double parameter is passed an
integer, the integer will be promoted to a(n) ____.
d. double
A ____ is a class for storing and manipulating changeable data that is composed of multiple
characters.
b. StringBuilder
When any primitive type is passed to a method, the ____ is passed.
a. value
____ forces a value of one data type to be used as a value of another type.
a. Type casting
When the String class ____ method is used to compare two Strings, it provides additional
information to the user in the form of an integer value.
b. compareTo()
A(n) ____ defines the circumstances under which a class can be accessed and the other classes
that have the right to use a class.
c. access specifier
When you catch an Exception object, you can call ____ to display a list of methods in the
call stack so you can determine the location of the statement that caused the exception.
b. printStackTrace()
Download