comp final
A runtime error is usually the result of ________.
a logical error
Every Java application program must have ________.
a method named main
In all but very rare cases, loops must contain, within themselves ________.
a way to terminate
The following statement is an example of ________.import java.util.*;
a wildcard import statement
The header of a value-returning method must specify ________.
the data type of the return value
Which of the following expressions will determine whether x is less than or equal to y?
x <= y
If x has been declared an int, which of the following statements is invalid?
x = 1,000;
The scope of a public instance field is ________.
the instance methods and methods outside the class
Which type of method performs a task and sends a value back to the code that called it?
value-returning
Which of the following statements will correctly convert the data type, if x is a float and y is a double?
x = (float)y;
A Java source file must be saved with the extension ________.
.java
By default, Java initializes array elements to ________.
0
How many times will the following for loop be executed?
12
What will be printed when the following code is executed?double x = 45678.259;System.out.printf("%,.2f", x);
45,678.26
When an array is passed to a method ________.
All of these are true
Local variables can be initialized with ________.
Any of these.
A value-returning method must specify ________ as its return type in the method header.
Any valid data type
________ refers to combining data and code into a single object.
Encapsulation
Which of the following statements opens a file named MyFile.txt and allows you to read data from it?
File file = new File("MyFile.txt"); Scanner inputFile = new Scanner(file);
Which of the following statements opens a file named MyFile.txt and allows you to append data to its existing contents?
FileWriter fwriter = new FileWriter("MyFile.txt", true); PrintWriter outFile = new PrintWriter(fwriter);
________ refers to the physical components that a computer is made of.
Hardware
Which of the following is not a rule that must be followed when naming identifiers?
Identifiers can contain spaces.
What does the following statement do?double[] array1 = new double[10];
It does all of these.
What would be displayed as a result of executing the following code?final int x = 22, y = 4;y += x;System.out.println("x = " + x + ", y = " + y)
Nothing. There is an error in the code.
Which of the following statements will create an object from the Random class?
Random myNumber = new Random();
________ operators are used to determine whether a specific relationship exists between two values.
Relational
Which of the following statements correctly creates a Scanner object for keyboard input?
Scanner keyboard = new Scanner(System.in);
________ works like this: If the expression on the left side of the && operator is false, the expression the right side will not be checked.
Short-circuit evaluation
Java was developed by ________.
Sun Microsystems
A ragged array is ________.
a two-dimensional array where the rows have different numbers of columns
in the following code, Integer.parseInt(str) is an example of ________.int num;string str = "555";num = Integer.parseInt(str) + 5;
a value-returning method
A characteristic of ________ is that only an object's methods are able to directly access and make changes to an object's data.
data hiding
Variables are classified according to their ________.
data types
When an argument value is passed to a method, the receiving parameter variable is ________.
declared in the method header inside the parentheses
To create a method, you must write its ________.
definition
An item that separates other items is known as a ________.
delimiter
The ________ loop is ideal in situations where you always want the loop to iterate at least once.
do-while
Variables of the boolean data type are useful for ________.
evaluating conditions that are either true or false
It is common practice in object-oriented programming to make all of a class's ________.
fields private
A class specifies the ________ and ________ that a particular type of object has.
fields, methods
A constructor ________.
has the same name as the class
Overloading means that multiple methods in the same class ________.
have the same name but different parameter lists perform the same function
The ________ statement is used to create a decision structure which allows a program to have more than one path of execution.
if
Which of the following statements determines whether the variable temp is within the range of 0 through 100 (inclusive)?
if (temp >= 0 && temp <= 100)
When working with the PrintWriter class, which of the following import statements should you have near the top of your program?
import java.io.*;
Which of the following is a valid declaration for a ragged array with five rows but no columns?
int[][] ragged = new int[5][];
Class objects normally have ________ that perform useful operations on their data, but primitive variables do not.
methods
If numbers is a two-dimensional array, which of the following would give the number of columns in row r?
numbers[r].length
A(n) ________ is a software entity that contains data and procedures.
object
Most of the programming languages used today are ________.
object-oriented
While ________ is centered on creating procedures, ________ is centered on creating objects.
procedural programming, object-oriented programming
Which of the following is a correct method header for receiving a two-dimensional array as an argument?
public static void passArray(int [][])
The ________ method removes an item from an ArrayList at a specific index.
remove
Instance methods do not have the ________ key word in their headers.
static
If str1 and str2 are both String objects, which of the following expressions will correctly determine whether or not they are equal?
str1.equals(str2)
Which of the following expressions could be used to perform a case-insensitive comparison of two String objects named str1 and str2?
str1.equalsIgnoreCase(str2)
Given that String[] str has been initialized, to get a copy of str[0] with all the characters converted to uppercase, you would use the ________ statement.
str[0].toUpperCase();
Java allows you to create objects of the ________ class in the same way you would create primitive variables.
string
A UML diagram does not contain ________.
the object names
In Java, ________ must be declared before they can be used.
variables
A ________ type of method performs a task and then terminates.
void
A partially filled array is normally used ________.
with an accompanying integer value that holds the number of items stored in the array
Which of the following is the not equal operator?
!=
Subscripting always starts with ________.
0
Which of the following is not one of the major components of a typical computer system?
All of these are major components
Which of the following is not part of the programming process?
All of these are parts of the programming process
What would be the result of executing the following code?int[] x = {0, 1, 2, 3, 4, 5};
An array of 6 values, ranging from 0 through 5 and referenced by the variable x will be created.
Which of the following statements will create a reference, str, to the String "Hello, World"?
String str = "Hello, World";
Which of the following will format 12.7801 to display as $12.78?
System.out.printf("$%,.2f", 12.7801);
To print "Hello, world" on the monitor, which of the following Java statements should be used?
System.out.println("Hello, world");
What will be the result after the following code executes?int num;string str = "555";num = Integer.parseInt(string str) + 5;
The last line of code will cause an error.
Given the following two-dimensional array declaration, which statement is true?int[][] numbers = new int[6][9];
The numbers array has 6 rows and 9 columns.
In Java, when a character is stored in memory, it is actually the ________ that is stored.
Unicode number
To display the output on the next line, you can use the println method or use the ________ escape sequence in the print method.
\n
When a method tests an argument and returns a true or false value, it should return ________.
a boolean value
A Java program must have at least one of the following.
a class definition
In a general sense, a method is ________.
a collection of statements that perform a specific task
If you attempt to use a local variable before it has been given a value, ________.
a compiler error will occur
What does the following UML diagram entry mean?+ setHeight(h : double) : void
a public method with a parameter of data type double that does not return a value
A computer program is ________.
a set of instructions that allow the computer to solve a problem or perform a task
Java requires that the boolean expression being tested by an if statement be enclosed in ________.
a set of parentheses
Which of the following is a named storage location in the computer's memory?
a variable
In the following code, System.out.println(num) is an example of ________.double num = 5.4;System.out.println(num);num = 0.0;
a void method
It is common practice to use a ________ variable as a size declarator.
final
A ________ is a boolean variable that signals when some condition exists in the program.
flag
The ________ loop is ideal in situations where the exact number of iterations is known.
for
If a loop does not contain, within itself, a valid way to terminate, it is called a(n) ________ loop
infinite
In Java, you do not use the new operator when you use a(n) ________.
initialization list
To compile a program named First you would use which of the following commands?
javac First.java
Which of the following will compile a program called ReadIt?
javac ReadIt.java
Each array in Java has a public field named ________ that contains the number of elements in the array.
length
A value that is written into the code of a program is a(n) ________.
literal
To return an array of long values from a method, which return type should be used for the method?
long[]
Which is a control structure that causes a statement or group of statements to repeat?
loop
The variable that controls the number of times a loop iterates is known as a ________.
loop control variable
Each different type of CPU has its own ________.
machine language
A ________ is a part of a method that contains a collection of statements that are performed when the method is executed.
method body
The switch statement is a ________.
multiple alternative decision structure
Which Scanner class method reads a String?
nextLine
A group of related classes is called a(n) ________.
package
In the header, the method name is always followed by ________.
parentheses
A constructor is a method that ________.
performs initialization or setup operations
A ________ loop will always be executed at least once.
posttest
A set of programming language statements that perform a specific task is a(n) ________.
procedure
A(n) ________ is used to write computer programs.
programming language
Software refers to ________.
programs
A cross between human language and a programming language is called ________.
pseudocode
One type of design tool used by programmers when creating a model of a program is ________.
pseudocode
Which of the following is a correct method header for receiving a two-dimensional array as an argument?
public static void passMyArray(int[][])
Which of the following is not a part of a method call?
return type
Which of the following is not part of a method header?
semicolon
The end of a Java statement is indicated by a(n) ________.
semicolon (;)
A ________ is a value that signals when the end of a list of values has been reached.
sentinel
You can use the ________ method to replace an item at a specific location in an ArrayList.
set
Character literals are enclosed in ________ and string literals are enclosed in ________.
single quotes, double quotes
Which of the following is not a primitive data type?
string
When the + operator is used with strings, it is known as the ________.
string concatenation operator
A(n) ________ is used as an index to pinpoint a specific element within an array.
subscript
Variables are ________.
symbolic names made up by the programmer that represent memory locations
Which of the following is not involved in identifying the classes to be used when developing an object-oriented application?
the code
The process of breaking a problem down into smaller pieces is sometimes called ________.
the divide and conquer method
When an individual element of an array is passed to a method ________.
the method does not have access to the original array
A parameter variable's scope is ________.
the method in which the parameter is declared
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
Application software refers to ________.
the programs that make the computer useful to the user
What is syntax?
the rules that must be followed when writing a program
Two or more methods in a class may have the same name as long as ________.
they have different parameter lists
Key words are ________.
words that have a special meaning in the programming language
RAM is usually ________.
a volatile type of memory, used for temporary storage
When an object is created, the attributes associated with the object are called ________.
instance fields
Methods that operate on an object's fields are called ________.
instance methods
Which symbol indicates that a member is public in a UML diagram?
+
Which symbol indicates that a member is private a UML diagram?
-
Which of the following is not a valid Java comment?
*/ Comment two /*
If final int SIZE = 15 and int[] x = new int[SIZE], what would be the range of subscript values that could be used with x[]?
0 through 14
How many times will the following do-while loop be executed?
1
The primitive data types only allow a(n) ________ to hold a single value.
variable
Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops is the correct way to read data from the file until the end of the file is reached?
while (inputFile.hasNext()) { ... }
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 output will be displayed as a result of executing the following code?int x = 5, y = 20;x += 32;y /= 4;System.out.println("x = " + x + ", y = " + y);
x = 37, y = 5
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}
Which of the following is the correct boolean expression to test for: int x being a value between, but not including, 500 and 650, or int y not equal to 1000?
((x > 500 && x < 650) || (y != 1000))
A flag may have the values ________.
true or false
The ________ loop allows the user to decide on the number of iterations.
user controlled loop
Assuming that inputFile references a Scanner object that was used to open a file, which of the following statements will read an int from the file?
int number = inputFile.nextInt();
Assume that the following method header is for a method in class A.public void displayValue(int value)Assume that the following code segments appear in another method, also in class A. Which contains a legal call to the displayValue method?
int x = 7;displayValue(x);
Each repetition of a loop is known as a(n) ________.
iteration
When an argument is passed to a method ________.
its value is copied into the method's parameter variable
You should always document a method by writing comments that appear ________.
just before the method's definition
Which of the following cannot be used as identifiers in Java?
key words
Before entering a loop to compute a running total, the program should first ________.
set the accumulator variable to an initial value, often zero
The central processing unit (CPU) consists of two parts which are ________.
the control unit and the arithmetic and logic unit (ALU)
Internally, the central processing unit (CPU) consists of two parts which are ________.
the control unit and the arithmetic/logic unit (ALU)
The scope of a private instance field is ________.
the instance methods of the same class
When you pass an argument to a method you should be sure that the argument's type is compatible with ________.
the parameter variable's data type
In an if-else statement, if the boolean expression is false then ________.
the statement or block following the else is executed
To indicate the data type of a variable in a UML diagram, you enter ________.
the variable name followed by a colon and the data type
An expression tested by an if statement must evaluate to ________.
true or false
The boolean data type may contain which of the following range of values?
true or false
The boolean expression in an if statement must evaluate to ________.
true or false
Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by ________.
using the private access specifier on the class fields
There are ________ bits in a byte.
8
What is the value of z after the following statements have been executed?int x = 4, y = 33;double z;z = (double) (y / x);
8.0
When writing documentation comments for a method, you can provide a description of each parameter by using a ________.
@param tag
To document the return value of a method you can use a ________.
@return tag
f the following Java statements are executed, what will be displayed?System.out.println("The top three winners are\n");System.out.print("Jody, the Giant\n");System.out.print("Buffy, the Barbarian");System.out.println("Adelle, the Alligator");
The top three winners areJody, the GiantBuffy, the BarbarianAdelle, the Alligator
What would be displayed as a result of executing the following code?int x = 578;System.out.print("There are " +x + 5 + "\n" +"hens in the hen house.");
There are 5785hens in the hen house.
The variable used to keep a running total in a loop is called a(n) ________.
accumulator
When an object, such as a String, is passed as an argument it is ________.
actually a reference to the object that is passed
The following statement is an example of ________.import java.util.Scanner;
an explicit import statement
Which of the following is a software entity that contains data and procedures?
an object
Values stored in local variables ________.
are lost between calls to the method in which they are declared
Values that are sent into a method are called ________.
arguments
Java performs ________, which means that it does not allow a statement to use a subscript that is outside the range of valid subscripts for the array.
array bounds checking
The ________ indicates the number of elements the array can hold.
array's data type
If you prematurely terminate an if statement with a semicolon, the compiler will ________.
both not display an error message and assume you are placing a null statement there
A class's responsibilities include ________.
both of these
A block of code is enclosed in a set of ________.
braces, { }
Methods are commonly used to ________.
break a program down into small manageable pieces
Which of the following expressions determines whether the char variable, chrA, is not equal to the letter 'A'?
chrA != 'A'
One or more objects may be created from a(n) ________.
class
A(n) ________ can be thought of as a blueprint that can be used to create a type of ________.
class, object
A loop that executes as long as a particular condition exists is called a(n) ________ loop.
conditional
In memory, an array of String objects ________.
consists of an array of references to String objects
What will be the value of x after the following code is executed?int x, y = 15;x = y--;
15
What will be returned from the following method?
18.0
What is the value of z after the following code is executed?int x = 5, y = 28;float z;z = (float) (y / x);
5.0
A loop that repeats a specific number of times is known as a(n) ________ loop.
count-controlled
Given the following statement, which statement will write the string "Calvin" to the file DiskFile.txt?PrintWriter diskOut = new PrintWriter("DiskFile.txt");
diskOut.println("Calvin");
Given the following method header, which of these method calls is incorrect?public void displayValue(int x, int y);
displayValue(a, b); // where a is a short and b is a long
Which of the following statements is invalid?
double r = 2.9X106;
Which of the following is a value that is written into the code of a program?
a literal
A method ________.
may have zero or more parameters
A reference variable stores a(n) ________.
memory address
The lifetime of a method's local variable is ________.
only while the method is executing
A special variable that holds a value being passed into a method is called a(n) ________.
parameter
When you work with a ________, you are using a storage location that holds a piece of data.
primitive variable