Java Practice Final 2
A value-returning method must specify ________ as its return type in the method header.
Any valid data type
________ refers to the physical components that a computer is made of.
Hardware
Which of the following statements will create an object from the Random class?
Random myNumber = new Random();
A runtime error is usually the result of ________.
a logical error
Which of the following is a named storage location in the computer's memory?
a variable
In all but very rare cases, loops must contain, within themselves ________.
a way to terminate
Class objects normally have ________ that perform useful operations on their data, but primitive variables do not.
methods
In the header, the method name is always followed by ________.
parentheses
While ________ is centered on creating procedures, ________ is centered on creating objects.
procedural programming, object-oriented programming
Which of the following is not a part of a method call?
return type
The end of a Java statement is indicated by a(n) ________.
semicolon (;)
Which of the following is not a primitive data type?
string
Internally, the central processing unit (CPU) consists of two parts which are ________.
the control unit and the arithmetic/logic unit (ALU)
In the following Java statement, what value is stored in the variable name?String name = "John Doe";
the memory address where "John Doe" is located
When an object is passed as an argument to a method, what is passed into the method's parameter variable?
the object's memory address
In Java, ________ must be declared before they can be used.
variables
The binary search algorithm ________.
will cut the portion of the array being searched in half each time it fails to locate the search value
A partially filled array is normally used ________.
with an accompanying integer value that holds the number of items stored in the array
What will be the values of x and y as a result of the following code? int x = 25, y = 8; x += y++;
x = 33, y = 9
What would be the result after the following code is executed? int[] x = {23, 55, 83, 19}; int[] y = {36, 78, 12, 24}; x = y; y = x;
x[] = {36, 78, 12, 24} and y[] = {36, 78, 12, 24}
What is the value of ans after the following code has been executed? int x = 35; int y = 20, ans = 80; if (x<y) ans += y;
100
A(n) ________ can be thought of as a blueprint that can be used to create a type of ________.
class, object
Variables of the boolean data type are useful for ________.
evaluating conditions that are either true or false
You should not define a class that is dependent on the values of other class fields ________.
in order to avoid having stale data
A random number, created as an object of the Random class, is always a(n) ________.
integer
A ________ is a part of a method that contains a collection of statements that are performed when the method is executed.
method body