Jowett Midterm – Flashcards

Unlock all answers in this set

Unlock answers
question
public class First { public static void main(String[ ] args) { System.out.println("First Java application"); } } ​ Given the above code, which item identifies the method's return type?
answer
void
question
public class First { public static void main(String[] args) { System.out.println("First Java application"); } } Given the above code, which item identifies that the method will work without instantiating an object of the class?
answer
static
question
A ____ is an error not detected until the program asks the computer to do something wrong, or even illegal, while executing.
answer
run-time error
question
A program written in ____ is the most basic circuitry-level language.
answer
machine language
question
A(n) ____ defines the circumstances under which a class can be accessed and the other classes that have the right to use a class.
answer
access specifier
question
After a successful compile, you can run the class file on any computer that has a ____.
answer
Java Language Interpreter
question
If a compiler detects a violation of language rules, it refuses to translate the class to ____.
answer
machine code
question
If you receive an error that states, "Exception in thread 'main' java.lang.NoClassDefFoundError," when you try to execute the application, you probably do not have your ____ set correctly.
answer
class path
question
In Java, the reserved keyword ____ means that a method is accessible and usable even though no objects of the class exist.
answer
static
question
In a ____ environment, you can change directories using the cd command. For example, to change to a directory named MyClasses, you type cd MyClasses and press Enter.
answer
DOS
question
It is a tradition among programmers that the first program you write in any language produces "____" as its output.
answer
Hello, world!
question
It is best to use the ____ available text editor when writing Java programs.
answer
simplest
question
Java contains a class named ____ that allows you to produce dialog boxes.
answer
JOptionPane
question
Line comments start with ____.
answer
two forward slashes
question
Locating and repairing all syntax errors is part of the process of ____ a program.
answer
debugging
question
Programs that are embedded in a Web page are called Java ____.
answer
applets
question
When you run a Java application using the ____ command, do not add the .class extension to the filename.
answer
java
question
Whenever a method requires multiple arguments, the arguments are always separated with ____.
answer
commas
question
____ are also called modules, methods, functions, and subroutines. Java programmers most frequently use the term "method."
answer
Procedures
question
____ are pieces of information that are sent into, or passed to, a method, usually because the method requires the information to perform its task or carry out its purpose.
answer
arguments
question
____ describes the feature of languages that allows the same word to be interpreted correctly in different situations based on the context.
answer
Polymorphism
question
____ is the process the compiler uses to divide your source code into meaningful portions; the message means that the compiler was in the process of analyzing the code when the end of the file was encountered prematurely.
answer
Parsing
question
____ refers to the hiding of data and methods within an object.
answer
Encapsulation
question
public class First { public static void main(String[] args) { System.out.println("First Java application"); } } Given the above code, which item identifies the name of the class?
answer
First
question
{ public static void main(String[] args) { System.out.println("First Java application"); } } Given the above code, which item identifies the access specifier?
answer
Public
question
Allow you to assign intuitive names to areas of computer memory Any combination of nonprinting characters The characteristics that define an object A low-level programming language Translates an entire program before carrying out the statement The rules for the programming language Hypothetical computer used to run a Java program Series of characters that will appear in output exactly as entered A GUI object resembling a window in which you can place messages you want to display
answer
high level programming language whitespace attributes machine language compiler syntax Java Virtual Machine literal string dialog box
question
A ____ is a named memory location that you can use to store a value.
answer
variable
question
A data item is ____ when it cannot be changed while a program is running.
answer
constant
question
A(n) ____ dialog box asks a question and provides a text field in which the user can enter a response.
answer
input
question
A(n) ____ dialog box typically displays the options Yes, No, and Cancel.
answer
confirm
question
A(n) ____ variable can hold only one of two values: true or false.
answer
boolean
question
Each primitive type in Java has a corresponding class contained in the java.lang package. These classes are called ____ classes.
answer
type wrapper
question
In Java, ____ is a built-in class that provides you with the means for storing and manipulating character strings.
answer
string
question
In Java, when a numeric variable is concatenated to a String using the ____, the entire expression becomes a String.
answer
plus sign
question
In Java, you use variables of type ____ to store integers, or whole numbers.
answer
int
question
Primitive types serve as the building blocks for more complex data types, called ____ types.
answer
reference
question
The ____ is the type to which all operands in an expression are converted so that they are compatible with each other.
answer
unifying type
question
The characters ____ move the cursor to the next line when used within a println() statement.
answer
/n
question
The percent sign is the ____ operator.
answer
remainder
question
The term ____ refers to the mathematical accuracy of a value.
answer
significant digits
question
What is the value of result after the following statement is executed? int result = 2 + 3 * 4;
answer
14
question
When a numeric variable is concatenated to a String, the entire expression becomes a(n) ____.
answer
string
question
Which escape sequence will move the cursor to the beginning of the current line?
answer
r
question
Which of the following is NOT a component of a variable declaration statement?
answer
symbolic constant
question
You can store any character, including nonprinting characters such as a backspace or a tab, in a(n) ____ variable.
answer
char
question
You may declare an unlimited number of variables in a statement as long as the variables are ____.
answer
the same data type
question
You use ____ operators to perform calculations with values in your programs.
answer
arithmetic
question
You use the ____ data type to hold any single character.
answer
char
question
____ occurs when both of the operands are integers.
answer
Integer Division
question
____ refers to the order in which values are used with operators.
answer
Associativity
question
true or false The operator that is represented by an equal sign (=) A programming term for an unknown value Java consistently specifies their size and format A value that can be used on either side of an operator Rules for the order in which parts of a mathematical expression are evaluated A floating-point data type Created by placing the desired result type in parentheses Begins with a backslash followed by a character
answer
boolean assignment garbage value primitive type operand operator procedure float cast operator escape sequence
question
A method header is also called a(n) _____.
answer
declaration
question
A unique identifier is most likely used as a ____ key in a database.
answer
primary
question
A(n) ____ causes a value to be sent from a called method back to the calling environment.
answer
return statements
question
A(n) ____ constructor is one that requires no arguments.
answer
default
question
A(n) ____ is a program module that contains a series of statements that carry out a task.
answer
method
question
A(n) ____ method is a method that creates and initializes class objects.
answer
constructor
question
A(n) ____ variable is known only within the boundaries of the method.
answer
local
question
After an object has been instantiated, its methods can be accessed using the object's _____, a dot, and a method call.
answer
identifier aka name
question
Assigning ____ to a field means that no other classes can access the field's values.
answer
private access
question
Data items you use in a call to a method are called ____.
answer
arguments
question
Every object is a _____ of a more general class.
answer
member
question
For ease in locating class methods, many programmers store them in ____ order.
answer
alphabetical
question
In order to allocate the needed memory for an object, you must use the ____ operator.
answer
new
question
Method names that begin with ____ and set are very typical.
answer
get
question
Methods used with object instantiations are called ____ methods.
answer
instance
question
Public classes are accessible by all objects, which means that public classes can be ____, or used as a basis for any other class.
answer
extended
question
The ____ method executes first in an application, regardless of where you physically place it within its class.
answer
main ()
question
The arguments in a method call are often referred to as ____.
answer
actual parameters
question
The name of the ____ is always the same as the name of the class whose objects it constructs.
answer
constructor
question
When a variable ceases to exist at the end of a method, programmers say the variable ____.
answer
goes out of scope
question
When an application is run, the method that must be executed first must be named ____.
answer
main ()
question
Which of the following is NOT an initial value assigned to an object's data field by a default constructor?
answer
Boolean fields set to true
question
____ is a principle of object-oriented programming that describes the encapsulation of method details within a class.
answer
Implementation giding
question
____ parameters are variables in a method declaration that accept the values from the actual parameters.
answer
formal
question
A locally declared variable always ____ another variable with the same name elsewhere in the class.
answer
masks
question
A method can receive ____ arguments, even if it is defined as needing double arguments.
answer
integer
question
A variable comes into existence, or ____, when you declare it.
answer
comes into scope
question
Another name for a nonstatic member class is a(n) ____.
answer
inner class
question
Due to automatic type promotion, when a method with a double parameter is passed an integer, the integer will be promoted to a(n) ____.
answer
double
question
If a class's only constructor requires an argument, you must provide an argument for every ____ of the class that you create.
answer
object
question
If you want all objects to share a single nonchanging value, then the field is static and ______.
answer
final
question
It is a convenience to be able to use one reasonable name for ____ that are functionally identical except for argument types.
answer
tasks
question
It is not necessary to create an instance of the Math class because the constants and methods of the class are ____.
answer
static
question
Object-oriented programmers use the term ____ when a child class contains a field or method that has the same name as one in the parent class.
answer
override
question
The ____ package contains is implicitly imported into Java programs and is the only automatically imported, named package.
answer
java.lang
question
The ____ statement notifies the program that you will be using the data and method names that are part of the imported class or package.
answer
import
question
The compiler determines which version of a method to call by the method's ____.
answer
signature
question
The reference to an object that is passed to any object's nonstatic class method is called the ____.
answer
this reference
question
When an application contains just one version of a method, you can call the method using a(n) ____ of the correct data type.
answer
parameter
question
When an object of one class is a data field within another class, they are related by ____.
answer
composition
question
When calling this() from a constructor, it must be the ____ statement within the constructor.
answer
first
question
When they have the same name, variables within ____ of a class override the class's fields.
answer
methods
question
When you instantiate an object from a class, ____ is reserved for each instance field in the class.
answer
memory
question
When you properly ____ a method, you can call it providing different argument lists, and the appropriate version of the method executes.
answer
overload
question
Within any class or method, the code between a pair of curly braces is called a(n) ____.
answer
block
question
You can use ____ arguments to initialize field values, but you can also use arguments for any other purpose.
answer
constructor
question
You can use the asterisk (*) as a ____, which indicates that it can be replaced by any set of characters.
answer
wildcard symbol
question
____ involves using one term to indicate diverse meanings, or writing multiple methods with the same name but with different parameter lists.
answer
overloading
question
____ variables are variables that are shared by every instantiation of a class.
answer
class
question
A variable comes into existence Using one term to indicate diverse meanings Must be explicitly named in an import statement Starts with the second opening curly brace and ends with the first closing curly brace Describes the relationship between classes when an object of one class is a data field within another class Defines mathematical constants such as PI Useful when working with dates and times No object associated with them Created using the keyword final
answer
comes into scope overloading optional classes inner block composition math class java.time class methods constant
question
A ____ checks a value, and based on the result performs one of two actions.
answer
decision structure
question
A ____ consists of written steps in diagram form, as a series of shapes connected by arrows.
answer
flowchart
question
A logical structure called a(n) ____ structure is when one step follows another unconditionally.
answer
sequence
question
A(n) ____ is a series of if statements that determine whether a value falls within a specified range.
answer
range check
question
A(n) ____ statement is the decision structure you use when you need to take one or the other of two possible courses of action.
answer
dual alternative if
question
Just as you can block statements that depend on an if, you can also block statements that depend on a(n) ____.
answer
else
question
Statements in which an if structure is contained inside another if structure are commonly called ____ if statements.
answer
nested
question
The AND operator is written as two ____.
answer
ampersands
question
The ____ operator is always evaluated before the OR operator.
answer
AND
question
The ____ operator is written as the exclamation point ( ! ).
answer
NOT
question
The ____ requires three expressions separated with a question mark and a colon.
answer
conditional operator
question
The ____ statement is useful when you need to test a single variable against a series of exact integer, character, or string values.
answer
switch
question
The compiler does not take indentation into account when compiling code, but consistent indentation can help readers understand a program's ____.
answer
logic
question
The simplest statement you can use to make a decision is the ____ statement.
answer
if
question
When an expression containing a ____ is part of an if statement, the assignment is illegal.
answer
single equal sign
question
When using equals and not equals for comparisons with objects, you compare the objects' ____ instead of actual values.
answer
memory addresses
question
When working with logical operators, you can always use ____ to change precedence.
answer
parentheses
question
When you block statements, you must remember that any ____ you declare within a block is local to that block.
answer
variable
question
When you execute an if...else statement, only one of the resulting actions takes place depending on the evaluation of the ____ following the if.
answer
independent statement
question
When you place a block within an if statement, it is crucial to place the ____ correctly.
answer
curly braces
question
When you use the && operator, you must include a complete _____ on each side.
answer
Boolean Expression
question
In Java, you can leave out the ____ statements in a switch structure.
answer
if
question
if (quotaAmt > 100 || sales > 100 && productCode == "C") bonusAmt = 50; ​ When the above code is executed, which operator is evaluated first?
answer
&&
question
true and false A double equal sign Two possible courses of action Two ampersands Used in the OR operator > or < An alternative to using a series of nested if statements Separated with a question mark and a colon The logical NOT operator
answer
Boolean Values equality dual alternative logical and operator pipes relational operator switch statement conditional operator !
question
A ____ is a structure that allows repeated execution of a block of statements.
answer
loop
question
A for loop provides a convenient way to create a(n) ____ loop.
answer
counter-controlled
question
A loop controlled by user entry is a type of ____ loop.
answer
indefinite
question
A loop that never ends is called a(n) ____ loop.
answer
indefinite
question
A(n) ____ loop is a special loop that is used when a definite number of loop iterations is required.
answer
for
question
An indefinite loop is a(n) ____ loop.
answer
event-controlled
question
How many times will outputLabel be called? for(customer = 1; customer <= 20; ++customer) for(color = 1; color <= 3; ++color) outputLabel();
answer
60
question
In a do...while loop, the loop will continue to execute until ____.
answer
the loop control variable is false
question
In the expressions b = 8 and c = --b, what value will be assigned to the variable c?
answer
7
question
It is important that the loop control ____ be altered within the body of the loop.
answer
variable
question
The ____ loop checks the value of the loop control variable at the bottom of the loop after one repetition has occurred.
answer
do...while
question
The order of the conditional expressions in the following is most important within a(n) ____ loop. while(requestedNum > LIMIT || requestedNum < 0)...
answer
nested
question
The process of repeatedly increasing a value by some amount is known as ____.
answer
accumulating
question
Use a(n) ____ loop to execute a body of statements continually as long as the Boolean expression that controls entry into the loop continues to be true.
answer
while
question
When you want to increase a variable's value by exactly 1, use the ____.
answer
prefix increment operator
question
Which is an infinite loop?
answer
} loopCount = 1; while(loopCount < 3); { System.out.println("Hello"); loopCount = loopCount + 1;
question
Which of the following is NOT a valid method to increase a variable named score by 1?
answer
++score = score + 1
question
You can initialize more than one variable in a for loop by placing a(n) ____ between the separate statements.
answer
comma
question
You use a unary minus sign preceding a value to make the value ____.
answer
negative
question
____ is the process of ensuring that a value falls within a specified range.
answer
validating data
question
Multiple statements within curly braces The value that determines whether loop execution continues Subtracting 1 from a variable A countered loop A shortcut for incrementing and accumulating Operate on two values Within parentheses are three sections separated by exactly two semicolons Part of the Thread class in the java.lang package The technique of combining two loops into one
answer
block loop control variable decrementing definite loop prefix ++ binary operators for loop sleep () method loop fusion
question
A StringBuilder object contains a memory block called a _____, which might or might not contain a string.
answer
buffer
question
A ____ is a class for storing and manipulating changeable data that is composed of multiple characters.
answer
stringbuilder
question
A literal string is a(n) ____ object.
answer
anonymous
question
A(n) ____ comparison is based on the integer Unicode values of the characters.
answer
lexigraphical
question
A(n) ____ is a variable that holds a memory address.
answer
reference
question
Besides Double and Integer, other wrapper classes such as Float and Long also provide ____ methods that convert Strings to the wrapper types.
answer
valueof ()
question
String oneStr = "Welcome Jim" String twoStr = "Welcome Joe" Given the lines of code above, which of the following regionMatches() expressions will result in a value of true?
answer
oneStr.regionMatches(0, twoStr, 0, 7)
question
Strings and other objects that can't be changed are known as ____.
answer
immutable
question
System.out.println("Your name is " + yourName); The above statement is an example of ____, which is used to join Strings.
answer
concatenation
question
The Character class ____ from java.lang.Object.
answer
inherits
question
The String class ____ method evaluates the contents of two String objects to determine if they are equivalent.
answer
equals ()
question
The ____ method allows you to replace all occurrences of some character within a String.
answer
replace ()
question
The ____ method converts any object to a String.
answer
to string ()
question
The ____ method lets you add characters at a specific location within a StringBuilder object.
answer
insert ()
question
The ____ method returns the length of a String.
answer
length ()
question
The ____ method takes a String argument and returns its double value.
answer
parse double ()
question
The creators of Java chose ____ characters as the "extra" length for a StringBuilder object.
answer
16
question
The method header of the equals() method within the String class is ____.
answer
public boolean equals(String s)
question
The methods of the Character class that begin with ____ return a character that has been converted to the stated format.
answer
to
question
To alter just one character in a StringBuilder, you can use the ____ method, which allows you to change a character at a specified position within a StringBuilder object
answer
setCharAt()
question
To convert a String to an integer, you use the ____ class, which is part of java.lang and is automatically imported into programs you write.
answer
integer
question
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.
answer
compareto ()
question
When you declare a variable of a basic, primitive type, such as int x = 10;, the memory address where x is located holds the ____.
answer
value of 10
question
Which of the following correctly declares and initializes a String object?
answer
String greeting = "Hello";
question
You can tell that the equals() method takes a ____ argument because parentheses are used in the method call.
answer
string
Get an explanation on any task
Get unstuck with the help of our AI assistant in seconds
New